ffi-icu 0.1.7 → 0.3.0
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 +5 -5
 - data/.rspec +2 -0
 - data/.travis.yml +10 -4
 - data/README.md +9 -11
 - data/ffi-icu.gemspec +4 -4
 - data/lib/ffi-icu.rb +1 -10
 - data/lib/ffi-icu/lib.rb +20 -6
 - data/lib/ffi-icu/locale.rb +4 -4
 - data/lib/ffi-icu/normalizer.rb +47 -0
 - data/lib/ffi-icu/time_formatting.rb +1 -0
 - data/lib/ffi-icu/version.rb +1 -1
 - data/spec/break_iterator_spec.rb +20 -19
 - data/spec/chardet_spec.rb +10 -12
 - data/spec/collation_spec.rb +19 -22
 - data/spec/lib/version_info_spec.rb +11 -6
 - data/spec/lib_spec.rb +11 -11
 - data/spec/locale_spec.rb +105 -80
 - data/spec/normalization_spec.rb +2 -4
 - data/spec/normalizer_spec.rb +57 -0
 - data/spec/number_formatting_spec.rb +28 -25
 - data/spec/time_spec.rb +34 -37
 - data/spec/transliteration_spec.rb +5 -6
 - data/spec/uchar_spec.rb +8 -10
 - metadata +18 -16
 - data/spec/spec.opts +0 -1
 
| 
         @@ -1,68 +1,71 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: UTF-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
3 
     | 
    
         
             
            module ICU
         
     | 
| 
       6 
4 
     | 
    
         
             
              module NumberFormatting
         
     | 
| 
       7 
5 
     | 
    
         
             
                describe 'NumberFormatting' do
         
     | 
| 
       8 
6 
     | 
    
         
             
                  it 'should format a simple integer' do
         
     | 
| 
       9 
     | 
    
         
            -
                    NumberFormatting.format_number("en", 1). 
     | 
| 
       10 
     | 
    
         
            -
                    NumberFormatting.format_number("en", 1_000). 
     | 
| 
       11 
     | 
    
         
            -
                    NumberFormatting.format_number("de-DE", 1_000_000). 
     | 
| 
      
 7 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", 1)).to eq("1")
         
     | 
| 
      
 8 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", 1_000)).to eq("1,000")
         
     | 
| 
      
 9 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("de-DE", 1_000_000)).to eq("1.000.000")
         
     | 
| 
       12 
10 
     | 
    
         
             
                  end
         
     | 
| 
       13 
11 
     | 
    
         | 
| 
       14 
12 
     | 
    
         
             
                  it 'should format a float' do
         
     | 
| 
       15 
     | 
    
         
            -
                    NumberFormatting.format_number("en", 1.0). 
     | 
| 
       16 
     | 
    
         
            -
                    NumberFormatting.format_number("en", 1.123). 
     | 
| 
       17 
     | 
    
         
            -
                    NumberFormatting.format_number("en", 1_000.1238). 
     | 
| 
       18 
     | 
    
         
            -
                    NumberFormatting.format_number("en", 1_000.1238, max_fraction_digits: 4). 
     | 
| 
      
 13 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", 1.0)).to eq("1")
         
     | 
| 
      
 14 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", 1.123)).to eq("1.123")
         
     | 
| 
      
 15 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", 1_000.1238)).to eq("1,000.124")
         
     | 
| 
      
 16 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", 1_000.1238, max_fraction_digits: 4)).to eq("1,000.1238")
         
     | 
| 
       19 
17 
     | 
    
         
             
                    NumberFormatting.set_default_options(fraction_digits: 5)
         
     | 
| 
       20 
     | 
    
         
            -
                    NumberFormatting.format_number("en", 1_000.1238). 
     | 
| 
      
 18 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", 1_000.1238)).to eq("1,000.12380")
         
     | 
| 
       21 
19 
     | 
    
         
             
                    NumberFormatting.clear_default_options
         
     | 
| 
       22 
20 
     | 
    
         
             
                  end
         
     | 
| 
       23 
21 
     | 
    
         | 
| 
       24 
22 
     | 
    
         
             
                  it 'should format a decimal' do
         
     | 
| 
       25 
     | 
    
         
            -
                    NumberFormatting.format_number("en", BigDecimal 
     | 
| 
      
 23 
     | 
    
         
            +
                    expect(NumberFormatting.format_number("en", BigDecimal("10000.123"))).to eq("10,000.123")
         
     | 
| 
       26 
24 
     | 
    
         
             
                  end
         
     | 
| 
       27 
25 
     | 
    
         | 
| 
       28 
26 
     | 
    
         
             
                  it 'should format a currency' do
         
     | 
| 
       29 
     | 
    
         
            -
                    NumberFormatting.format_currency("en", 123.45, 'USD'). 
     | 
| 
       30 
     | 
    
         
            -
                    NumberFormatting.format_currency("en", 123_123.45, 'USD'). 
     | 
| 
       31 
     | 
    
         
            -
                    NumberFormatting.format_currency("de-DE", 123_123.45, 'EUR'). 
     | 
| 
      
 27 
     | 
    
         
            +
                    expect(NumberFormatting.format_currency("en", 123.45, 'USD')).to eq("$123.45")
         
     | 
| 
      
 28 
     | 
    
         
            +
                    expect(NumberFormatting.format_currency("en", 123_123.45, 'USD')).to eq("$123,123.45")
         
     | 
| 
      
 29 
     | 
    
         
            +
                    expect(NumberFormatting.format_currency("de-DE", 123_123.45, 'EUR')).to eq("123.123,45\u{A0}€")
         
     | 
| 
       32 
30 
     | 
    
         
             
                  end
         
     | 
| 
       33 
31 
     | 
    
         | 
| 
       34 
32 
     | 
    
         
             
                  it 'should format a percent' do
         
     | 
| 
       35 
     | 
    
         
            -
                    NumberFormatting.format_percent("en", 1.1). 
     | 
| 
       36 
     | 
    
         
            -
                    NumberFormatting.format_percent("da", 0.15). 
     | 
| 
       37 
     | 
    
         
            -
                    NumberFormatting.format_percent("da", -0.1545, max_fraction_digits: 10). 
     | 
| 
      
 33 
     | 
    
         
            +
                    expect(NumberFormatting.format_percent("en", 1.1)).to eq("110%")
         
     | 
| 
      
 34 
     | 
    
         
            +
                    expect(NumberFormatting.format_percent("da", 0.15)).to eq("15\u{A0}%")
         
     | 
| 
      
 35 
     | 
    
         
            +
                    expect(NumberFormatting.format_percent("da", -0.1545, max_fraction_digits: 10)).to eq("-15,45\u{A0}%")
         
     | 
| 
       38 
36 
     | 
    
         
             
                  end
         
     | 
| 
       39 
37 
     | 
    
         | 
| 
       40 
38 
     | 
    
         
             
                  it 'should spell numbers' do
         
     | 
| 
       41 
     | 
    
         
            -
                    NumberFormatting.spell("en_US", 1_000). 
     | 
| 
       42 
     | 
    
         
            -
                    NumberFormatting.spell("de-DE", 123.456). 
     | 
| 
      
 39 
     | 
    
         
            +
                    expect(NumberFormatting.spell("en_US", 1_000)).to eq('one thousand')
         
     | 
| 
      
 40 
     | 
    
         
            +
                    expect(NumberFormatting.spell("de-DE", 123.456)).to eq("ein\u{AD}hundert\u{AD}drei\u{AD}und\u{AD}zwanzig Komma vier fünf sechs")
         
     | 
| 
       43 
41 
     | 
    
         
             
                  end
         
     | 
| 
       44 
42 
     | 
    
         | 
| 
       45 
43 
     | 
    
         
             
                  it 'should be able to re-use number formatter objects' do
         
     | 
| 
       46 
44 
     | 
    
         
             
                    numf = NumberFormatting.create('fr-CA')
         
     | 
| 
       47 
     | 
    
         
            -
                    numf.format(1_000). 
     | 
| 
       48 
     | 
    
         
            -
                    numf.format(1_000.123). 
     | 
| 
      
 45 
     | 
    
         
            +
                    expect(numf.format(1_000)).to eq("1\u{A0}000")
         
     | 
| 
      
 46 
     | 
    
         
            +
                    expect(numf.format(1_000.123)).to eq("1\u{A0}000,123")
         
     | 
| 
       49 
47 
     | 
    
         
             
                  end
         
     | 
| 
       50 
48 
     | 
    
         | 
| 
       51 
49 
     | 
    
         
             
                  it 'should be able to re-use currency formatter objects' do
         
     | 
| 
       52 
50 
     | 
    
         
             
                    curf = NumberFormatting.create('en-US', :currency)
         
     | 
| 
       53 
     | 
    
         
            -
                    curf.format(1_000.12, 'USD'). 
     | 
| 
      
 51 
     | 
    
         
            +
                    expect(curf.format(1_000.12, 'USD')).to eq("$1,000.12")
         
     | 
| 
       54 
52 
     | 
    
         
             
                  end
         
     | 
| 
       55 
53 
     | 
    
         | 
| 
       56 
54 
     | 
    
         
             
                  it 'should allow for various styles of currency formatting if the version is new enough' do
         
     | 
| 
       57 
55 
     | 
    
         
             
                    if ICU::Lib.version.to_a.first >= 53
         
     | 
| 
       58 
56 
     | 
    
         
             
                      curf = NumberFormatting.create('en-US', :currency, style: :iso)
         
     | 
| 
       59 
     | 
    
         
            -
                       
     | 
| 
      
 57 
     | 
    
         
            +
                      expected = if ICU::Lib.version.to_a.first >= 62
         
     | 
| 
      
 58 
     | 
    
         
            +
                        "USD\u00A01,000.12"
         
     | 
| 
      
 59 
     | 
    
         
            +
                      else
         
     | 
| 
      
 60 
     | 
    
         
            +
                        "USD1,000.12"
         
     | 
| 
      
 61 
     | 
    
         
            +
                      end
         
     | 
| 
      
 62 
     | 
    
         
            +
                      expect(curf.format(1_000.12, 'USD')).to eq(expected)
         
     | 
| 
       60 
63 
     | 
    
         
             
                      curf = NumberFormatting.create('en-US', :currency, style: :plural)
         
     | 
| 
       61 
     | 
    
         
            -
                      curf.format(1_000.12, 'USD'). 
     | 
| 
      
 64 
     | 
    
         
            +
                      expect(curf.format(1_000.12, 'USD')).to eq("1,000.12 US dollars")
         
     | 
| 
       62 
65 
     | 
    
         
             
                      expect { NumberFormatting.create('en-US', :currency, style: :fake) }.to raise_error(StandardError)
         
     | 
| 
       63 
66 
     | 
    
         
             
                    else
         
     | 
| 
       64 
67 
     | 
    
         
             
                      curf = NumberFormatting.create('en-US', :currency, style: :default)
         
     | 
| 
       65 
     | 
    
         
            -
                      curf.format(1_000.12, 'USD'). 
     | 
| 
      
 68 
     | 
    
         
            +
                      expect(curf.format(1_000.12, 'USD')).to eq('$1,000.12')
         
     | 
| 
       66 
69 
     | 
    
         
             
                      expect { NumberFormatting.create('en-US', :currency, style: :iso) }.to raise_error(StandardError)
         
     | 
| 
       67 
70 
     | 
    
         
             
                    end
         
     | 
| 
       68 
71 
     | 
    
         
             
                  end
         
     | 
    
        data/spec/time_spec.rb
    CHANGED
    
    | 
         @@ -1,7 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: UTF-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
3 
     | 
    
         
             
            module ICU
         
     | 
| 
       6 
4 
     | 
    
         
             
              describe TimeFormatting do
         
     | 
| 
       7 
5 
     | 
    
         
             
                describe 'the TimeFormatting ' do
         
     | 
| 
         @@ -17,21 +15,21 @@ module ICU 
     | 
|
| 
       17 
15 
     | 
    
         | 
| 
       18 
16 
     | 
    
         
             
                  f1 = TimeFormatting.create(:locale => 'cs_CZ', :zone => 'Europe/Prague', :date => :long , :time => :long, :tz_style => :localized_long)
         
     | 
| 
       19 
17 
     | 
    
         
             
                  it 'check date_format for lang=cs_CZ' do
         
     | 
| 
       20 
     | 
    
         
            -
                    f1.date_format(true). 
     | 
| 
       21 
     | 
    
         
            -
                    f1.date_format(false). 
     | 
| 
      
 18 
     | 
    
         
            +
                    expect(f1.date_format(true)).to eq("d. MMMM y H:mm:ss ZZZZ")
         
     | 
| 
      
 19 
     | 
    
         
            +
                    expect(f1.date_format(false)).to eq("d. MMMM y H:mm:ss ZZZZ")
         
     | 
| 
       22 
20 
     | 
    
         
             
                  end
         
     | 
| 
       23 
21 
     | 
    
         | 
| 
       24 
22 
     | 
    
         
             
                  it "for lang=cs_CZ zone=Europe/Prague" do
         
     | 
| 
       25 
     | 
    
         
            -
                    f1. 
     | 
| 
       26 
     | 
    
         
            -
                    f1.format(t0). 
     | 
| 
       27 
     | 
    
         
            -
                    f1.format(t1). 
     | 
| 
       28 
     | 
    
         
            -
                    f1.format(t2). 
     | 
| 
       29 
     | 
    
         
            -
                    f1.format(t3). 
     | 
| 
       30 
     | 
    
         
            -
                    f1.format(t4). 
     | 
| 
       31 
     | 
    
         
            -
                    f1.format(t5). 
     | 
| 
       32 
     | 
    
         
            -
                    f1.format(t6). 
     | 
| 
       33 
     | 
    
         
            -
                    f1.format(t7). 
     | 
| 
       34 
     | 
    
         
            -
                    f1.format(t8). 
     | 
| 
      
 23 
     | 
    
         
            +
                    expect(f1).to be_an_instance_of TimeFormatting::DateTimeFormatter
         
     | 
| 
      
 24 
     | 
    
         
            +
                    expect(f1.format(t0)).to eq("12. listopadu 2008 15:21:16 GMT+01:00")
         
     | 
| 
      
 25 
     | 
    
         
            +
                    expect(f1.format(t1)).to eq("25. října 2008 1:15:17 GMT+02:00")
         
     | 
| 
      
 26 
     | 
    
         
            +
                    expect(f1.format(t2)).to eq("25. října 2008 2:16:18 GMT+02:00")
         
     | 
| 
      
 27 
     | 
    
         
            +
                    expect(f1.format(t3)).to eq("25. října 2008 3:17:19 GMT+02:00")
         
     | 
| 
      
 28 
     | 
    
         
            +
                    expect(f1.format(t4)).to eq("25. října 2008 4:18:20 GMT+02:00")
         
     | 
| 
      
 29 
     | 
    
         
            +
                    expect(f1.format(t5)).to eq("29. března 2008 1:35:21 GMT+01:00")
         
     | 
| 
      
 30 
     | 
    
         
            +
                    expect(f1.format(t6)).to eq("29. března 2008 2:36:22 GMT+01:00")
         
     | 
| 
      
 31 
     | 
    
         
            +
                    expect(f1.format(t7)).to eq("29. března 2008 3:37:23 GMT+01:00")
         
     | 
| 
      
 32 
     | 
    
         
            +
                    expect(f1.format(t8)).to eq("29. března 2008 4:38:24 GMT+01:00")
         
     | 
| 
       35 
33 
     | 
    
         
             
                  end
         
     | 
| 
       36 
34 
     | 
    
         | 
| 
       37 
35 
     | 
    
         
             
                  f2 = TimeFormatting.create(:locale => 'en_US', :zone => 'Europe/Moscow', :date => :short , :time => :long, :tz_style => :generic_location)
         
     | 
| 
         @@ -45,20 +43,20 @@ module ICU 
     | 
|
| 
       45 
43 
     | 
    
         | 
| 
       46 
44 
     | 
    
         
             
                  en_exp = "M/d/yy#{en_sep} h:mm:ss a VVVV"
         
     | 
| 
       47 
45 
     | 
    
         
             
                  it 'check date_format for lang=en_US' do
         
     | 
| 
       48 
     | 
    
         
            -
                    f2.date_format(true). 
     | 
| 
       49 
     | 
    
         
            -
                    f2.date_format(false). 
     | 
| 
      
 46 
     | 
    
         
            +
                    expect(f2.date_format(true)).to eq(en_exp)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    expect(f2.date_format(false)).to eq(en_exp)
         
     | 
| 
       50 
48 
     | 
    
         
             
                  end
         
     | 
| 
       51 
49 
     | 
    
         | 
| 
       52 
50 
     | 
    
         
             
                  it "lang=en_US zone=Europe/Moscow" do
         
     | 
| 
       53 
     | 
    
         
            -
                    f2.format(t0). 
     | 
| 
       54 
     | 
    
         
            -
                    f2.format(t1). 
     | 
| 
       55 
     | 
    
         
            -
                    f2.format(t2). 
     | 
| 
       56 
     | 
    
         
            -
                    f2.format(t3). 
     | 
| 
       57 
     | 
    
         
            -
                    f2.format(t4). 
     | 
| 
       58 
     | 
    
         
            -
                    f2.format(t5). 
     | 
| 
       59 
     | 
    
         
            -
                    f2.format(t6). 
     | 
| 
       60 
     | 
    
         
            -
                    f2.format(t7). 
     | 
| 
       61 
     | 
    
         
            -
                    f2.format(t8). 
     | 
| 
      
 51 
     | 
    
         
            +
                    expect(f2.format(t0)).to eq("11/12/08#{en_sep} 5:21:16 PM #{en_tz}")
         
     | 
| 
      
 52 
     | 
    
         
            +
                    expect(f2.format(t1)).to eq("10/25/08#{en_sep} 3:15:17 AM #{en_tz}")
         
     | 
| 
      
 53 
     | 
    
         
            +
                    expect(f2.format(t2)).to eq("10/25/08#{en_sep} 4:16:18 AM #{en_tz}")
         
     | 
| 
      
 54 
     | 
    
         
            +
                    expect(f2.format(t3)).to eq("10/25/08#{en_sep} 5:17:19 AM #{en_tz}")
         
     | 
| 
      
 55 
     | 
    
         
            +
                    expect(f2.format(t4)).to eq("10/25/08#{en_sep} 6:18:20 AM #{en_tz}")
         
     | 
| 
      
 56 
     | 
    
         
            +
                    expect(f2.format(t5)).to eq("3/29/08#{en_sep} 3:35:21 AM #{en_tz}")
         
     | 
| 
      
 57 
     | 
    
         
            +
                    expect(f2.format(t6)).to eq("3/29/08#{en_sep} 4:36:22 AM #{en_tz}")
         
     | 
| 
      
 58 
     | 
    
         
            +
                    expect(f2.format(t7)).to eq("3/29/08#{en_sep} 5:37:23 AM #{en_tz}")
         
     | 
| 
      
 59 
     | 
    
         
            +
                    expect(f2.format(t8)).to eq("3/29/08#{en_sep} 6:38:24 AM #{en_tz}")
         
     | 
| 
       62 
60 
     | 
    
         
             
                  end
         
     | 
| 
       63 
61 
     | 
    
         | 
| 
       64 
62 
     | 
    
         
             
                  f3 = TimeFormatting.create(:locale => 'de_DE', :zone => 'Africa/Dakar ', :date => :short , :time => :long)
         
     | 
| 
         @@ -69,22 +67,21 @@ module ICU 
     | 
|
| 
       69 
67 
     | 
    
         | 
| 
       70 
68 
     | 
    
         
             
                  ge_exp = "dd.MM.yy#{ge_sep} HH:mm:ss z"
         
     | 
| 
       71 
69 
     | 
    
         
             
                  it 'check date_format for lang=de_DE' do
         
     | 
| 
       72 
     | 
    
         
            -
                    f3.date_format(true). 
     | 
| 
       73 
     | 
    
         
            -
                    f3.date_format(false). 
     | 
| 
      
 70 
     | 
    
         
            +
                    expect(f3.date_format(true)).to eq(ge_exp)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    expect(f3.date_format(false)).to eq(ge_exp)
         
     | 
| 
       74 
72 
     | 
    
         
             
                  end
         
     | 
| 
       75 
73 
     | 
    
         | 
| 
       76 
74 
     | 
    
         
             
                  it "lang=de_DE zone=Africa/Dakar" do
         
     | 
| 
       77 
     | 
    
         
            -
                    f3.format(t0). 
     | 
| 
       78 
     | 
    
         
            -
                    f3.format(t1). 
     | 
| 
       79 
     | 
    
         
            -
                    f3.format(t2). 
     | 
| 
       80 
     | 
    
         
            -
                    f3.format(t3). 
     | 
| 
       81 
     | 
    
         
            -
                    f3.format(t4). 
     | 
| 
       82 
     | 
    
         
            -
                    f3.format(t5). 
     | 
| 
       83 
     | 
    
         
            -
                    f3.format(t6). 
     | 
| 
       84 
     | 
    
         
            -
                    f3.format(t7). 
     | 
| 
       85 
     | 
    
         
            -
                    f3.format(t8). 
     | 
| 
      
 75 
     | 
    
         
            +
                    expect(f3.format(t0)).to eq("12.11.08#{ge_sep} 14:21:16 GMT")
         
     | 
| 
      
 76 
     | 
    
         
            +
                    expect(f3.format(t1)).to eq("24.10.08#{ge_sep} 23:15:17 GMT")
         
     | 
| 
      
 77 
     | 
    
         
            +
                    expect(f3.format(t2)).to eq("25.10.08#{ge_sep} 00:16:18 GMT")
         
     | 
| 
      
 78 
     | 
    
         
            +
                    expect(f3.format(t3)).to eq("25.10.08#{ge_sep} 01:17:19 GMT")
         
     | 
| 
      
 79 
     | 
    
         
            +
                    expect(f3.format(t4)).to eq("25.10.08#{ge_sep} 02:18:20 GMT")
         
     | 
| 
      
 80 
     | 
    
         
            +
                    expect(f3.format(t5)).to eq("29.03.08#{ge_sep} 00:35:21 GMT")
         
     | 
| 
      
 81 
     | 
    
         
            +
                    expect(f3.format(t6)).to eq("29.03.08#{ge_sep} 01:36:22 GMT")
         
     | 
| 
      
 82 
     | 
    
         
            +
                    expect(f3.format(t7)).to eq("29.03.08#{ge_sep} 02:37:23 GMT")
         
     | 
| 
      
 83 
     | 
    
         
            +
                    expect(f3.format(t8)).to eq("29.03.08#{ge_sep} 03:38:24 GMT")
         
     | 
| 
       86 
84 
     | 
    
         
             
                  end
         
     | 
| 
       87 
85 
     | 
    
         
             
                end
         
     | 
| 
       88 
86 
     | 
    
         
             
              end
         
     | 
| 
       89 
87 
     | 
    
         
             
            end
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
         @@ -1,7 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require "spec_helper"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
3 
     | 
    
         
             
            module ICU
         
     | 
| 
       6 
4 
     | 
    
         
             
              describe Transliteration::Transliterator do
         
     | 
| 
       7 
5 
     | 
    
         
             
                def transliterator_for(*args)
         
     | 
| 
         @@ -16,7 +14,7 @@ module ICU 
     | 
|
| 
       16 
14 
     | 
    
         
             
                ].each do |id, input, output|
         
     | 
| 
       17 
15 
     | 
    
         
             
                  it "should transliterate #{id}" do
         
     | 
| 
       18 
16 
     | 
    
         
             
                    tl = transliterator_for(id)
         
     | 
| 
       19 
     | 
    
         
            -
                    tl.transliterate(input). 
     | 
| 
      
 17 
     | 
    
         
            +
                    expect(tl.transliterate(input)).to eq(output)
         
     | 
| 
       20 
18 
     | 
    
         
             
                  end
         
     | 
| 
       21 
19 
     | 
    
         | 
| 
       22 
20 
     | 
    
         
             
                end
         
     | 
| 
         @@ -25,12 +23,13 @@ module ICU 
     | 
|
| 
       25 
23 
     | 
    
         
             
              describe Transliteration do
         
     | 
| 
       26 
24 
     | 
    
         
             
                it "should provide a list of available ids" do
         
     | 
| 
       27 
25 
     | 
    
         
             
                  ids = ICU::Transliteration.available_ids
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                  ids. 
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  expect(ids).to be_an(Array)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  expect(ids).to_not be_empty
         
     | 
| 
       30 
29 
     | 
    
         
             
                end
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
31 
     | 
    
         
             
               it "should transliterate custom rules" do
         
     | 
| 
       33 
     | 
    
         
            -
                 ICU::Transliteration.translit("NFD; [:Nonspacing Mark:] Remove; NFC", "âêîôû"). 
     | 
| 
      
 32 
     | 
    
         
            +
                 expect(ICU::Transliteration.translit("NFD; [:Nonspacing Mark:] Remove; NFC", "âêîôû")).to eq("aeiou")
         
     | 
| 
       34 
33 
     | 
    
         
             
               end
         
     | 
| 
       35 
34 
     | 
    
         | 
| 
       36 
35 
     | 
    
         
             
              end # Transliteration
         
     | 
    
        data/spec/uchar_spec.rb
    CHANGED
    
    | 
         @@ -1,35 +1,33 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: UTF-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
3 
     | 
    
         
             
            module ICU
         
     | 
| 
       6 
4 
     | 
    
         
             
              describe UCharPointer do
         
     | 
| 
       7 
5 
     | 
    
         
             
                it 'allocates enough memory for 16-bit characters' do
         
     | 
| 
       8 
     | 
    
         
            -
                  UCharPointer.new(5).size. 
     | 
| 
      
 6 
     | 
    
         
            +
                  expect(UCharPointer.new(5).size).to eq(10)
         
     | 
| 
       9 
7 
     | 
    
         
             
                end
         
     | 
| 
       10 
8 
     | 
    
         | 
| 
       11 
9 
     | 
    
         
             
                it 'builds a buffer from a string' do
         
     | 
