unf 0.1.2-jruby → 0.1.3-jruby

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c78741ad32acce3ea27215c8087333f9a0ef388e
4
- data.tar.gz: 24d78b56ba57f61d77f4ff5013e5037a47b95248
3
+ metadata.gz: a047bb26b86afc1831cf4e043e9fec4e1990f822
4
+ data.tar.gz: 6c8fae781ea7cddc673e4bb21286fb53d20ac4c5
5
5
  SHA512:
6
- metadata.gz: 688bdded541348e74f8fd93c97e9e64daa747563f5cbfb05d6a62e981bf949cf7b99f77d1f6726e6e1274f2b92fe3a38017748de187ca8849c60b61e2e91196e
7
- data.tar.gz: 0ea4f7993ae6aef03c281286ba457645bc11bc77763705cbfc0ffc5e245053f7b931915d341a223e59ddb6b177ac247bfe81b70ae36876568ddc89d71328ed68
6
+ metadata.gz: 5d09fd3236f2e7975ccac630d78a3d8de0a7b74d736a8ca9ced267f6e9b0d17870b1321d70baa49cbf417311cea36303d9125fc2e9154a3fbdef0ed4a198dfa2
7
+ data.tar.gz: 8b1b3faec7da32e54e67b2d7492b1803afd6abd10d325c5f20fbbd758db6899ef7a32644dd679756e30355e9f60240cdf08549bb62e5d8437fcfba1e8c2c2c09
data/CHANGELOG.md CHANGED
@@ -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 #6)
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
data/lib/unf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module UNF
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
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.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: jruby
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-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda