unf 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/lib/unf/normalizer.rb +10 -11
- data/lib/unf/version.rb +1 -1
- data/test/test_unf.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 717002d088d243c10448dfd361c2efbe28ca92ec
|
4
|
+
data.tar.gz: 31ef0fd850f89262359a7fc16505c37a05db4daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23b38ba78e528c0ee36a235b03adf1be34f189cc47377f5e7aa6778ea805d9061966118f31ab04ca3dfa7a623697012dce9fb997c18c73c1e2c9b82d07beeab5
|
7
|
+
data.tar.gz: 8f8646b6300e3f675bd4846c8790a1377afc87212d2153df6f8dc4e0de8918692a8f5b1e0e3abb3f22ce91d5d76f2340e017f2915033b83688194e8e5f25b954
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -14,13 +14,13 @@ Description
|
|
14
14
|
* Normalizes UTF-8 strings into and from NFC, NFD, NFKC or NFKD
|
15
15
|
|
16
16
|
# For bulk conversion
|
17
|
-
normalizer = UNF::Normalizer.
|
17
|
+
normalizer = UNF::Normalizer.instance
|
18
18
|
a_bunch_of_strings.map! { |string|
|
19
19
|
normalizer.normalize(string, :nfc) #=> string in NFC
|
20
20
|
}
|
21
21
|
|
22
22
|
# Class method
|
23
|
-
UNF::Normalizer.normalize(string)
|
23
|
+
UNF::Normalizer.normalize(string, :nfc)
|
24
24
|
|
25
25
|
# Instance methods of String
|
26
26
|
string.to_nfc
|
data/lib/unf/normalizer.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'singleton'
|
1
2
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
2
3
|
require 'unf/normalizer_jruby'
|
3
4
|
else
|
@@ -7,21 +8,19 @@ end
|
|
7
8
|
# UTF-8 string normalizer class. Implementations may vary depending
|
8
9
|
# on the platform.
|
9
10
|
class UNF::Normalizer
|
11
|
+
include Singleton
|
12
|
+
|
10
13
|
class << self
|
11
|
-
# :singleton-method:
|
12
|
-
# :call-seq:
|
13
|
-
# new
|
14
|
-
# instance
|
14
|
+
# :singleton-method: instance
|
15
15
|
#
|
16
|
-
# Returns a normalizer instance.
|
16
|
+
# Returns a singleton normalizer instance.
|
17
17
|
|
18
|
-
# :
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# :startdoc:
|
18
|
+
# :singleton-method: new
|
19
|
+
#
|
20
|
+
# Returns a new normalizer instance. Use +singleton+ instead.
|
21
|
+
public :new
|
23
22
|
|
24
|
-
# A shortcut for
|
23
|
+
# A shortcut for instance.normalize(string, form).
|
25
24
|
def normalize(string, form)
|
26
25
|
instance.normalize(string, form)
|
27
26
|
end
|
data/lib/unf/version.rb
CHANGED
data/test/test_unf.rb
CHANGED
@@ -4,12 +4,12 @@ require 'pathname'
|
|
4
4
|
|
5
5
|
class TestUNF < Test::Unit::TestCase
|
6
6
|
should "raise ArgumentError if an unknown normalization form is given" do
|
7
|
-
normalizer = UNF::Normalizer.
|
7
|
+
normalizer = UNF::Normalizer.instance
|
8
8
|
assert_raises(ArgumentError) { normalizer.normalize("が", :nfck) }
|
9
9
|
end
|
10
10
|
|
11
11
|
should "pass all tests bundled with the original unf" do
|
12
|
-
normalizer = UNF::Normalizer.
|
12
|
+
normalizer = UNF::Normalizer.instance
|
13
13
|
open(Pathname(__FILE__).dirname + 'normalization-test.txt', 'r:utf-8').each_slice(6) { |lines|
|
14
14
|
flunk "broken test file" if lines.size != 6 || lines.pop !~ /^$/
|
15
15
|
str, nfd, nfc, nfkd, nfkc = lines
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unf_ext
|