Skip to content

Instantly share code, notes, and snippets.

@andrew-d
Created August 2, 2016 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrew-d/7ad397d8548930c426340762a53c3934 to your computer and use it in GitHub Desktop.
Save andrew-d/7ad397d8548930c426340762a53c3934 to your computer and use it in GitHub Desktop.
Homebrew recipe to install unicode (https://github.com/garabik/unicode)
class Unicode < Formula
desc "Display Unicode character properties"
homepage "https://github.com/garabik/unicode"
version "2.4"
url "https://github.com/garabik/unicode/archive/v#{version}.tar.gz"
sha256 "0e3dbf8ae9b136e1799d3ed59628d2908cd89cf4ee8f3a8277d5cffc6e12e8e4"
# Python 2 has somewhat brain-dead Unicode behavior
depends_on :python3
resource 'UnicodeData.txt' do
url 'http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt'
sha256 '68dfc414d28257b9b5d6ddbb8b466c768c00ebdf6cbf7784364a9b6cad55ee8f'
end
resource 'Blocks.txt' do
url 'http://www.unicode.org/Public/9.0.0/ucd/Blocks.txt'
sha256 '612127d4889032e55d82522e4a0c19793bda8aa8da14ecb3c696d17c83e6be13'
end
resource 'Unihan.txt' do
url 'http://www.unicode.org/Public/9.0.0/ucd/Unihan.zip'
sha256 '6afdd48fb3c5d79a527ed27ce2582b2f684c09e16f5d0837fe7e5b0204f46362'
end
# Patch the tool to look for unicode data files in the location we've saved
# them.
patch :p1, :DATA
def install
# Fix the Python version - this requires Python 3
inreplace 'unicode' do |s|
s.gsub!('#!/usr/bin/python', "#!#{HOMEBREW_PREFIX}/bin/python3")
end
# Install binaries
bin.install 'unicode'
# Install manpages
man.mkpath
man1.install 'unicode.1'
# Install miscellaneous data
['UnicodeData.txt', 'Blocks.txt'].each do |res|
resource(res).stage do
pkgshare.install res
end
end
# Copy all Unihan data
resource('Unihan.txt').stage do
pkgshare.install Dir['Unihan*.txt']
end
end
test do
system "#{bin}/unicode", "0x1234"
end
end
__END__
diff --git i/unicode w/unicode
index c6bfcd2..0355836 100755
--- i/unicode
+++ w/unicode
@@ -277,19 +277,13 @@ def get_unicode_properties(ch):
def do_init():
- HomeDir = os.path.expanduser('~/.unicode')
- HomeUnicodeData = os.path.join(HomeDir, "UnicodeData.txt")
global UnicodeDataFileNames
- UnicodeDataFileNames = [HomeUnicodeData, '/usr/share/unicode/UnicodeData.txt', '/usr/share/unicode-data/UnicodeData.txt', '/usr/share/unidata/UnicodeData.txt', '/usr/share/unicode/ucd/UnicodeData.txt', './UnicodeData.txt'] + \
- glob.glob('/usr/share/unidata/UnicodeData*.txt') + \
- glob.glob('/usr/share/perl/*/unicore/UnicodeData.txt') + \
- glob.glob('/System/Library/Perl/*/unicore/UnicodeData.txt') # for MacOSX
+ UnicodeDataFileNames = ['HOMEBREW_PREFIX/share/unicode/UnicodeData.txt']
- HomeUnihanData = os.path.join(HomeDir, "Unihan*")
global UnihanDataGlobs
- UnihanDataGlobs = [HomeUnihanData, '/usr/share/unidata/Unihan*', '/usr/share/unicode-data/Unihan*', '/usr/share/unicode/Unihan*', './Unihan*']
+ UnihanDataGlobs = ['HOMEBREW_PREFIX/share/unicode/Unihan*']
global UnicodeBlocksFiles
- UnicodeBlocksFiles = ['/usr/share/unicode/Blocks.txt', '/usr/share/unicode-data/Blocks.txt', '/usr/share/unidata/Blocks.txt', './Blocks.txt']
+ UnicodeBlocksFiles = ['HOMEBREW_PREFIX/share/unicode/Blocks.txt']
# cache where grepped unicode properties are kept
global linecache
linecache = {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment