unicode 0.4.4.1-java → 0.4.4.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -28
  3. data/lib/unicode.rb +113 -8
  4. data/unicode.gemspec +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d049f7fe938ddcd91b252faa94765bf62b0b8ca8
4
- data.tar.gz: 55bf8652c415a9f707d1a68b5696e8cc50d485b7
3
+ metadata.gz: 8e618ea0568276001d073d0c485e7a9f61b22e28
4
+ data.tar.gz: 57e8fd345eceeaa7a2bf5a9f50f89b335a3dfd4f
5
5
  SHA512:
6
- metadata.gz: c08d4b381e421e322ac5d6ba65fc636fdef3dac8dfaf5ee3d5714e207c13f610bc234d82923481b1a794b836c8ce7d2a7df0fca34c3838db7acf81bf7b285e05
7
- data.tar.gz: 28a6d32de00650904048f8d93c23cfbde62d1027804b0eb457d19c5e3346d63dbde21265e71c611b9400395b5c372a8a882774f9e12780836dd270387dd22db0
6
+ metadata.gz: a0734b8c7980d0372dabfafda11476204d951e21e129cc16a7d851bc660f6f8b65a181274235794c8da089e903bf356a17bceda1d9b87268bdf2e5225043a4e9
7
+ data.tar.gz: e5c80957ea4a1c137a3d6d685cce658b26a86db1df8ee4a5abd0f580e71cf33fc684dc17976bfcbb2ccde67c135c98d04190dce958e1ab0e376497177f777c39
data/Rakefile CHANGED
@@ -1,20 +1,20 @@
1
- require "rake/clean"
2
- require "rake/extensiontask"
3
- require "rubygems/package_task"
1
+ require 'rake/clean'
2
+ require 'rake/extensiontask'
3
+ require 'rubygems/package_task'
4
4
 
5
- CLEAN << "pkg" << "tmp" << "lib/unicode"
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("../unicode.gemspec", __FILE__)))
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 = "ext/unicode"
17
- ext.lib_dir = "lib/unicode"
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 "Build native gems for Windows"
55
+ desc 'Build native gems for Windows'
70
56
  task :windows do
71
- ENV["RUBY_CC_VERSION"] = "1.8.7:1.9.3"
72
- sh "rake cross compile"
73
- sh "rake cross native gem"
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 "Update from upstream"
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
- module Unicode
1
+ module Unicode
2
2
 
3
- extend self
3
+ extend self
4
4
 
5
- def upcase(str)
6
- str.to_java.to_upper_case
7
- end
5
+ VERSION = '0.4.3'
8
6
 
9
- def downcase(str)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{unicode}
5
- s.version = "0.4.4.1"
5
+ s.version = "0.4.4.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Yoshida Masato}]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4.1
4
+ version: 0.4.4.2
5
5
  platform: java
6
6
  authors:
7
7
  - Yoshida Masato