ruby-cldr 0.0.1 → 0.0.2
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.
- data/Gemfile +7 -0
- data/Gemfile.lock +23 -0
- data/README.textile +9 -6
- data/VERSION +1 -1
- data/lib/cldr.rb +1 -1
- data/lib/cldr/data.rb +9 -29
- data/lib/cldr/download.rb +2 -2
- data/lib/cldr/export.rb +8 -2
- data/lib/cldr/export/code.rb +34 -0
- data/lib/cldr/export/code/numbers.rb +29 -0
- data/lib/cldr/export/data.rb +36 -0
- data/lib/cldr/export/data/base.rb +61 -0
- data/lib/cldr/export/data/calendars.rb +14 -0
- data/lib/cldr/export/data/calendars/gregorian.rb +142 -0
- data/lib/cldr/export/data/currencies.rb +28 -0
- data/lib/cldr/export/data/delimiters.rb +29 -0
- data/lib/cldr/export/data/languages.rb +19 -0
- data/lib/cldr/export/data/numbers.rb +67 -0
- data/lib/cldr/export/data/plurals.rb +41 -0
- data/lib/cldr/{data → export/data}/plurals/cldr_grammar.treetop +0 -0
- data/lib/cldr/export/data/plurals/grammar.rb +538 -0
- data/lib/cldr/export/data/plurals/rules.rb +119 -0
- data/lib/cldr/export/data/territories.rb +19 -0
- data/lib/cldr/export/data/timezones.rb +27 -0
- data/lib/cldr/export/data/units.rb +29 -0
- data/lib/cldr/export/ruby.rb +1 -1
- data/lib/cldr/export/yaml.rb +1 -1
- data/lib/cldr/format.rb +1 -97
- data/lib/cldr/format/currency.rb +1 -1
- data/lib/cldr/format/date.rb +1 -1
- data/lib/cldr/format/datetime.rb +14 -18
- data/lib/cldr/format/datetime/base.rb +1 -1
- data/lib/cldr/format/decimal.rb +1 -1
- data/lib/cldr/format/decimal/base.rb +1 -1
- data/lib/cldr/format/decimal/fraction.rb +1 -1
- data/lib/cldr/format/decimal/integer.rb +1 -1
- data/lib/cldr/format/decimal/number.rb +1 -1
- data/lib/cldr/format/percent.rb +1 -1
- data/lib/cldr/format/time.rb +1 -1
- data/lib/cldr/thor.rb +3 -3
- data/test/all.rb +1 -1
- data/test/export/code/numbers_test.rb +11 -0
- data/test/{data → export/data}/all.rb +1 -1
- data/test/{data → export/data}/calendars_test.rb +18 -18
- data/test/{data → export/data}/currencies_test.rb +6 -6
- data/test/{data → export/data}/delimiters_test.rb +6 -6
- data/test/{data → export/data}/languages_test.rb +6 -6
- data/test/{data → export/data}/numbers_test.rb +8 -8
- data/test/export/data/plurals_test.rb +141 -0
- data/test/{data → export/data}/territories_test.rb +6 -6
- data/test/{data → export/data}/timezones_test.rb +6 -6
- data/test/{data → export/data}/units_test.rb +6 -6
- data/test/export_test.rb +8 -8
- data/test/{formats → format}/all.rb +1 -1
- data/test/format/currency_test.rb +0 -0
- data/test/format/date_test.rb +265 -0
- data/test/format/datetime_test.rb +18 -0
- data/test/{formats → format}/decimal/fraction_test.rb +4 -4
- data/test/{formats → format}/decimal/integer_test.rb +17 -17
- data/test/{formats → format}/decimal/number_test.rb +19 -19
- data/test/{formats → format}/decimal_test.rb +5 -5
- data/test/format/percent_test.rb +0 -0
- data/test/format/time_test.rb +195 -0
- data/test/test_autotest.rb +36 -0
- data/test/test_helper.rb +16 -1
- metadata +124 -114
- data/lib/cldr/data/base.rb +0 -66
- data/lib/cldr/data/calendars.rb +0 -12
- data/lib/cldr/data/calendars/gregorian.rb +0 -124
- data/lib/cldr/data/currencies.rb +0 -26
- data/lib/cldr/data/delimiters.rb +0 -21
- data/lib/cldr/data/languages.rb +0 -17
- data/lib/cldr/data/numbers.rb +0 -60
- data/lib/cldr/data/plurals.rb +0 -39
- data/lib/cldr/data/plurals/grammar.rb +0 -536
- data/lib/cldr/data/plurals/rules.rb +0 -113
- data/lib/cldr/data/territories.rb +0 -17
- data/lib/cldr/data/timezones.rb +0 -25
- data/lib/cldr/data/units.rb +0 -25
- data/test/data/plurals_test.rb +0 -132
- data/test/formats/datetime/all.rb +0 -3
- data/test/formats/datetime/date_test.rb +0 -31
- data/test/formats/datetime/datetime_test.rb +0 -18
- data/test/formats/datetime/day_test.rb +0 -41
- data/test/formats/datetime/hour_test.rb +0 -79
- data/test/formats/datetime/minute_test.rb +0 -25
- data/test/formats/datetime/month_test.rb +0 -76
- data/test/formats/datetime/period_test.rb +0 -20
- data/test/formats/datetime/quarter_test.rb +0 -118
- data/test/formats/datetime/second_test.rb +0 -80
- data/test/formats/datetime/time_test.rb +0 -33
- data/test/formats/datetime/timezone_test.rb +0 -23
- data/test/formats/datetime/year_test.rb +0 -57
- data/test/formats/format_test.rb +0 -66
- data/test/formats/rails_compat/all.rb +0 -3
- data/test/formats/rails_compat/format_integer_test.rb +0 -56
- data/test/formats/rails_compat/format_number_test.rb +0 -134
@@ -1,75 +1,75 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__) + '/../../test_helper'))
|
2
2
|
|
3
3
|
class TestCldrDecimalNumberFormat < Test::Unit::TestCase
|
4
|
-
|
4
|
+
test "interpolates a number" do
|
5
5
|
assert_equal '123', Cldr::Format::Decimal::Number.new('###').apply(123)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
test "interpolates a number on the right side" do
|
9
9
|
assert_equal '0123', Cldr::Format::Decimal::Number.new('0###').apply(123)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
test "strips optional digits" do
|
13
13
|
assert_equal '123', Cldr::Format::Decimal::Number.new('######').apply(123)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
test "single group" do
|
17
17
|
assert_equal '1,23', Cldr::Format::Decimal::Number.new('#,##').apply(123)
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
test "multiple groups with a primary group size" do
|
21
21
|
assert_equal '1,23,45,67,89', Cldr::Format::Decimal::Number.new('#,##').apply(123456789)
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
test "multiple groups with a primary and secondary group size" do
|
25
25
|
assert_equal '12,34,56,789', Cldr::Format::Decimal::Number.new('#,##,##0').apply(123456789)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
test "does not group when no digits left of the grouping position" do
|
29
29
|
assert_equal '123', Cldr::Format::Decimal::Number.new('#,###').apply(123)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
test "interpolates a fraction when defined by the format" do
|
33
33
|
assert_equal '123.45', Cldr::Format::Decimal::Number.new('###.##').apply(123.45)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
test "interpolates a fraction when not defined by the format but :precision given" do
|
37
37
|
assert_equal '123.45', Cldr::Format::Decimal::Number.new('###').apply(123.45, :precision => 2)
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
test "rounds a fraction" do
|
41
41
|
assert_equal '123.46', Cldr::Format::Decimal::Number.new('###.##').apply(123.456)
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
test "interpolates fraction on the left side" do
|
45
45
|
assert_equal '123.4500', Cldr::Format::Decimal::Number.new('###.0000#').apply(123.45)
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
test "rounds with precision => 0" do
|
49
49
|
assert_equal '124', Cldr::Format::Decimal::Number.new('###.##').apply(123.55, :precision => 0)
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
test "rounds with precision => 1" do
|
53
53
|
assert_equal '124', Cldr::Format::Decimal::Number.new('###.##').apply(123.55, :precision => 0)
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
test "cldr example #,##0.## => 1 234,57" do
|
57
57
|
assert_equal '1 234,57', Cldr::Format::Decimal::Number.new('#,##0.##', :decimal => ',', :group => ' ').apply(1234.567)
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
test "cldr example #,##0.### => 1 234,567" do
|
61
61
|
assert_equal '1 234,567', Cldr::Format::Decimal::Number.new('#,##0.###', :decimal => ',', :group => ' ').apply(1234.567)
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
test "cldr example ###0.##### => 1234,567" do
|
65
65
|
assert_equal '1234,567', Cldr::Format::Decimal::Number.new('###0.#####', :decimal => ',', :group => ' ').apply(1234.567)
|
66
66
|
end
|
67
67
|
|
68
|
-
|
68
|
+
test "cldr example ###0.0000# => 1234,5670" do
|
69
69
|
assert_equal '1234,5670', Cldr::Format::Decimal::Number.new('###0.0000#', :decimal => ',', :group => ' ').apply(1234.567)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
test "cldr example 00000.0000 => 01234,5670" do
|
73
73
|
assert_equal '01234,5670', Cldr::Format::Decimal::Number.new('00000.0000', :decimal => ',', :group => ' ').apply(1234.567)
|
74
74
|
end
|
75
75
|
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__) + '/../test_helper'))
|
2
2
|
|
3
3
|
class TestCldrDecimalFormat < Test::Unit::TestCase
|
4
|
-
|
4
|
+
test "single pattern, positive number" do
|
5
5
|
assert_equal '123', Cldr::Format::Decimal.new('#').apply(123)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
test "single pattern, negative number" do
|
9
9
|
assert_equal '-123', Cldr::Format::Decimal.new('#').apply(-123)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
test "positive/negative patterns, positive number" do
|
13
13
|
assert_equal '123', Cldr::Format::Decimal.new('#;-#').apply(123)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
test "positive/negative patterns, negative number" do
|
17
17
|
assert_equal '-123', Cldr::Format::Decimal.new('#;-#').apply(-123)
|
18
18
|
end
|
19
19
|
end
|
File without changes
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__) + '/../test_helper'))
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
class TestCldrDateTimeFormat < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@locale = :de
|
9
|
+
@calendar = Cldr::Export::Data::Calendars.new(@locale)[:calendars][:gregorian]
|
10
|
+
end
|
11
|
+
|
12
|
+
def format(object, pattern)
|
13
|
+
Cldr::Format::Time.new(pattern, @calendar).apply(object)
|
14
|
+
end
|
15
|
+
|
16
|
+
# FORMATS
|
17
|
+
|
18
|
+
# Timezone missing
|
19
|
+
#
|
20
|
+
# test "full time pattern :de" do
|
21
|
+
# assert_equal '13:12:11 zzzz', format(Time.local(2000, 1, 1, 13, 12, 11), 'HH:mm:ss zzzz')
|
22
|
+
# end
|
23
|
+
|
24
|
+
test "long time pattern :de" do
|
25
|
+
assert_equal '13:12:11 UTC', format(Time.utc(2010, 1, 1, 13, 12, 11), 'HH:mm:ss z')
|
26
|
+
end
|
27
|
+
|
28
|
+
test "medium time pattern :de" do
|
29
|
+
assert_equal '13:12:11', format(Time.utc(2010, 1, 1, 13, 12, 11), 'HH:mm:ss')
|
30
|
+
end
|
31
|
+
|
32
|
+
test "short time pattern :de" do
|
33
|
+
assert_equal '13:12', format(Time.utc(2010, 1, 1, 13, 12, 11), 'HH:mm')
|
34
|
+
end
|
35
|
+
|
36
|
+
# TIMEZONE
|
37
|
+
|
38
|
+
test "z, zz, zzz" do # TODO is this what's meant by the spec?
|
39
|
+
assert_equal 'CET', format(Time.local(2000, 1, 1, 1, 1, 1), 'z')
|
40
|
+
assert_equal 'CET', format(Time.local(2000, 1, 1, 1, 1, 1), 'zz')
|
41
|
+
assert_equal 'CET', format(Time.local(2000, 1, 1, 1, 1, 1), 'zzz')
|
42
|
+
end
|
43
|
+
|
44
|
+
# PERIOD
|
45
|
+
|
46
|
+
test "period" do
|
47
|
+
assert_equal 'vorm.', format(Time.local(2000, 1, 1, 1, 1, 1), 'a')
|
48
|
+
assert_equal 'nachm.', format(Time.local(2000, 1, 1, 15, 1, 1), 'a')
|
49
|
+
end
|
50
|
+
|
51
|
+
# HOUR
|
52
|
+
|
53
|
+
test "h" do
|
54
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 0, 1, 1), 'h')
|
55
|
+
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 'h')
|
56
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'h')
|
57
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 12, 1, 1), 'h')
|
58
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 23, 1, 1), 'h')
|
59
|
+
end
|
60
|
+
|
61
|
+
test "hh" do
|
62
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 0, 1, 1), 'hh')
|
63
|
+
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'hh')
|
64
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'hh')
|
65
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 12, 1, 1), 'hh')
|
66
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 23, 1, 1), 'hh')
|
67
|
+
end
|
68
|
+
|
69
|
+
test "H" do
|
70
|
+
assert_equal '0', format(Time.local(2000, 1, 1, 0, 1, 1), 'H')
|
71
|
+
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 'H')
|
72
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'H')
|
73
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 12, 1, 1), 'H')
|
74
|
+
assert_equal '23', format(Time.local(2000, 1, 1, 23, 1, 1), 'H')
|
75
|
+
end
|
76
|
+
|
77
|
+
test "HH" do
|
78
|
+
assert_equal '00', format(Time.local(2000, 1, 1, 0, 1, 1), 'HH')
|
79
|
+
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'HH')
|
80
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'HH')
|
81
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 12, 1, 1), 'HH')
|
82
|
+
assert_equal '23', format(Time.local(2000, 1, 1, 23, 1, 1), 'HH')
|
83
|
+
end
|
84
|
+
|
85
|
+
test "K" do
|
86
|
+
assert_equal '0', format(Time.local(2000, 1, 1, 0, 1, 1), 'K')
|
87
|
+
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 'K')
|
88
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'K')
|
89
|
+
assert_equal '0', format(Time.local(2000, 1, 1, 12, 1, 1), 'K')
|
90
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 23, 1, 1), 'K')
|
91
|
+
end
|
92
|
+
|
93
|
+
test "KK" do
|
94
|
+
assert_equal '00', format(Time.local(2000, 1, 1, 0, 1, 1), 'KK')
|
95
|
+
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'KK')
|
96
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'KK')
|
97
|
+
assert_equal '00', format(Time.local(2000, 1, 1, 12, 1, 1), 'KK')
|
98
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 23, 1, 1), 'KK')
|
99
|
+
end
|
100
|
+
|
101
|
+
test "k" do
|
102
|
+
assert_equal '24', format(Time.local(2000, 1, 1, 0, 1, 1), 'k')
|
103
|
+
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 'k')
|
104
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'k')
|
105
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 12, 1, 1), 'k')
|
106
|
+
assert_equal '23', format(Time.local(2000, 1, 1, 23, 1, 1), 'k')
|
107
|
+
end
|
108
|
+
|
109
|
+
test "kk" do
|
110
|
+
assert_equal '24', format(Time.local(2000, 1, 1, 0, 1, 1), 'kk')
|
111
|
+
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'kk')
|
112
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 11, 1, 1), 'kk')
|
113
|
+
assert_equal '12', format(Time.local(2000, 1, 1, 12, 1, 1), 'kk')
|
114
|
+
assert_equal '23', format(Time.local(2000, 1, 1, 23, 1, 1), 'kk')
|
115
|
+
end
|
116
|
+
|
117
|
+
# MINUTE
|
118
|
+
|
119
|
+
test "m" do
|
120
|
+
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 'm')
|
121
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 1, 11, 1), 'm')
|
122
|
+
end
|
123
|
+
|
124
|
+
test "mm" do
|
125
|
+
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'mm')
|
126
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 1, 11, 1), 'mm')
|
127
|
+
end
|
128
|
+
|
129
|
+
# SECOND
|
130
|
+
|
131
|
+
test "s" do
|
132
|
+
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1), 's')
|
133
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 1, 1, 11), 's')
|
134
|
+
end
|
135
|
+
|
136
|
+
test "ss" do
|
137
|
+
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1), 'ss')
|
138
|
+
assert_equal '11', format(Time.local(2000, 1, 1, 1, 1, 11), 'ss')
|
139
|
+
end
|
140
|
+
|
141
|
+
# have i gotten the spec right here?
|
142
|
+
test "S" do
|
143
|
+
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'S')
|
144
|
+
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'S')
|
145
|
+
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'S')
|
146
|
+
assert_equal '0', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'S')
|
147
|
+
assert_equal '1', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'S')
|
148
|
+
assert_equal '8', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'S')
|
149
|
+
end
|
150
|
+
|
151
|
+
test "SS" do
|
152
|
+
assert_equal '00', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SS')
|
153
|
+
assert_equal '00', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SS')
|
154
|
+
assert_equal '00', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SS')
|
155
|
+
assert_equal '01', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SS')
|
156
|
+
assert_equal '08', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SS')
|
157
|
+
assert_equal '78', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SS')
|
158
|
+
end
|
159
|
+
|
160
|
+
test "SSS" do
|
161
|
+
assert_equal '000', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSS')
|
162
|
+
assert_equal '000', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSS')
|
163
|
+
assert_equal '001', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSS')
|
164
|
+
assert_equal '008', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSS')
|
165
|
+
assert_equal '078', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSS')
|
166
|
+
assert_equal '778', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSS')
|
167
|
+
end
|
168
|
+
|
169
|
+
test "SSSS" do
|
170
|
+
assert_equal '0000', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSSS')
|
171
|
+
assert_equal '0001', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSSS')
|
172
|
+
assert_equal '0008', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSSS')
|
173
|
+
assert_equal '0078', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSSS')
|
174
|
+
assert_equal '0778', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSSS')
|
175
|
+
assert_equal '7778', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSSS')
|
176
|
+
end
|
177
|
+
|
178
|
+
test "SSSSS" do
|
179
|
+
assert_equal '00001', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSSSS')
|
180
|
+
assert_equal '00008', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSSSS')
|
181
|
+
assert_equal '00078', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSSSS')
|
182
|
+
assert_equal '00778', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSSSS')
|
183
|
+
assert_equal '07778', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSSSS')
|
184
|
+
assert_equal '77778', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSSSS')
|
185
|
+
end
|
186
|
+
|
187
|
+
test "SSSSSS" do
|
188
|
+
assert_equal '000007', format(Time.local(2000, 1, 1, 1, 1, 1, 7), 'SSSSSS')
|
189
|
+
assert_equal '000077', format(Time.local(2000, 1, 1, 1, 1, 1, 77), 'SSSSSS')
|
190
|
+
assert_equal '000777', format(Time.local(2000, 1, 1, 1, 1, 1, 777), 'SSSSSS')
|
191
|
+
assert_equal '007777', format(Time.local(2000, 1, 1, 1, 1, 1, 7777), 'SSSSSS')
|
192
|
+
assert_equal '077777', format(Time.local(2000, 1, 1, 1, 1, 1, 77777), 'SSSSSS')
|
193
|
+
assert_equal '777777', format(Time.local(2000, 1, 1, 1, 1, 1, 777777), 'SSSSSS')
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
def tests_for(filename)
|
2
|
+
pattern = case filename
|
3
|
+
when %r(gregorian\.rb)
|
4
|
+
"test/export/data/calendars_test.rb"
|
5
|
+
when %r(/base.rb)
|
6
|
+
dir = filename.gsub('/base.rb', '')
|
7
|
+
base = File.basename(dir)
|
8
|
+
dir = File.dirname(dir).gsub(%(lib/cldr), '')
|
9
|
+
"test/#{dir}/{#{base},#{base}/**/*}_test.rb"
|
10
|
+
when %r(lib/cldr/.*\.rb)
|
11
|
+
"test/" + filename.gsub('lib/cldr/', '').gsub(/\.rb/, '_test.rb')
|
12
|
+
when %r(^test/.*_test\.rb)
|
13
|
+
filename
|
14
|
+
end
|
15
|
+
pattern ? Dir[pattern.gsub('//', '/')] : []
|
16
|
+
end
|
17
|
+
|
18
|
+
if $0 == __FILE__
|
19
|
+
require 'test/unit'
|
20
|
+
|
21
|
+
class TestAutotestMatching < Test::Unit::TestCase
|
22
|
+
define_method :"test: default mapping for library files" do
|
23
|
+
assert tests_for("lib/cldr/format/date.rb").all? { |file| file =~ /date_test.rb/ }
|
24
|
+
assert tests_for("lib/cldr/format/decimal/fraction.rb").all? { |file| file =~ /fraction_test.rb/ }
|
25
|
+
assert tests_for("lib/cldr/format/decimal/base.rb").all? { |file| file =~ /decimal/ }
|
26
|
+
end
|
27
|
+
|
28
|
+
define_method :"test: mapping for gregorian.rb" do
|
29
|
+
assert_equal ['test/data/calendars_test.rb'], tests_for("lib/cldr/calendars/gregorian.rb")
|
30
|
+
end
|
31
|
+
|
32
|
+
define_method :"test: default mapping for test files" do
|
33
|
+
assert_equal ["test/export_test.rb"], tests_for("test/export_test.rb")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,4 +2,19 @@ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'cldr'
|
5
|
-
require 'rubygems'
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
class Test::Unit::TestCase
|
8
|
+
def self.test(name, &block)
|
9
|
+
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
10
|
+
defined = instance_method(test_name) rescue false
|
11
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
12
|
+
if block_given?
|
13
|
+
define_method(test_name, &block)
|
14
|
+
else
|
15
|
+
define_method(test_name) do
|
16
|
+
flunk "No implementation provided for #{name}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,82 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-cldr
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Sven Fuchs
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
date: 2012-08-01 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: &70146354889260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70146354889260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: i18n
|
27
|
+
requirement: &70146354888620 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70146354888620
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: ya2yaml
|
38
|
+
requirement: &70146354887760 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70146354887760
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: &70146354886960 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70146354886960
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &70146354886240 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70146354886240
|
16
69
|
description: Ruby library for exporting and using data from CLDR, see http://cldr.unicode.org
|
17
70
|
email: svenfuchs@artweb-design.de
|
18
71
|
executables: []
|
19
|
-
|
20
72
|
extensions: []
|
21
|
-
|
22
|
-
extra_rdoc_files:
|
73
|
+
extra_rdoc_files:
|
23
74
|
- LICENSE
|
24
75
|
- README.textile
|
25
76
|
- TODO
|
26
|
-
files:
|
77
|
+
files:
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
27
80
|
- LICENSE
|
28
81
|
- README.textile
|
29
82
|
- Rakefile
|
@@ -32,22 +85,25 @@ files:
|
|
32
85
|
- cldr.thor
|
33
86
|
- lib/cldr.rb
|
34
87
|
- lib/cldr/data.rb
|
35
|
-
- lib/cldr/data/base.rb
|
36
|
-
- lib/cldr/data/calendars.rb
|
37
|
-
- lib/cldr/data/calendars/gregorian.rb
|
38
|
-
- lib/cldr/data/currencies.rb
|
39
|
-
- lib/cldr/data/delimiters.rb
|
40
|
-
- lib/cldr/data/languages.rb
|
41
|
-
- lib/cldr/data/numbers.rb
|
42
|
-
- lib/cldr/data/plurals.rb
|
43
|
-
- lib/cldr/data/plurals/cldr_grammar.treetop
|
44
|
-
- lib/cldr/data/plurals/grammar.rb
|
45
|
-
- lib/cldr/data/plurals/rules.rb
|
46
|
-
- lib/cldr/data/territories.rb
|
47
|
-
- lib/cldr/data/timezones.rb
|
48
|
-
- lib/cldr/data/units.rb
|
49
88
|
- lib/cldr/download.rb
|
50
89
|
- lib/cldr/export.rb
|
90
|
+
- lib/cldr/export/code.rb
|
91
|
+
- lib/cldr/export/code/numbers.rb
|
92
|
+
- lib/cldr/export/data.rb
|
93
|
+
- lib/cldr/export/data/base.rb
|
94
|
+
- lib/cldr/export/data/calendars.rb
|
95
|
+
- lib/cldr/export/data/calendars/gregorian.rb
|
96
|
+
- lib/cldr/export/data/currencies.rb
|
97
|
+
- lib/cldr/export/data/delimiters.rb
|
98
|
+
- lib/cldr/export/data/languages.rb
|
99
|
+
- lib/cldr/export/data/numbers.rb
|
100
|
+
- lib/cldr/export/data/plurals.rb
|
101
|
+
- lib/cldr/export/data/plurals/cldr_grammar.treetop
|
102
|
+
- lib/cldr/export/data/plurals/grammar.rb
|
103
|
+
- lib/cldr/export/data/plurals/rules.rb
|
104
|
+
- lib/cldr/export/data/territories.rb
|
105
|
+
- lib/cldr/export/data/timezones.rb
|
106
|
+
- lib/cldr/export/data/units.rb
|
51
107
|
- lib/cldr/export/ruby.rb
|
52
108
|
- lib/cldr/export/yaml.rb
|
53
109
|
- lib/cldr/format.rb
|
@@ -69,101 +125,55 @@ files:
|
|
69
125
|
- lib/core_ext/string/camelize.rb
|
70
126
|
- lib/core_ext/string/underscore.rb
|
71
127
|
- test/all.rb
|
72
|
-
- test/
|
73
|
-
- test/data/
|
74
|
-
- test/data/
|
75
|
-
- test/data/
|
76
|
-
- test/data/
|
77
|
-
- test/data/
|
78
|
-
- test/data/
|
79
|
-
- test/data/
|
80
|
-
- test/data/
|
81
|
-
- test/data/
|
128
|
+
- test/export/code/numbers_test.rb
|
129
|
+
- test/export/data/all.rb
|
130
|
+
- test/export/data/calendars_test.rb
|
131
|
+
- test/export/data/currencies_test.rb
|
132
|
+
- test/export/data/delimiters_test.rb
|
133
|
+
- test/export/data/languages_test.rb
|
134
|
+
- test/export/data/numbers_test.rb
|
135
|
+
- test/export/data/plurals_test.rb
|
136
|
+
- test/export/data/territories_test.rb
|
137
|
+
- test/export/data/timezones_test.rb
|
138
|
+
- test/export/data/units_test.rb
|
82
139
|
- test/export_test.rb
|
83
|
-
- test/
|
84
|
-
- test/
|
85
|
-
- test/
|
86
|
-
- test/
|
87
|
-
- test/
|
88
|
-
- test/
|
89
|
-
- test/
|
90
|
-
- test/
|
91
|
-
- test/
|
92
|
-
- test/
|
93
|
-
- test/
|
94
|
-
- test/formats/datetime/time_test.rb
|
95
|
-
- test/formats/datetime/timezone_test.rb
|
96
|
-
- test/formats/datetime/year_test.rb
|
97
|
-
- test/formats/decimal/fraction_test.rb
|
98
|
-
- test/formats/decimal/integer_test.rb
|
99
|
-
- test/formats/decimal/number_test.rb
|
100
|
-
- test/formats/decimal_test.rb
|
101
|
-
- test/formats/format_test.rb
|
102
|
-
- test/formats/rails_compat/all.rb
|
103
|
-
- test/formats/rails_compat/format_integer_test.rb
|
104
|
-
- test/formats/rails_compat/format_number_test.rb
|
140
|
+
- test/format/all.rb
|
141
|
+
- test/format/currency_test.rb
|
142
|
+
- test/format/date_test.rb
|
143
|
+
- test/format/datetime_test.rb
|
144
|
+
- test/format/decimal/fraction_test.rb
|
145
|
+
- test/format/decimal/integer_test.rb
|
146
|
+
- test/format/decimal/number_test.rb
|
147
|
+
- test/format/decimal_test.rb
|
148
|
+
- test/format/percent_test.rb
|
149
|
+
- test/format/time_test.rb
|
150
|
+
- test/test_autotest.rb
|
105
151
|
- test/test_helper.rb
|
106
|
-
has_rdoc: true
|
107
152
|
homepage: http://github.com/svenfuchs/ruby-cldr
|
108
153
|
licenses: []
|
109
|
-
|
110
154
|
post_install_message:
|
111
|
-
rdoc_options:
|
112
|
-
|
113
|
-
require_paths:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
114
157
|
- lib
|
115
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
hash: 1186465596136012030
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
127
173
|
requirements: []
|
128
|
-
|
129
174
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.
|
175
|
+
rubygems_version: 1.8.6
|
131
176
|
signing_key:
|
132
177
|
specification_version: 3
|
133
178
|
summary: Ruby library for exporting and using data from CLDR
|
134
|
-
test_files:
|
135
|
-
- test/all.rb
|
136
|
-
- test/data/all.rb
|
137
|
-
- test/data/calendars_test.rb
|
138
|
-
- test/data/currencies_test.rb
|
139
|
-
- test/data/delimiters_test.rb
|
140
|
-
- test/data/languages_test.rb
|
141
|
-
- test/data/numbers_test.rb
|
142
|
-
- test/data/plurals_test.rb
|
143
|
-
- test/data/territories_test.rb
|
144
|
-
- test/data/timezones_test.rb
|
145
|
-
- test/data/units_test.rb
|
146
|
-
- test/export_test.rb
|
147
|
-
- test/formats/all.rb
|
148
|
-
- test/formats/datetime/all.rb
|
149
|
-
- test/formats/datetime/date_test.rb
|
150
|
-
- test/formats/datetime/datetime_test.rb
|
151
|
-
- test/formats/datetime/day_test.rb
|
152
|
-
- test/formats/datetime/hour_test.rb
|
153
|
-
- test/formats/datetime/minute_test.rb
|
154
|
-
- test/formats/datetime/month_test.rb
|
155
|
-
- test/formats/datetime/period_test.rb
|
156
|
-
- test/formats/datetime/quarter_test.rb
|
157
|
-
- test/formats/datetime/second_test.rb
|
158
|
-
- test/formats/datetime/time_test.rb
|
159
|
-
- test/formats/datetime/timezone_test.rb
|
160
|
-
- test/formats/datetime/year_test.rb
|
161
|
-
- test/formats/decimal/fraction_test.rb
|
162
|
-
- test/formats/decimal/integer_test.rb
|
163
|
-
- test/formats/decimal/number_test.rb
|
164
|
-
- test/formats/decimal_test.rb
|
165
|
-
- test/formats/format_test.rb
|
166
|
-
- test/formats/rails_compat/all.rb
|
167
|
-
- test/formats/rails_compat/format_integer_test.rb
|
168
|
-
- test/formats/rails_compat/format_number_test.rb
|
169
|
-
- test/test_helper.rb
|
179
|
+
test_files: []
|