| 
       12 
10 
     | 
    
         
             
                  ptr = UCharPointer.from_string('abc')
         
     | 
| 
       13 
     | 
    
         
            -
                  ptr. 
     | 
| 
       14 
     | 
    
         
            -
                  ptr.size. 
     | 
| 
       15 
     | 
    
         
            -
                  ptr.read_array_of_uint16(3). 
     | 
| 
      
 11 
     | 
    
         
            +
                  expect(ptr).to be_a UCharPointer
         
     | 
| 
      
 12 
     | 
    
         
            +
                  expect(ptr.size).to eq(6)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  expect(ptr.read_array_of_uint16(3)).to eq([0x61, 0x62, 0x63])
         
     | 
| 
       16 
14 
     | 
    
         
             
                end
         
     | 
| 
       17 
15 
     | 
    
         | 
| 
       18 
16 
     | 
    
         
             
                it 'takes an optional capacity' do
         
     | 
| 
       19 
17 
     | 
    
         
             
                  ptr = UCharPointer.from_string('abc', 5)
         
     | 
| 
       20 
     | 
    
         
            -
                  ptr.size. 
     | 
| 
      
 18 
     | 
    
         
            +
                  expect(ptr.size).to eq(10)
         
     | 
| 
       21 
19 
     | 
    
         
             
                end
         
     | 
| 
       22 
20 
     | 
    
         | 
| 
       23 
21 
     | 
    
         
             
                describe 'converting to string' do
         
     | 
| 
       24 
22 
     | 
    
         
             
                  let(:ptr) { UCharPointer.new(3).write_array_of_uint16 [0x78, 0x0, 0x79] }
         
     | 
| 
       25 
23 
     | 
    
         | 
| 
       26 
24 
     | 
    
         
             
                  it 'returns the the entire buffer by default' do
         
     | 
| 
       27 
     | 
    
         
            -
                    ptr.string. 
     | 
| 
      
 25 
     | 
    
         
            +
                    expect(ptr.string).to eq("x\0y")
         
     | 
| 
       28 
26 
     | 
    
         
             
                  end
         
     | 
| 
       29 
27 
     | 
    
         | 
| 
       30 
28 
     | 
    
         
             
                  it 'returns strings of the specified length' do
         
     | 
| 
       31 
     | 
    
         
            -
                    ptr.string(0). 
     | 
| 
       32 
     | 
    
         
            -
                    ptr.string(2). 
     | 
| 
      
 29 
     | 
    
         
            +
                    expect(ptr.string(0)).to eq("")
         
     | 
| 
      
 30 
     | 
    
         
            +
                    expect(ptr.string(2)).to eq("x\0")
         
     | 
