ffi-icu 0.2.0 → 0.4.1
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 +16 -3
- data/README.md +20 -11
- data/ffi-icu.gemspec +2 -3
- data/lib/ffi-icu/lib.rb +16 -9
- data/lib/ffi-icu/number_formatting.rb +13 -4
- data/lib/ffi-icu/time_formatting.rb +46 -8
- data/lib/ffi-icu/version.rb +1 -1
- data/lib/ffi-icu.rb +0 -9
- 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 +97 -85
- data/spec/normalization_spec.rb +2 -4
- data/spec/normalizer_spec.rb +24 -26
- data/spec/number_formatting_spec.rb +33 -25
- data/spec/time_spec.rb +48 -38
- data/spec/transliteration_spec.rb +6 -7
- data/spec/uchar_spec.rb +8 -10
- metadata +12 -20
- data/spec/spec.opts +0 -1
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,23 +43,23 @@ 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
|
-
f3 = TimeFormatting.create(:locale => 'de_DE', :zone => 'Africa/Dakar
|
62
|
+
f3 = TimeFormatting.create(:locale => 'de_DE', :zone => 'Africa/Dakar', :date => :short , :time => :long)
|
65
63
|
ge_sep = ""
|
66
64
|
if cldr_version >= "27.0.1"
|
67
65
|
ge_sep = ","
|
@@ -69,22 +67,34 @@ 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")
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'skeleton pattern' do
|
87
|
+
f4 = TimeFormatting.create(:locale => 'fr_FR', :date => :pattern, :time => :pattern, :skeleton => 'MMMy')
|
88
|
+
|
89
|
+
it 'check format' do
|
90
|
+
expect(f4.format(t0)).to eq("nov. 2008")
|
91
|
+
expect(f4.format(t1)).to eq("oct. 2008")
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'check date_format' do
|
95
|
+
expect(f4.date_format(true)).to eq("MMM y")
|
96
|
+
end
|
86
97
|
end
|
87
98
|
end
|
88
99
|
end
|
89
100
|
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)
|
@@ -11,12 +9,12 @@ module ICU
|
|
11
9
|
[
|
12
10
|
["Any-Hex", "abcde", "\\u0061\\u0062\\u0063\\u0064\\u0065"],
|
13
11
|
["Lower", "ABC", "abc"],
|
14
|
-
["
|
12
|
+
["Han-Latin", "雙屬性集合之空間分群演算法-應用於地理資料", "shuāng shǔ xìng jí hé zhī kōng jiān fēn qún yǎn suàn fǎ-yīng yòng yú de lǐ zī liào"],
|
15
13
|
["Devanagari-Latin", "दौलत", "daulata"]
|
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,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-icu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-10-15 00:00:00.000000000 Z
|
@@ -36,34 +36,28 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 2.5.0
|
39
|
+
version: '3.9'
|
43
40
|
type: :development
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 2.5.0
|
46
|
+
version: '3.9'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
48
|
name: rake
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
|
-
- - "
|
51
|
+
- - ">="
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
53
|
+
version: 12.3.3
|
60
54
|
type: :development
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
57
|
requirements:
|
64
|
-
- - "
|
58
|
+
- - ">="
|
65
59
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
60
|
+
version: 12.3.3
|
67
61
|
description: Provides charset detection, locale sensitive collation and more. Depends
|
68
62
|
on libicu.
|
69
63
|
email: jari.bakken@gmail.com
|
@@ -75,6 +69,7 @@ extra_rdoc_files:
|
|
75
69
|
files:
|
76
70
|
- ".document"
|
77
71
|
- ".gitignore"
|
72
|
+
- ".rspec"
|
78
73
|
- ".travis.yml"
|
79
74
|
- Gemfile
|
80
75
|
- LICENSE
|
@@ -107,7 +102,6 @@ files:
|
|
107
102
|
- spec/normalization_spec.rb
|
108
103
|
- spec/normalizer_spec.rb
|
109
104
|
- spec/number_formatting_spec.rb
|
110
|
-
- spec/spec.opts
|
111
105
|
- spec/spec_helper.rb
|
112
106
|
- spec/time_spec.rb
|
113
107
|
- spec/transliteration_spec.rb
|
@@ -117,7 +111,7 @@ homepage: http://github.com/jarib/ffi-icu
|
|
117
111
|
licenses:
|
118
112
|
- MIT
|
119
113
|
metadata: {}
|
120
|
-
post_install_message:
|
114
|
+
post_install_message:
|
121
115
|
rdoc_options:
|
122
116
|
- "--charset=UTF-8"
|
123
117
|
require_paths:
|
@@ -133,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
127
|
- !ruby/object:Gem::Version
|
134
128
|
version: '0'
|
135
129
|
requirements: []
|
136
|
-
|
137
|
-
|
138
|
-
signing_key:
|
130
|
+
rubygems_version: 3.0.9
|
131
|
+
signing_key:
|
139
132
|
specification_version: 4
|
140
133
|
summary: Simple Ruby FFI wrappers for things I need from ICU.
|
141
134
|
test_files:
|
@@ -148,7 +141,6 @@ test_files:
|
|
148
141
|
- spec/normalization_spec.rb
|
149
142
|
- spec/normalizer_spec.rb
|
150
143
|
- spec/number_formatting_spec.rb
|
151
|
-
- spec/spec.opts
|
152
144
|
- spec/spec_helper.rb
|
153
145
|
- spec/time_spec.rb
|
154
146
|
- spec/transliteration_spec.rb
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|