unicode 0.4.4.1-java → 0.4.4.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Rakefile +14 -28
 - data/lib/unicode.rb +113 -8
 - data/unicode.gemspec +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8e618ea0568276001d073d0c485e7a9f61b22e28
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 57e8fd345eceeaa7a2bf5a9f50f89b335a3dfd4f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a0734b8c7980d0372dabfafda11476204d951e21e129cc16a7d851bc660f6f8b65a181274235794c8da089e903bf356a17bceda1d9b87268bdf2e5225043a4e9
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e5c80957ea4a1c137a3d6d685cce658b26a86db1df8ee4a5abd0f580e71cf33fc684dc17976bfcbb2ccde67c135c98d04190dce958e1ab0e376497177f777c39
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,20 +1,20 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
            require  
     | 
| 
       3 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require 'rake/clean'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/extensiontask'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rubygems/package_task'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            CLEAN <<  
     | 
| 
      
 5 
     | 
    
         
            +
            CLEAN << 'pkg' << 'tmp' << 'lib/unicode'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            UPSTREAM_URL = 'http://www.yoshidam.net/unicode-%s.tar.gz'
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            gem_spec = eval(File.read(File.expand_path( 
     | 
| 
      
 9 
     | 
    
         
            +
            gem_spec = eval(File.read(File.expand_path('../unicode.gemspec', __FILE__)))
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            gem_task = Gem::PackageTask.new(gem_spec) {|pkg|}
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
            Rake::ExtensionTask.new('unicode_native', gem_spec) do |ext|
         
     | 
| 
       14 
14 
     | 
    
         
             
              ext.cross_compile = true
         
     | 
| 
       15 
15 
     | 
    
         
             
              ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
         
     | 
| 
       16 
     | 
    
         
            -
              ext.ext_dir =  
     | 
| 
       17 
     | 
    
         
            -
              ext.lib_dir =  
     | 
| 
      
 16 
     | 
    
         
            +
              ext.ext_dir = 'ext/unicode'
         
     | 
| 
      
 17 
     | 
    
         
            +
              ext.lib_dir = 'lib/unicode'
         
     | 
| 
       18 
18 
     | 
    
         
             
            end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
            namespace :gem do
         
     | 
| 
         @@ -38,25 +38,11 @@ namespace :gem do 
     | 
|
| 
       38 
38 
     | 
    
         
             
              file java_gem_path => [java_gem_dir] + java_gem_spec.files do
         
     | 
| 
       39 
39 
     | 
    
         
             
                lib_file = 'lib/unicode.rb'
         
     | 
| 
       40 
40 
     | 
    
         
             
                tmp_file = "#{lib_file}.tmp-#{$$}"
         
     | 
| 
      
 41 
     | 
    
         
            +
                jrb_file = lib_file.sub('.', '-java.')
         
     | 
| 
       41 
42 
     | 
    
         | 
| 
       42 
43 
     | 
    
         
             
                begin
         
     | 
| 
       43 
44 
     | 
    
         
             
                  mv lib_file, tmp_file
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                  File.write(lib_file, <<-EOT)
         
     | 
| 
       46 
     | 
    
         
            -
              module Unicode
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                extend self
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                def upcase(str)
         
     | 
| 
       51 
     | 
    
         
            -
                  str.to_java.to_upper_case
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                def downcase(str)
         
     | 
| 
       55 
     | 
    
         
            -
                  str.to_java.to_lower_case
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
              end
         
     | 
| 
       59 
     | 
    
         
            -
                  EOT
         
     | 
| 
      
 45 
     | 
    
         
            +
                  ln jrb_file, lib_file
         
     | 
| 
       60 
46 
     | 
    
         | 
| 
       61 
47 
     | 
    
         
             
                  Gem::Package.build(java_gem_spec)
         
     | 
| 
       62 
48 
     | 
    
         | 
| 
         @@ -66,16 +52,16 @@ namespace :gem do 
     | 
|
| 
       66 
52 
     | 
    
         
             
                end
         
     | 
| 
       67 
53 
     | 
    
         
             
              end
         
     | 
| 
       68 
54 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
              desc  
     | 
| 
      
 55 
     | 
    
         
            +
              desc 'Build native gems for Windows'
         
     | 
| 
       70 
56 
     | 
    
         
             
              task :windows do
         
     | 
| 
       71 
     | 
    
         
            -
                ENV[ 
     | 
| 
       72 
     | 
    
         
            -
                sh  
     | 
| 
       73 
     | 
    
         
            -
                sh  
     | 
| 
      
 57 
     | 
    
         
            +
                ENV['RUBY_CC_VERSION'] = '1.9.3:2.0.0:2.1.5'
         
     | 
| 
      
 58 
     | 
    
         
            +
                sh 'rake cross compile'
         
     | 
| 
      
 59 
     | 
    
         
            +
                sh 'rake cross native gem'
         
     | 
| 
       74 
60 
     | 
    
         
             
              end
         
     | 
| 
       75 
61 
     | 
    
         | 
| 
       76 
62 
     | 
    
         
             
            end
         
     | 
| 
       77 
63 
     | 
    
         | 
| 
       78 
     | 
    
         
            -
            desc  
     | 
| 
      
 64 
     | 
    
         
            +
            desc 'Update from upstream'
         
     | 
| 
       79 
65 
     | 
    
         
             
            task :update, [:version] do |t, args|
         
     | 
| 
       80 
66 
     | 
    
         
             
              require 'zlib'
         
     | 
| 
       81 
67 
     | 
    
         
             
              require 'open-uri'
         
     | 
    
        data/lib/unicode.rb
    CHANGED
    
    | 
         @@ -1,13 +1,118 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module Unicode
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
              extend self
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                  str.to_java.to_upper_case
         
     | 
| 
       7 
     | 
    
         
            -
                end
         
     | 
| 
      
 5 
     | 
    
         
            +
              VERSION = '0.4.3'
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  str.to_java.to_lower_case
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
      
 7 
     | 
    
         
            +
              Normalizer = Java::JavaText::Normalizer
         
     | 
| 
       12 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
              def strcmp(str1, str2)
         
     | 
| 
      
 10 
     | 
    
         
            +
                decompose(str1).to_java.compare_to(decompose(str2))
         
     | 
| 
       13 
11 
     | 
    
         
             
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def strcmp_compat(str1, str2)
         
     | 
| 
      
 14 
     | 
    
         
            +
                decompose_compat(str1).to_java.compare_to(decompose_compat(str2))
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def decompose(str)
         
     | 
| 
      
 18 
     | 
    
         
            +
                Normalizer.normalize(str, Normalizer::Form::NFD)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              alias_method :normalize_D, :decompose
         
     | 
| 
      
 22 
     | 
    
         
            +
              alias_method :nfd,         :decompose
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              # Decompose Unicode string with a non-standard mapping.
         
     | 
| 
      
 25 
     | 
    
         
            +
              #
         
     | 
| 
      
 26 
     | 
    
         
            +
              # It does not decompose the characters in CompositionExclusions.txt.
         
     | 
| 
      
 27 
     | 
    
         
            +
              def decompose_safe(str)
         
     | 
| 
      
 28 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              alias_method :normalize_D_safe, :decompose_safe
         
     | 
| 
      
 32 
     | 
    
         
            +
              alias_method :nfd_safe,         :decompose_safe
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              def decompose_compat(str)
         
     | 
| 
      
 35 
     | 
    
         
            +
                Normalizer.normalize(str, Normalizer::Form::NFKD)
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              alias_method :normalize_KD, :decompose_compat
         
     | 
| 
      
 39 
     | 
    
         
            +
              alias_method :nfkd,         :decompose_compat
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              # Compose Unicode string. Before composing, the trailing
         
     | 
| 
      
 42 
     | 
    
         
            +
              # characters are sorted in canonical order.
         
     | 
| 
      
 43 
     | 
    
         
            +
              #
         
     | 
| 
      
 44 
     | 
    
         
            +
              # The parameter must be decomposed.
         
     | 
| 
      
 45 
     | 
    
         
            +
              #
         
     | 
| 
      
 46 
     | 
    
         
            +
              # The composition is based on the reverse of the
         
     | 
| 
      
 47 
     | 
    
         
            +
              # character decomposition mapping in UnicodeData.txt,
         
     | 
| 
      
 48 
     | 
    
         
            +
              # CompositionExclusions.txt and the Hangul composition
         
     | 
| 
      
 49 
     | 
    
         
            +
              # algorithm.
         
     | 
| 
      
 50 
     | 
    
         
            +
              def compose(str)
         
     | 
| 
      
 51 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              def normalize_C(str)
         
     | 
| 
      
 55 
     | 
    
         
            +
                Normalizer.normalize(str, Normalizer::Form::NFC)
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
              alias_method :nfc, :normalize_C
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              def normalize_KC(str)
         
     | 
| 
      
 61 
     | 
    
         
            +
                Normalizer.normalize(str, Normalizer::Form::NFKC)
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              alias_method :nfkc, :normalize_KC
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              # Normalize Unicode string with #decompose_safe (#decompose_safe + #compose).
         
     | 
| 
      
 67 
     | 
    
         
            +
              def normalize_C_safe(str)
         
     | 
| 
      
 68 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              alias_method :nfc_safe, :normalize_C_safe
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              def upcase(str)
         
     | 
| 
      
 74 
     | 
    
         
            +
                str.to_java.to_upper_case
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              def downcase(str)
         
     | 
| 
      
 78 
     | 
    
         
            +
                str.to_java.to_lower_case
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              def capitalize(str)
         
     | 
| 
      
 82 
     | 
    
         
            +
                downcase(str).tap { |s| s[0] = upcase(s[0]) }
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              # Get an array of general category names of the string.
         
     | 
| 
      
 86 
     | 
    
         
            +
              #
         
     | 
| 
      
 87 
     | 
    
         
            +
              # Can be called with a block.
         
     | 
| 
      
 88 
     | 
    
         
            +
              def categories(str)
         
     | 
| 
      
 89 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              # Get an array of abbreviated category names of the string.
         
     | 
| 
      
 93 
     | 
    
         
            +
              #
         
     | 
| 
      
 94 
     | 
    
         
            +
              # Can be called with a block.
         
     | 
| 
      
 95 
     | 
    
         
            +
              def abbr_categories(str)
         
     | 
| 
      
 96 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              # Get an array of text elements.
         
     | 
| 
      
 100 
     | 
    
         
            +
              #
         
     | 
| 
      
 101 
     | 
    
         
            +
              # A text element is a unit that is displayed as a single character.
         
     | 
| 
      
 102 
     | 
    
         
            +
              #
         
     | 
| 
      
 103 
     | 
    
         
            +
              # Can be called with a block.
         
     | 
| 
      
 104 
     | 
    
         
            +
              def text_elements(str)
         
     | 
| 
      
 105 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
              # Estimate the display width on the fixed pitch text terminal.
         
     | 
| 
      
 109 
     | 
    
         
            +
              #
         
     | 
| 
      
 110 
     | 
    
         
            +
              # It based on Markus Kuhn's mk_wcwidth.
         
     | 
| 
      
 111 
     | 
    
         
            +
              #
         
     | 
| 
      
 112 
     | 
    
         
            +
              # If the optional argument 'cjk' is true, East Asian
         
     | 
| 
      
 113 
     | 
    
         
            +
              # Ambiguous characters are treated as wide characters.
         
     | 
| 
      
 114 
     | 
    
         
            +
              def width(str, cjk = false)
         
     | 
| 
      
 115 
     | 
    
         
            +
                raise NotImplementedError
         
     | 
| 
      
 116 
     | 
    
         
            +
              end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            end
         
     | 
    
        data/unicode.gemspec
    CHANGED