ffi-icu 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/lib/ffi-icu.rb +1 -0
- data/lib/ffi-icu/lib.rb +17 -0
- data/lib/ffi-icu/number_formatting.rb +2 -2
- data/lib/ffi-icu/time_formatting.rb +181 -0
- data/lib/ffi-icu/transliteration.rb +2 -4
- data/lib/ffi-icu/uchar.rb +5 -6
- data/lib/ffi-icu/version.rb +1 -1
- data/spec/time_spec.rb +90 -0
- data/spec/transliteration_spec.rb +4 -3
- data/spec/uchar_spec.rb +1 -1
- metadata +19 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61818359548264beab4f803a6d4b6873eb9796f9
|
4
|
+
data.tar.gz: 5cffff3be406e40154bc45c51b2e199d3b36eb9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f212ef09319ea71ea83493578d659c8e44d8be59a5d9afeb72f14bfd08ca834e00026cf397eba9ebb8737011455bc4c717fd66b3684c00e6515409d80560ccb
|
7
|
+
data.tar.gz: 0ab9f362d3d94351fc720f95d90ab3718a299e0061a6fec80a2ae690d2a8d44556a8ef73d22d25b50f2d684c1a9dc2bd625030b9c05f2548406c48bde810b5ae
|
data/README.md
CHANGED
@@ -101,6 +101,27 @@ Examples:
|
|
101
101
|
curf.format(1234.56, 'USD') #=> "$1,234.56"
|
102
102
|
```
|
103
103
|
|
104
|
+
Time Formatting/Parsing
|
105
|
+
--------------------------
|
106
|
+
|
107
|
+
Examples:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# class method interface
|
111
|
+
f = ICU::TimeFormatting.format(Time.mktime(2015, 11, 12, 15, 21, 16), {:locale => 'cs_CZ', :zone => 'Europe/Prague', :date => :short, :time => :short})
|
112
|
+
f #=> "12.11.15 15:21"
|
113
|
+
|
114
|
+
# reusable formatting objects
|
115
|
+
formater = ICU::TimeFormatting.create(:locale => 'cs_CZ', :zone => 'Europe/Prague', :date => :long , :time => :none)
|
116
|
+
formater.format(Time.now) #=> "25. února 2015"
|
117
|
+
```
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
# reusable formatting objects
|
121
|
+
formater = ICU::TimeFormatting.create(:locale => 'cs_CZ', :zone => 'Europe/Prague', :date => :long , :time => :none)
|
122
|
+
formater.parse("25. února 2015") #=> Wed Feb 25 00:00:00 +0100 2015
|
123
|
+
```
|
124
|
+
|
104
125
|
Tested on:
|
105
126
|
==========
|
106
127
|
|
data/lib/ffi-icu.rb
CHANGED
data/lib/ffi-icu/lib.rb
CHANGED
@@ -409,6 +409,23 @@ module ICU
|
|
409
409
|
end
|
410
410
|
attach_function :unum_format_currency, "unum_formatDoubleCurrency#{suffix}", [:pointer, :double, :pointer, :pointer, :int32_t, :pointer, :pointer], :int32_t
|
411
411
|
attach_function :unum_set_attribute, "unum_setAttribute#{suffix}", [:pointer, :number_format_attribute, :int32_t], :void
|
412
|
+
# date
|
413
|
+
enum :date_format_style, [
|
414
|
+
:none, -1,
|
415
|
+
:full, 0,
|
416
|
+
:long, 1,
|
417
|
+
:medium, 2,
|
418
|
+
:short, 3,
|
419
|
+
]
|
420
|
+
attach_function :udat_open, "udat_open#{suffix}", [:date_format_style, :date_format_style, :string, :pointer, :int32_t, :pointer, :int32_t, :pointer ], :pointer
|
421
|
+
attach_function :udat_close, "unum_close#{suffix}", [:pointer], :void
|
422
|
+
attach_function :udat_format, "udat_format#{suffix}", [:pointer, :double, :pointer, :int32_t, :pointer, :pointer], :int32_t
|
423
|
+
attach_function :udat_parse, "udat_parse#{suffix}", [:pointer, :pointer, :int32_t, :pointer, :pointer], :double
|
424
|
+
attach_function :udat_toPattern, "udat_toPattern#{suffix}", [:pointer, :bool , :pointer, :int32_t , :pointer], :int32_t
|
425
|
+
attach_function :udat_applyPattern, "udat_applyPattern#{suffix}", [:pointer, :bool , :pointer, :int32_t ], :void
|
426
|
+
# tz
|
427
|
+
attach_function :ucal_setDefaultTimeZone, "ucal_setDefaultTimeZone#{suffix}", [:pointer, :pointer], :int32_t
|
428
|
+
attach_function :ucal_getDefaultTimeZone, "ucal_getDefaultTimeZone#{suffix}", [:pointer, :int32_t, :pointer], :int32_t
|
412
429
|
|
413
430
|
end # Lib
|
414
431
|
end # ICU
|
@@ -81,7 +81,7 @@ module ICU
|
|
81
81
|
needed_length = Lib.unum_format_int64(@f, number, out_ptr, needed_length, nil, error)
|
82
82
|
end
|
83
83
|
end
|
84
|
-
out_ptr.string
|
84
|
+
out_ptr.string needed_length
|
85
85
|
rescue BufferOverflowError
|
86
86
|
raise BufferOverflowError, "needed: #{needed_length}" if retried
|
87
87
|
out_ptr = out_ptr.resized_to needed_length
|
@@ -115,7 +115,7 @@ module ICU
|
|
115
115
|
|
116
116
|
begin
|
117
117
|
Lib.check_error do |error|
|
118
|
-
needed_length = Lib.unum_format_currency(@f, number, UCharPointer.from_string(currency,
|
118
|
+
needed_length = Lib.unum_format_currency(@f, number, UCharPointer.from_string(currency, 4), out_ptr, needed_length, nil, error)
|
119
119
|
end
|
120
120
|
out_ptr.string
|
121
121
|
rescue BufferOverflowError
|
@@ -0,0 +1,181 @@
|
|
1
|
+
|
2
|
+
module ICU
|
3
|
+
module TimeFormatting
|
4
|
+
TZ_MAP = {
|
5
|
+
:generic_location => 'VVVV',# The generic location format.
|
6
|
+
# Where that is unavailable, falls back to the long localized GMT format ("OOOO";
|
7
|
+
# Note: Fallback is only necessary with a GMT-style Time Zone ID, like Etc/GMT-830.),
|
8
|
+
# This is especially useful when presenting possible timezone choices for user selection,
|
9
|
+
# since the naming is more uniform than the "v" format.
|
10
|
+
# such as "United States Time (New York)", "Italy Time"
|
11
|
+
:generic_long => 'vvvv', # The long generic non-location format.
|
12
|
+
# Where that is unavailable, falls back to generic location format ("VVVV")., such as "Eastern Time".
|
13
|
+
:generic_short => 'v', # The short generic non-location format.
|
14
|
+
# Where that is unavailable, falls back to the generic location format ("VVVV"),
|
15
|
+
# then the short localized GMT format as the final fallback., such as "ET".
|
16
|
+
:specific_long => 'zzzz', # The long specific non-location format.
|
17
|
+
# Where that is unavailable, falls back to the long localized GMT format ("OOOO").
|
18
|
+
:specific_short => 'z', # The short specific non-location format.
|
19
|
+
# Where that is unavailable, falls back to the short localized GMT format ("O").
|
20
|
+
:basic => 'Z', # The ISO8601 basic format with hours, minutes and optional seconds fields.
|
21
|
+
# The format is equivalent to RFC 822 zone format (when optional seconds field is absent).
|
22
|
+
# This is equivalent to the "xxxx" specifier.
|
23
|
+
:localized_long => 'ZZZZ', # The long localized GMT format. This is equivalent to the "OOOO" specifier, such as GMT-8:00
|
24
|
+
:extended => 'ZZZZZ', # The ISO8601 extended format with hours, minutes and optional seconds fields.
|
25
|
+
# The ISO8601 UTC indicator "Z" is used when local time offset is 0.
|
26
|
+
# This is equivalent to the "XXXXX" specifier, such as -08:00 -07:52:58
|
27
|
+
:localized_short => 'O', # The short localized GMT format, such as GMT-8
|
28
|
+
:localized_longO => 'OOOO', # The long localized GMT format, such as GMT-08:00
|
29
|
+
:tz_id_short => 'V', # The short time zone ID. Where that is unavailable,
|
30
|
+
# the special short time zone ID unk (Unknown Zone) is used.
|
31
|
+
# Note: This specifier was originally used for a variant of the short specific non-location format,
|
32
|
+
# but it was deprecated in the later version of this specification. In CLDR 23, the definition
|
33
|
+
# of the specifier was changed to designate a short time zone ID, such as uslax
|
34
|
+
:tz_id_long => 'VV', # The long time zone ID, such as America/Los_Angeles
|
35
|
+
:city_location => 'VVV', # The exemplar city (location) for the time zone. Where that is unavailable,
|
36
|
+
# the localized exemplar city name for the special zone Etc/Unknown is used as the fallback
|
37
|
+
# (for example, "Unknown City"), such as Los Angeles
|
38
|
+
# see: http://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns
|
39
|
+
}
|
40
|
+
@default_options = {}
|
41
|
+
|
42
|
+
def self.create(options = {})
|
43
|
+
DateTimeFormatter.new(@default_options.merge(options))
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.clear_default_options
|
47
|
+
@default_options.clear
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.set_default_options(options)
|
51
|
+
@default_options.merge!(options)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.format(dt, options = {})
|
55
|
+
create(@default_options.merge(options)).format(dt)
|
56
|
+
end
|
57
|
+
|
58
|
+
class BaseFormatter
|
59
|
+
|
60
|
+
def set_attributes(options)
|
61
|
+
options.each { |key, value| Lib.unum_set_attribute(@f, key, value) }
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def make_formatter(time_style, date_style, locale, time_zone_str)
|
68
|
+
time_zone = nil
|
69
|
+
d_len = 0
|
70
|
+
if time_zone_str
|
71
|
+
time_zone = UCharPointer.from_string(time_zone_str)
|
72
|
+
d_len = time_zone_str.size
|
73
|
+
else
|
74
|
+
Lib.check_error { | error|
|
75
|
+
i_len = 150
|
76
|
+
time_zone = UCharPointer.new(i_len)
|
77
|
+
d_len = Lib.ucal_getDefaultTimeZone(time_zone, i_len, error)
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
ptr = Lib.check_error { | error| Lib.udat_open(time_style, date_style, locale, time_zone, d_len, FFI::MemoryPointer.new(4), -1, error) }
|
82
|
+
FFI::AutoPointer.new(ptr, Lib.method(:udat_close))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class DateTimeFormatter < BaseFormatter
|
87
|
+
def initialize(options={})
|
88
|
+
time_style = options[:time] || :short
|
89
|
+
date_style = options[:date] || :short
|
90
|
+
locale = options[:locale] || 'C'
|
91
|
+
tz_style = options[:tz_style]
|
92
|
+
time_zone = options[:zone]
|
93
|
+
@f = make_formatter(time_style, date_style, locale, time_zone)
|
94
|
+
if tz_style
|
95
|
+
f0 = date_format(true)
|
96
|
+
f1 = update_tz_format(f0, tz_style)
|
97
|
+
if f1 != f0
|
98
|
+
set_date_format(true, f1)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def parse(str)
|
104
|
+
str_u = UCharPointer.from_string(str)
|
105
|
+
str_l = str_u.size
|
106
|
+
Lib.check_error do |error|
|
107
|
+
ret = Lib.udat_parse(@f, str_u, str_l, nil, error)
|
108
|
+
Time.at(ret / 1000.0)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def format(dt)
|
113
|
+
needed_length = 0
|
114
|
+
out_ptr = UCharPointer.new(needed_length)
|
115
|
+
|
116
|
+
retried = false
|
117
|
+
|
118
|
+
begin
|
119
|
+
Lib.check_error do |error|
|
120
|
+
case dt
|
121
|
+
when Date
|
122
|
+
needed_length = Lib.udat_format(@f, Time.mktime( dt.year, dt.month, dt.day, 0, 0, 0, 0 ).to_f * 1000.0, out_ptr, needed_length, nil, error)
|
123
|
+
when Time
|
124
|
+
needed_length = Lib.udat_format(@f, dt.to_f * 1000.0, out_ptr, needed_length, nil, error)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
out_ptr.string
|
129
|
+
rescue BufferOverflowError
|
130
|
+
raise BufferOverflowError, "needed: #{needed_length}" if retried
|
131
|
+
out_ptr = out_ptr.resized_to needed_length
|
132
|
+
retried = true
|
133
|
+
retry
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# time-zone formating
|
138
|
+
def update_tz_format(format, tz_style)
|
139
|
+
return format if format !~ /(.*?)(\s*(?:[zZOVV]+\s*))(.*?)/
|
140
|
+
pre, tz, suff = $1, $2, $3
|
141
|
+
if tz_style == :none
|
142
|
+
tz = ((tz =~ /\s/) && !pre.empty? && !suff.empty?) ? ' ' : ''
|
143
|
+
else
|
144
|
+
repl = TZ_MAP[tz_style]
|
145
|
+
raise 'no such tz_style' unless repl
|
146
|
+
tz.gsub!(/^(\s*)(.*?)(\s*)$/, '\1'+repl+'\3')
|
147
|
+
end
|
148
|
+
pre + tz + suff
|
149
|
+
end
|
150
|
+
|
151
|
+
def date_format(localized=true)
|
152
|
+
needed_length = 0
|
153
|
+
out_ptr = UCharPointer.new(needed_length)
|
154
|
+
|
155
|
+
retried = false
|
156
|
+
|
157
|
+
begin
|
158
|
+
Lib.check_error do |error|
|
159
|
+
needed_length = Lib.udat_toPattern(@f, localized, out_ptr, needed_length, error)
|
160
|
+
end
|
161
|
+
|
162
|
+
out_ptr.string
|
163
|
+
rescue BufferOverflowError
|
164
|
+
raise BufferOverflowError, "needed: #{needed_length}" if retried
|
165
|
+
out_ptr = out_ptr.resized_to needed_length
|
166
|
+
retried = true
|
167
|
+
retry
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def set_date_format(localized, pattern_str)
|
172
|
+
pattern = UCharPointer.from_string(pattern_str)
|
173
|
+
pattern_len = pattern_str.size
|
174
|
+
|
175
|
+
Lib.check_error do |error|
|
176
|
+
needed_length = Lib.udat_applyPattern(@f, localized, pattern, pattern_len)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end # DateTimeFormatter
|
180
|
+
end # Formatting
|
181
|
+
end # ICU
|
@@ -23,8 +23,6 @@ module ICU
|
|
23
23
|
class Transliterator
|
24
24
|
|
25
25
|
def initialize(id, rules = nil, direction = :forward)
|
26
|
-
warn 'the ffi-icu transliteration support is broken, see https://github.com/jarib/ffi-icu/issues/15'
|
27
|
-
|
28
26
|
rules_length = 0
|
29
27
|
|
30
28
|
if rules
|
@@ -47,8 +45,8 @@ module ICU
|
|
47
45
|
# this is a bit unpleasant
|
48
46
|
|
49
47
|
unicode_size = from.unpack("U*").size
|
50
|
-
capacity =
|
51
|
-
buf = UCharPointer.from_string(from)
|
48
|
+
capacity = unicode_size + 1
|
49
|
+
buf = UCharPointer.from_string(from, capacity)
|
52
50
|
limit = FFI::MemoryPointer.new :int32
|
53
51
|
text_length = FFI::MemoryPointer.new :int32
|
54
52
|
|
data/lib/ffi-icu/uchar.rb
CHANGED
@@ -6,20 +6,19 @@ module ICU
|
|
6
6
|
|
7
7
|
def self.from_string(str, capacity = nil)
|
8
8
|
str = str.encode("UTF-8") if str.respond_to? :encode
|
9
|
-
|
9
|
+
chars = str.unpack("U*")
|
10
10
|
|
11
11
|
if capacity
|
12
|
-
capacity
|
13
|
-
|
14
|
-
raise ArgumentError, "capacity is too small for string of #{bytes.size} bytes"
|
12
|
+
if capacity < chars.size
|
13
|
+
raise ArgumentError, "capacity is too small for string of #{chars.size} UChars"
|
15
14
|
end
|
16
15
|
|
17
16
|
ptr = new capacity
|
18
17
|
else
|
19
|
-
ptr = new
|
18
|
+
ptr = new chars.size
|
20
19
|
end
|
21
20
|
|
22
|
-
ptr.write_array_of_uint16
|
21
|
+
ptr.write_array_of_uint16 chars
|
23
22
|
|
24
23
|
ptr
|
25
24
|
end
|
data/lib/ffi-icu/version.rb
CHANGED
data/spec/time_spec.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module ICU
|
6
|
+
describe TimeFormatting do
|
7
|
+
describe 'the TimeFormatting ' do
|
8
|
+
t0 = Time.at(1226499676) # in TZ=Europe/Prague Time.mktime(2008, 11, 12, 15, 21, 16)
|
9
|
+
t1 = Time.at(1224890117) # in TZ=Europe/Prague Time.mktime(2008, 10, 25, 01, 15, 17)
|
10
|
+
t2 = Time.at(1224893778) # in TZ=Europe/Prague Time.mktime(2008, 10, 25, 02, 16, 18)
|
11
|
+
t3 = Time.at(1224897439) # in TZ=Europe/Prague Time.mktime(2008, 10, 25, 03, 17, 19)
|
12
|
+
t4 = Time.at(1224901100) # in TZ=Europe/Prague Time.mktime(2008, 10, 25, 04, 18, 20)
|
13
|
+
t5 = Time.at(1206750921) # in TZ=Europe/Prague Time.mktime(2008, 03, 29, 01, 35, 21)
|
14
|
+
t6 = Time.at(1206754582) # in TZ=Europe/Prague Time.mktime(2008, 03, 29, 02, 36, 22)
|
15
|
+
t7 = Time.at(1206758243) # in TZ=Europe/Prague Time.mktime(2008, 03, 29, 03, 37, 23)
|
16
|
+
t8 = Time.at(1206761904) # in TZ=Europe/Prague Time.mktime(2008, 03, 29, 04, 38, 24)
|
17
|
+
|
18
|
+
f1 = TimeFormatting.create(:locale => 'cs_CZ', :zone => 'Europe/Prague', :date => :long , :time => :long, :tz_style => :localized_long)
|
19
|
+
it 'check date_format for lang=cs_CZ' do
|
20
|
+
f1.date_format(true).should eql "d. MMMM y H:mm:ss ZZZZ"
|
21
|
+
f1.date_format(false).should eql "d. MMMM y H:mm:ss ZZZZ"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "for lang=cs_CZ zone=Europe/Prague" do
|
25
|
+
f1.should be_an_instance_of TimeFormatting::DateTimeFormatter
|
26
|
+
f1.format(t0).should eql "12. listopadu 2008 15:21:16 GMT+01:00"
|
27
|
+
f1.format(t1).should eql "25. října 2008 1:15:17 GMT+02:00"
|
28
|
+
f1.format(t2).should eql "25. října 2008 2:16:18 GMT+02:00"
|
29
|
+
f1.format(t3).should eql "25. října 2008 3:17:19 GMT+02:00"
|
30
|
+
f1.format(t4).should eql "25. října 2008 4:18:20 GMT+02:00"
|
31
|
+
f1.format(t5).should eql "29. března 2008 1:35:21 GMT+01:00"
|
32
|
+
f1.format(t6).should eql "29. března 2008 2:36:22 GMT+01:00"
|
33
|
+
f1.format(t7).should eql "29. března 2008 3:37:23 GMT+01:00"
|
34
|
+
f1.format(t8).should eql "29. března 2008 4:38:24 GMT+01:00"
|
35
|
+
end
|
36
|
+
|
37
|
+
f2 = TimeFormatting.create(:locale => 'en_US', :zone => 'Europe/Moscow', :date => :short , :time => :long, :tz_style => :generic_location)
|
38
|
+
cldr_version = Lib.cldr_version.to_s
|
39
|
+
en_tz = "Moscow Time"
|
40
|
+
en_sep = ","
|
41
|
+
if cldr_version <= "2.0.1"
|
42
|
+
en_tz = "Russia Time (Moscow)"
|
43
|
+
en_sep = ""
|
44
|
+
end
|
45
|
+
|
46
|
+
en_exp = "M/d/yy#{en_sep} h:mm:ss a VVVV"
|
47
|
+
it 'check date_format for lang=en_US' do
|
48
|
+
f2.date_format(true).should eql en_exp
|
49
|
+
f2.date_format(false).should eql en_exp
|
50
|
+
end
|
51
|
+
|
52
|
+
it "lang=en_US zone=Europe/Moscow" do
|
53
|
+
f2.format(t0).should eql "11/12/08#{en_sep} 5:21:16 PM #{en_tz}"
|
54
|
+
f2.format(t1).should eql "10/25/08#{en_sep} 3:15:17 AM #{en_tz}"
|
55
|
+
f2.format(t2).should eql "10/25/08#{en_sep} 4:16:18 AM #{en_tz}"
|
56
|
+
f2.format(t3).should eql "10/25/08#{en_sep} 5:17:19 AM #{en_tz}"
|
57
|
+
f2.format(t4).should eql "10/25/08#{en_sep} 6:18:20 AM #{en_tz}"
|
58
|
+
f2.format(t5).should eql "3/29/08#{en_sep} 3:35:21 AM #{en_tz}"
|
59
|
+
f2.format(t6).should eql "3/29/08#{en_sep} 4:36:22 AM #{en_tz}"
|
60
|
+
f2.format(t7).should eql "3/29/08#{en_sep} 5:37:23 AM #{en_tz}"
|
61
|
+
f2.format(t8).should eql "3/29/08#{en_sep} 6:38:24 AM #{en_tz}"
|
62
|
+
end
|
63
|
+
|
64
|
+
f3 = TimeFormatting.create(:locale => 'de_DE', :zone => 'Africa/Dakar ', :date => :short , :time => :long)
|
65
|
+
ge_sep = ""
|
66
|
+
if cldr_version >= "27.0.1"
|
67
|
+
ge_sep = ","
|
68
|
+
end
|
69
|
+
|
70
|
+
ge_exp = "dd.MM.yy#{ge_sep} HH:mm:ss z"
|
71
|
+
it 'check date_format for lang=de_DE' do
|
72
|
+
f3.date_format(true).should eql ge_exp
|
73
|
+
f3.date_format(false).should eql ge_exp
|
74
|
+
end
|
75
|
+
|
76
|
+
it "lang=de_DE zone=Africa/Dakar" do
|
77
|
+
f3.format(t0).should eql "12.11.08#{ge_sep} 14:21:16 GMT"
|
78
|
+
f3.format(t1).should eql "24.10.08#{ge_sep} 23:15:17 GMT"
|
79
|
+
f3.format(t2).should eql "25.10.08#{ge_sep} 00:16:18 GMT"
|
80
|
+
f3.format(t3).should eql "25.10.08#{ge_sep} 01:17:19 GMT"
|
81
|
+
f3.format(t4).should eql "25.10.08#{ge_sep} 02:18:20 GMT"
|
82
|
+
f3.format(t5).should eql "29.03.08#{ge_sep} 00:35:21 GMT"
|
83
|
+
f3.format(t6).should eql "29.03.08#{ge_sep} 01:36:22 GMT"
|
84
|
+
f3.format(t7).should eql "29.03.08#{ge_sep} 02:37:23 GMT"
|
85
|
+
f3.format(t8).should eql "29.03.08#{ge_sep} 03:38:24 GMT"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
module ICU
|
6
|
-
describe Transliteration::Transliterator
|
6
|
+
describe Transliteration::Transliterator do
|
7
7
|
def transliterator_for(*args)
|
8
8
|
Transliteration::Transliterator.new(*args)
|
9
9
|
end
|
@@ -11,7 +11,8 @@ module ICU
|
|
11
11
|
[
|
12
12
|
["Any-Hex", "abcde", "\\u0061\\u0062\\u0063\\u0064\\u0065"],
|
13
13
|
["Lower", "ABC", "abc"],
|
14
|
-
["en", "雙屬性集合之空間分群演算法-應用於地理資料", "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"]
|
14
|
+
["en", "雙屬性集合之空間分群演算法-應用於地理資料", "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
|
+
["Devanagari-Latin", "दौलत", "daulata"]
|
15
16
|
].each do |id, input, output|
|
16
17
|
it "should transliterate #{id}" do
|
17
18
|
tl = transliterator_for(id)
|
@@ -21,7 +22,7 @@ module ICU
|
|
21
22
|
end
|
22
23
|
end # Transliterator
|
23
24
|
|
24
|
-
describe Transliteration
|
25
|
+
describe Transliteration do
|
25
26
|
it "should provide a list of available ids" do
|
26
27
|
ids = ICU::Transliteration.available_ids
|
27
28
|
ids.should be_kind_of(Array)
|
data/spec/uchar_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-icu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
@@ -14,48 +14,48 @@ dependencies:
|
|
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
39
|
version: 2.5.0
|
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
46
|
version: 2.5.0
|
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
53
|
version: 0.9.2
|
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
60
|
version: 0.9.2
|
61
61
|
description: Provides charset detection, locale sensitive collation and more. Depends
|
@@ -67,9 +67,9 @@ extra_rdoc_files:
|
|
67
67
|
- LICENSE
|
68
68
|
- README.md
|
69
69
|
files:
|
70
|
-
- .document
|
71
|
-
- .gitignore
|
72
|
-
- .travis.yml
|
70
|
+
- ".document"
|
71
|
+
- ".gitignore"
|
72
|
+
- ".travis.yml"
|
73
73
|
- Gemfile
|
74
74
|
- LICENSE
|
75
75
|
- README.md
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/ffi-icu/locale.rb
|
88
88
|
- lib/ffi-icu/normalization.rb
|
89
89
|
- lib/ffi-icu/number_formatting.rb
|
90
|
+
- lib/ffi-icu/time_formatting.rb
|
90
91
|
- lib/ffi-icu/transliteration.rb
|
91
92
|
- lib/ffi-icu/uchar.rb
|
92
93
|
- lib/ffi-icu/version.rb
|
@@ -100,6 +101,7 @@ files:
|
|
100
101
|
- spec/number_formatting_spec.rb
|
101
102
|
- spec/spec.opts
|
102
103
|
- spec/spec_helper.rb
|
104
|
+
- spec/time_spec.rb
|
103
105
|
- spec/transliteration_spec.rb
|
104
106
|
- spec/uchar_spec.rb
|
105
107
|
- test.c
|
@@ -108,22 +110,22 @@ licenses: []
|
|
108
110
|
metadata: {}
|
109
111
|
post_install_message:
|
110
112
|
rdoc_options:
|
111
|
-
- --charset=UTF-8
|
113
|
+
- "--charset=UTF-8"
|
112
114
|
require_paths:
|
113
115
|
- lib
|
114
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
117
|
requirements:
|
116
|
-
- -
|
118
|
+
- - ">="
|
117
119
|
- !ruby/object:Gem::Version
|
118
120
|
version: '0'
|
119
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
122
|
requirements:
|
121
|
-
- -
|
123
|
+
- - ">="
|
122
124
|
- !ruby/object:Gem::Version
|
123
125
|
version: '0'
|
124
126
|
requirements: []
|
125
127
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.4.5
|
127
129
|
signing_key:
|
128
130
|
specification_version: 4
|
129
131
|
summary: Simple Ruby FFI wrappers for things I need from ICU.
|
@@ -138,5 +140,6 @@ test_files:
|
|
138
140
|
- spec/number_formatting_spec.rb
|
139
141
|
- spec/spec.opts
|
140
142
|
- spec/spec_helper.rb
|
143
|
+
- spec/time_spec.rb
|
141
144
|
- spec/transliteration_spec.rb
|
142
145
|
- spec/uchar_spec.rb
|