unf 0.1.2-jruby → 0.1.3-jruby
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: a047bb26b86afc1831cf4e043e9fec4e1990f822
|
4
|
+
data.tar.gz: 6c8fae781ea7cddc673e4bb21286fb53d20ac4c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d09fd3236f2e7975ccac630d78a3d8de0a7b74d736a8ca9ced267f6e9b0d17870b1321d70baa49cbf417311cea36303d9125fc2e9154a3fbdef0ed4a198dfa2
|
7
|
+
data.tar.gz: 8b1b3faec7da32e54e67b2d7492b1803afd6abd10d325c5f20fbbd758db6899ef7a32644dd679756e30355e9f60240cdf08549bb62e5d8437fcfba1e8c2c2c09
|
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: jruby
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|