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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a6ca72b1d524ee95cac063e6adeb11f17c84286
4
- data.tar.gz: 1a4377b04582ffe478ce15fac05b04da1af366bc
3
+ metadata.gz: 717002d088d243c10448dfd361c2efbe28ca92ec
4
+ data.tar.gz: 31ef0fd850f89262359a7fc16505c37a05db4daa
5
5
  SHA512:
6
- metadata.gz: f873875d9f24fbd46bec423dfe44420a0d0ec41221ca90365922dbddd436875039cfdd6cac989f6b05e746d539a7c10207671633dcc0e6fb05650b77f5343cd9
7
- data.tar.gz: c4ca7e4b294810e818dcbee0031da1e066d401a01506b32f0765fc98b939f58c61c24991c57bf513f5b02785ddb2d2f8cbe7e46d238daf0888cab8033f10c0cd
6
+ metadata.gz: 23b38ba78e528c0ee36a235b03adf1be34f189cc47377f5e7aa6778ea805d9061966118f31ab04ca3dfa7a623697012dce9fb997c18c73c1e2c9b82d07beeab5
7
+ data.tar.gz: 8f8646b6300e3f675bd4846c8790a1377afc87212d2153df6f8dc4e0de8918692a8f5b1e0e3abb3f22ce91d5d76f2340e017f2915033b83688194e8e5f25b954
@@ -1,3 +1,10 @@
1
+ ## 0.1.3 (2013-10-25)
2
+
3
+ Features:
4
+
5
+ - Make UNF::Normalizer.instance thread-safe, and deprecate .new.
6
+ (GH #5)
7
+
1
8
  ## 0.1.2 (2013-08-12)
2
9
 
3
10
  Features:
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.new
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
@@ -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: new
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
- # :stopdoc:
19
- def instance
20
- @@normalizer ||= new
21
- end
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 new.normalize(string, form).
23
+ # A shortcut for instance.normalize(string, form).
25
24
  def normalize(string, form)
26
25
  instance.normalize(string, form)
27
26
  end
@@ -1,3 +1,3 @@
1
1
  module UNF
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -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.new
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.new
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.2
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-08-12 00:00:00.000000000 Z
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unf_ext