ffi-icu 0.1.10 → 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 +7 -10
- data/ffi-icu.gemspec +4 -4
- data/lib/ffi-icu.rb +0 -9
- data/lib/ffi-icu/lib.rb +6 -1
- data/lib/ffi-icu/locale.rb +4 -4
- 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 +24 -26
- 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 +27 -28
- 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,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,63 +1,63 @@
|
|
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
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 1.0.9
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.0'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.0.9
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rspec
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
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
|
@@ -67,9 +67,10 @@ extra_rdoc_files:
|
|
67
67
|
- LICENSE
|
68
68
|
- README.md
|
69
69
|
files:
|
70
|
-
- .document
|
71
|
-
- .gitignore
|
72
|
-
- .
|
70
|
+
- ".document"
|
71
|
+
- ".gitignore"
|
72
|
+
- ".rspec"
|
73
|
+
- ".travis.yml"
|
73
74
|
- Gemfile
|
74
75
|
- LICENSE
|
75
76
|
- README.md
|
@@ -101,34 +102,33 @@ files:
|
|
101
102
|
- spec/normalization_spec.rb
|
102
103
|
- spec/normalizer_spec.rb
|
103
104
|
- spec/number_formatting_spec.rb
|
104
|
-
- spec/spec.opts
|
105
105
|
- spec/spec_helper.rb
|
106
106
|
- spec/time_spec.rb
|
107
107
|
- spec/transliteration_spec.rb
|
108
108
|
- spec/uchar_spec.rb
|
109
109
|
- test.c
|
110
110
|
homepage: http://github.com/jarib/ffi-icu
|
111
|
-
licenses:
|
111
|
+
licenses:
|
112
|
+
- MIT
|
112
113
|
metadata: {}
|
113
|
-
post_install_message:
|
114
|
+
post_install_message:
|
114
115
|
rdoc_options:
|
115
|
-
- --charset=UTF-8
|
116
|
+
- "--charset=UTF-8"
|
116
117
|
require_paths:
|
117
118
|
- lib
|
118
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
120
|
requirements:
|
120
|
-
- -
|
121
|
+
- - ">="
|
121
122
|
- !ruby/object:Gem::Version
|
122
123
|
version: '0'
|
123
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
125
|
requirements:
|
125
|
-
- -
|
126
|
+
- - ">="
|
126
127
|
- !ruby/object:Gem::Version
|
127
128
|
version: '0'
|
128
129
|
requirements: []
|
129
|
-
|
130
|
-
|
131
|
-
signing_key:
|
130
|
+
rubygems_version: 3.0.9
|
131
|
+
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Simple Ruby FFI wrappers for things I need from ICU.
|
134
134
|
test_files:
|
@@ -141,7 +141,6 @@ test_files:
|
|
141
141
|
- spec/normalization_spec.rb
|
142
142
|
- spec/normalizer_spec.rb
|
143
143
|
- spec/number_formatting_spec.rb
|
144
|
-
- spec/spec.opts
|
145
144
|
- spec/spec_helper.rb
|
146
145
|
- spec/time_spec.rb
|
147
146
|
- spec/transliteration_spec.rb
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|