unf 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/unf.rb +13 -16
- data/lib/unf/normalizer.rb +17 -0
- data/lib/unf/normalizer_cruby.rb +1 -0
- data/lib/{unf_jruby.rb → unf/normalizer_jruby.rb} +0 -0
- data/unf.gemspec +5 -3
- metadata +7 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/unf.rb
CHANGED
@@ -1,26 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
else
|
4
|
-
require 'unf_ext'
|
1
|
+
module UNF
|
2
|
+
autoload :Normalizer, 'unf/normalizer'
|
5
3
|
end
|
6
4
|
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
class String
|
6
|
+
ascii_only =
|
7
|
+
if method_defined?(:ascii_only?)
|
8
|
+
'ascii_only?'
|
9
|
+
else
|
10
|
+
'/[^\x00-\x7f]/ !~ self'
|
11
11
|
end
|
12
12
|
|
13
|
-
def normalize(string, form)
|
14
|
-
instance.normalize(string, form)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class String
|
20
13
|
[:nfc, :nfd, :nfkc, :nfkd].each { |form|
|
21
14
|
eval %{
|
22
15
|
def to_#{form.to_s}
|
23
|
-
|
16
|
+
if #{ascii_only}
|
17
|
+
self
|
18
|
+
else
|
19
|
+
UNF::Normalizer.normalize(self, #{form.inspect})
|
20
|
+
end
|
24
21
|
end
|
25
22
|
}
|
26
23
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
2
|
+
require 'unf/normalizer_jruby'
|
3
|
+
else
|
4
|
+
require 'unf/normalizer_cruby'
|
5
|
+
end
|
6
|
+
|
7
|
+
class UNF::Normalizer
|
8
|
+
class << self
|
9
|
+
def instance
|
10
|
+
@@normalizer ||= new
|
11
|
+
end
|
12
|
+
|
13
|
+
def normalize(string, form)
|
14
|
+
instance.normalize(string, form)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'unf_ext'
|
File without changes
|
data/unf.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{unf}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Akinori MUSHA}]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-12-09}
|
13
13
|
s.description = %q{This is a wrapper library to bring Unicode Normalization Form support
|
14
14
|
to Ruby/JRuby.
|
15
15
|
}
|
@@ -26,7 +26,9 @@ to Ruby/JRuby.
|
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"lib/unf.rb",
|
29
|
-
"lib/
|
29
|
+
"lib/unf/normalizer.rb",
|
30
|
+
"lib/unf/normalizer_cruby.rb",
|
31
|
+
"lib/unf/normalizer_jruby.rb",
|
30
32
|
"test/helper.rb",
|
31
33
|
"test/normalization-test.txt",
|
32
34
|
"test/test_unf.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akinori MUSHA
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: unf_ext
|
@@ -111,7 +111,9 @@ files:
|
|
111
111
|
- Rakefile
|
112
112
|
- VERSION
|
113
113
|
- lib/unf.rb
|
114
|
-
- lib/
|
114
|
+
- lib/unf/normalizer.rb
|
115
|
+
- lib/unf/normalizer_cruby.rb
|
116
|
+
- lib/unf/normalizer_jruby.rb
|
115
117
|
- test/helper.rb
|
116
118
|
- test/normalization-test.txt
|
117
119
|
- test/test_unf.rb
|