| 
       33 
31 
     | 
    
         
             
                  end
         
     | 
| 
       34 
32 
     | 
    
         
             
                end
         
     | 
| 
       35 
33 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ffi-icu
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jari Bakken
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-10-15 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: ffi
         
     | 
| 
         @@ -36,28 +36,28 @@ dependencies: 
     | 
|
| 
       36 
36 
     | 
    
         
             
                requirements:
         
     | 
| 
       37 
37 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       38 
38 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       39 
     | 
    
         
            -
                    version:  
     | 
| 
      
 39 
     | 
    
         
            +
                    version: '3.9'
         
     | 
| 
       40 
40 
     | 
    
         
             
              type: :development
         
     | 
| 
       41 
41 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       42 
42 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       43 
43 
     | 
    
         
             
                requirements:
         
     | 
| 
       44 
44 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       45 
45 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       46 
     | 
    
         
            -
                    version:  
     | 
| 
      
 46 
     | 
    
         
            +
                    version: '3.9'
         
     | 
| 
       47 
47 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       48 
48 
     | 
    
         
             
              name: rake
         
     | 
| 
       49 
49 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       50 
50 
     | 
    
         
             
                requirements:
         
     | 
| 
       51 
     | 
    
         
            -
                - - " 
     | 
| 
      
 51 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       52 
52 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       53 
     | 
    
         
            -
                    version:  
     | 
| 
      
 53 
     | 
    
         
            +
                    version: 12.3.3
         
     | 
| 
       54 
54 
     | 
    
         
             
              type: :development
         
     | 
| 
       55 
55 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       56 
56 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       57 
57 
     | 
    
         
             
                requirements:
         
     | 
| 
       58 
     | 
    
         
            -
                - - " 
     | 
| 
      
 58 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       59 
59 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       60 
     | 
    
         
            -
                    version:  
     | 
| 
      
 60 
     | 
    
         
            +
                    version: 12.3.3
         
     | 
| 
       61 
61 
     | 
    
         
             
            description: Provides charset detection, locale sensitive collation and more. Depends
         
     | 
| 
       62 
62 
     | 
    
         
             
              on libicu.
         
     | 
| 
       63 
63 
     | 
    
         
             
            email: jari.bakken@gmail.com
         
     | 
| 
         @@ -69,6 +69,7 @@ extra_rdoc_files: 
     | 
|
| 
       69 
69 
     | 
    
         
             
            files:
         
     | 
| 
       70 
70 
     | 
    
         
             
            - ".document"
         
     | 
| 
       71 
71 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
      
 72 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
       72 
73 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       73 
74 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       74 
75 
     | 
    
         
             
            - LICENSE
         
     | 
| 
         @@ -86,6 +87,7 @@ files: 
     | 
|
| 
       86 
87 
     | 
    
         
             
            - lib/ffi-icu/lib/util.rb
         
     | 
| 
       87 
88 
     | 
    
         
             
            - lib/ffi-icu/locale.rb
         
     | 
| 
       88 
89 
     | 
    
         
             
            - lib/ffi-icu/normalization.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - lib/ffi-icu/normalizer.rb
         
     | 
| 
       89 
91 
     | 
    
         
             
            - lib/ffi-icu/number_formatting.rb
         
     | 
| 
       90 
92 
     | 
    
         
             
            - lib/ffi-icu/time_formatting.rb
         
     | 
| 
       91 
93 
     | 
    
         
             
            - lib/ffi-icu/transliteration.rb
         
     | 
| 
         @@ -98,17 +100,18 @@ files: 
     | 
|
| 
       98 
100 
     | 
    
         
             
            - spec/lib_spec.rb
         
     | 
| 
       99 
101 
     | 
    
         
             
            - spec/locale_spec.rb
         
     | 
| 
       100 
102 
     | 
    
         
             
            - spec/normalization_spec.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - spec/normalizer_spec.rb
         
     | 
| 
       101 
104 
     | 
    
         
             
            - spec/number_formatting_spec.rb
         
     | 
| 
       102 
     | 
    
         
            -
            - spec/spec.opts
         
     | 
| 
       103 
105 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       104 
106 
     | 
    
         
             
            - spec/time_spec.rb
         
     | 
| 
       105 
107 
     | 
    
         
             
            - spec/transliteration_spec.rb
         
     | 
| 
       106 
108 
     | 
    
         
             
            - spec/uchar_spec.rb
         
     | 
| 
       107 
109 
     | 
    
         
             
            - test.c
         
     | 
| 
       108 
110 
     | 
    
         
             
            homepage: http://github.com/jarib/ffi-icu
         
     | 
| 
       109 
     | 
    
         
            -
            licenses: 
     | 
| 
      
 111 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 112 
     | 
    
         
            +
            - MIT
         
     | 
| 
       110 
113 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       111 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 114 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       112 
115 
     | 
    
         
             
            rdoc_options:
         
     | 
| 
       113 
116 
     | 
    
         
             
            - "--charset=UTF-8"
         
     | 
| 
       114 
117 
     | 
    
         
             
            require_paths:
         
     | 
| 
         @@ -124,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       124 
127 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       125 
128 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       126 
129 
     | 
    
         
             
            requirements: []
         
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 130 
     | 
    
         
            +
            rubygems_version: 3.0.9
         
     | 
| 
      
 131 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       130 
132 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       131 
133 
     | 
    
         
             
            summary: Simple Ruby FFI wrappers for things I need from ICU.
         
     | 
| 
       132 
134 
     | 
    
         
             
            test_files:
         
     | 
| 
         @@ -137,8 +139,8 @@ test_files: 
     | 
|
| 
       137 
139 
     | 
    
         
             
            - spec/lib_spec.rb
         
     | 
| 
       138 
140 
     | 
    
         
             
            - spec/locale_spec.rb
         
     | 
| 
       139 
141 
     | 
    
         
             
            - spec/normalization_spec.rb
         
     | 
| 
      
 142 
     | 
    
         
            +
            - spec/normalizer_spec.rb
         
     | 
| 
       140 
143 
     | 
    
         
             
            - spec/number_formatting_spec.rb
         
     | 
| 
       141 
     | 
    
         
            -
            - spec/spec.opts
         
     | 
| 
       142 
144 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       143 
145 
     | 
    
         
             
            - spec/time_spec.rb
         
     | 
| 
       144 
146 
     | 
    
         
             
            - spec/transliteration_spec.rb
         
     | 
    
        data/spec/spec.opts
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --color
         
     |