twitter_cldr 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/History.txt +6 -0
  2. data/README.md +61 -5
  3. data/Rakefile +64 -60
  4. data/js/lib/twitter_cldr_js.rb +0 -2
  5. data/lib/twitter_cldr/core_ext.rb +12 -12
  6. data/lib/twitter_cldr/formatters/calendars/timespan_formatter.rb +13 -11
  7. data/lib/twitter_cldr/localized/localized_array.rb +33 -0
  8. data/lib/twitter_cldr/localized/localized_date.rb +23 -0
  9. data/lib/twitter_cldr/localized/localized_datetime.rb +63 -0
  10. data/lib/twitter_cldr/localized/localized_number.rb +50 -0
  11. data/lib/twitter_cldr/localized/localized_object.rb +38 -0
  12. data/lib/twitter_cldr/localized/localized_string.rb +41 -0
  13. data/lib/twitter_cldr/localized/localized_symbol.rb +20 -0
  14. data/lib/twitter_cldr/localized/localized_time.rb +23 -0
  15. data/lib/twitter_cldr/localized/localized_timespan.rb +26 -0
  16. data/lib/twitter_cldr/localized.rb +18 -0
  17. data/lib/twitter_cldr/normalization.rb +23 -0
  18. data/lib/twitter_cldr/resources/{tries_dumper.rb → collation_tries_dumper.rb} +1 -1
  19. data/lib/twitter_cldr/resources/composition_exclusions_importer.rb +1 -1
  20. data/lib/twitter_cldr/resources/language_codes_importer.rb +232 -0
  21. data/lib/twitter_cldr/resources/locales_resources_importer.rb +1 -1
  22. data/lib/twitter_cldr/resources/phone_codes_importer.rb +1 -1
  23. data/lib/twitter_cldr/resources/postal_codes_importer.rb +1 -1
  24. data/lib/twitter_cldr/resources/tailoring_importer.rb +12 -3
  25. data/lib/twitter_cldr/resources/unicode_data_importer.rb +3 -1
  26. data/lib/twitter_cldr/resources.rb +2 -1
  27. data/lib/twitter_cldr/shared/calendar.rb +2 -6
  28. data/lib/twitter_cldr/shared/language_codes.rb +75 -0
  29. data/lib/twitter_cldr/shared/languages.rb +4 -11
  30. data/lib/twitter_cldr/shared.rb +8 -7
  31. data/lib/twitter_cldr/tokenizers/base.rb +2 -8
  32. data/lib/twitter_cldr/utils.rb +8 -0
  33. data/lib/twitter_cldr/version.rb +1 -1
  34. data/lib/twitter_cldr.rb +5 -4
  35. data/resources/custom/locales/cs/units.yml +3 -3
  36. data/resources/custom/locales/pl/units.yml +4 -4
  37. data/resources/custom/locales/pt/units.yml +2 -2
  38. data/resources/shared/language_codes_table.dump +0 -0
  39. data/spec/core_ext_spec.rb +19 -0
  40. data/spec/{core_ext/array_spec.rb → localized/localized_array_spec.rb} +1 -1
  41. data/spec/{core_ext/calendars/date_spec.rb → localized/localized_date_spec.rb} +24 -44
  42. data/spec/localized/localized_datetime_spec.rb +81 -0
  43. data/spec/{core_ext/numbers → localized}/localized_number_spec.rb +34 -1
  44. data/spec/localized/localized_object_spec.rb +89 -0
  45. data/spec/{core_ext/string_spec.rb → localized/localized_string_spec.rb} +16 -33
  46. data/spec/{core_ext/symbol_spec.rb → localized/localized_symbol_spec.rb} +3 -1
  47. data/spec/localized/localized_time_spec.rb +70 -0
  48. data/spec/normalization_spec.rb +42 -0
  49. data/spec/readme_spec.rb +51 -5
  50. data/spec/shared/language_codes_spec.rb +161 -0
  51. data/spec/shared/phone_codes_spec.rb +2 -2
  52. data/spec/shared/postal_codes_spec.rb +2 -2
  53. data/spec/spec_helper.rb +2 -0
  54. data/spec/tokenizers/base_spec.rb +15 -6
  55. data/spec/utils_spec.rb +18 -2
  56. data/twitter_cldr.gemspec +2 -1
  57. metadata +28 -44
  58. data/lib/twitter_cldr/core_ext/array.rb +0 -35
  59. data/lib/twitter_cldr/core_ext/calendars/date.rb +0 -25
  60. data/lib/twitter_cldr/core_ext/calendars/datetime.rb +0 -65
  61. data/lib/twitter_cldr/core_ext/calendars/time.rb +0 -25
  62. data/lib/twitter_cldr/core_ext/calendars/timespan.rb +0 -24
  63. data/lib/twitter_cldr/core_ext/localized_object.rb +0 -25
  64. data/lib/twitter_cldr/core_ext/numbers/bignum.rb +0 -8
  65. data/lib/twitter_cldr/core_ext/numbers/fixnum.rb +0 -8
  66. data/lib/twitter_cldr/core_ext/numbers/float.rb +0 -8
  67. data/lib/twitter_cldr/core_ext/numbers/localized_number.rb +0 -54
  68. data/lib/twitter_cldr/core_ext/string.rb +0 -51
  69. data/lib/twitter_cldr/core_ext/symbol.rb +0 -22
  70. data/spec/core_ext/calendars/datetime_spec.rb +0 -90
  71. data/spec/core_ext/calendars/time_spec.rb +0 -90
  72. data/spec/core_ext/calendars_spec.rb +0 -34
  73. data/spec/core_ext/numbers/bignum_spec.rb +0 -25
  74. data/spec/core_ext/numbers/fixnum_spec.rb +0 -25
  75. data/spec/core_ext/numbers/float_spec.rb +0 -25
  76. data/spec/core_ext/numbers_spec.rb +0 -39
@@ -1,90 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Copyright 2012 Twitter, Inc
4
- # http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- require 'spec_helper'
7
-
8
- include TwitterCldr
9
-
10
- describe Time do
11
- describe "#localize" do
12
- let (:time) { Time.now }
13
-
14
- it "should localize with the given locale, English by default" do
15
- loc_time = time.localize
16
- loc_time.should be_a(LocalizedTime)
17
- loc_time.locale.should == :en
18
- loc_time.calendar_type.should == :gregorian
19
- loc_time.base_obj.should == time
20
-
21
- loc_time = Time.now.localize(:it)
22
- loc_time.should be_a(LocalizedTime)
23
- loc_time.locale.should == :it
24
- end
25
-
26
- it "should localize with the given calendar" do
27
- loc_time = time.localize(:th, :calendar_type => :buddhist)
28
- loc_time.should be_a(LocalizedTime)
29
- loc_time.locale.should == :th
30
- loc_time.calendar_type.should == :buddhist
31
- loc_time.base_obj.should == time
32
- end
33
-
34
- it "should forward calendar_type" do
35
- loc_time = time.localize(:th, :calendar_type => :buddhist)
36
- loc_time.to_datetime(Date.today).calendar_type.should == :buddhist
37
- end
38
- end
39
-
40
- describe "stringify" do
41
- it "should stringify with a default calendar" do
42
- #Time.now.localize(:th, :calendar_type => :buddhist).to_full_s # It doesn't support era
43
- Time.now.localize(:th).to_long_s
44
- Time.now.localize(:th).to_medium_s
45
- Time.now.localize(:th).to_short_s
46
- end
47
-
48
- it "should stringify with buddhist calendar" do
49
- # Ensure that buddhist calendar data is present in th locale.
50
- TwitterCldr.get_locale_resource(:th, :calendars)[:th][:calendars][:buddhist].should_not(
51
- be_nil, 'buddhist calendar is missing for :th locale (check resources/locales/th/calendars.yml)'
52
- )
53
-
54
- #Time.now.localize(:th, :calendar_type => :buddhist).to_full_s # It doesn't support era
55
- Time.now.localize(:th, :calendar_type => :buddhist).to_long_s
56
- Time.now.localize(:th, :calendar_type => :buddhist).to_medium_s
57
- Time.now.localize(:th, :calendar_type => :buddhist).to_short_s
58
- end
59
- end
60
- end
61
-
62
- describe "#ago" do
63
- it "should ago-ify a time with a number of different units" do
64
- time = Time.now
65
- base_time = time + 172800
66
- loc_time = time.localize(:de)
67
- loc_time.ago(:base_time => base_time).to_s(:unit => :hour).should match_normalized("Vor 48 Stunden")
68
- loc_time.ago(:base_time => base_time).to_s(:unit => :day).should match_normalized("Vor 2 Tagen")
69
- end
70
- end
71
-
72
- describe LocalizedTime do
73
- describe "#to_datetime" do
74
- it "should combine a date and a time object into a datetime" do
75
- date = Date.new(1987, 9, 20)
76
- time = Time.local(2000, 5, 12, 22, 5)
77
- datetime = time.localize.to_datetime(date)
78
- datetime.should be_a(LocalizedDateTime)
79
- datetime.base_obj.strftime("%Y-%m-%d %H:%M:%S").should == "1987-09-20 22:05:00"
80
- end
81
-
82
- it "should work with an instance of LocalizedDate too" do
83
- date = Date.new(1987, 9, 20).localize
84
- time = Time.local(2000, 5, 12, 22, 5)
85
- datetime = time.localize.to_datetime(date)
86
- datetime.should be_a(LocalizedDateTime)
87
- datetime.base_obj.strftime("%Y-%m-%d %H:%M:%S").should == "1987-09-20 22:05:00"
88
- end
89
- end
90
- end
@@ -1,34 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Copyright 2012 Twitter, Inc
4
- # http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- require 'spec_helper'
7
-
8
- include TwitterCldr::Tokenizers
9
-
10
- describe "Calendars" do
11
- it "makes sure datetime formatters for every locale don't raise errors" do
12
- TwitterCldr.supported_locales.each do |locale|
13
- DateTimeTokenizer::VALID_TYPES.each do |type|
14
- lambda { DateTime.now.localize(locale).send(:"to_#{type}_s") }.should_not raise_error
15
- end
16
- end
17
- end
18
-
19
- it "makes sure date formatters for every locale don't raise errors" do
20
- TwitterCldr.supported_locales.each do |locale|
21
- DateTimeTokenizer::VALID_TYPES.each do |type|
22
- lambda { Date.today.localize(locale).send(:"to_#{type}_s") }.should_not raise_error
23
- end
24
- end
25
- end
26
-
27
- it "makes sure time formatters for every locale don't raise errors" do
28
- TwitterCldr.supported_locales.each do |locale|
29
- DateTimeTokenizer::VALID_TYPES.each do |type|
30
- lambda { Time.now.localize(locale).send(:"to_#{type}_s") }.should_not raise_error
31
- end
32
- end
33
- end
34
- end
@@ -1,25 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Copyright 2012 Twitter, Inc
4
- # http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- require 'spec_helper'
7
-
8
- include TwitterCldr
9
-
10
- describe Bignum do
11
- describe "#localize" do
12
- it "should localize with the given locale, English by default" do
13
- num = 9719791287349172340823094829
14
- num.should be_a(Bignum)
15
- loc_num = num.localize
16
- loc_num.should be_a(LocalizedNumber)
17
- loc_num.locale.should == :en
18
- loc_num.base_obj.should == num
19
-
20
- loc_num = num.localize(:it)
21
- loc_num.should be_a(LocalizedNumber)
22
- loc_num.locale.should == :it
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Copyright 2012 Twitter, Inc
4
- # http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- require 'spec_helper'
7
-
8
- include TwitterCldr
9
-
10
- describe Fixnum do
11
- describe "#localize" do
12
- it "should localize with the given locale, English by default" do
13
- num = 1337
14
- num.should be_a(Fixnum)
15
- loc_num = num.localize
16
- loc_num.should be_a(LocalizedNumber)
17
- loc_num.locale.should == :en
18
- loc_num.base_obj.should == num
19
-
20
- loc_num = num.localize(:it)
21
- loc_num.should be_a(LocalizedNumber)
22
- loc_num.locale.should == :it
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Copyright 2012 Twitter, Inc
4
- # http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- require 'spec_helper'
7
-
8
- include TwitterCldr
9
-
10
- describe Float do
11
- describe "#localize" do
12
- it "should localize with the given locale, English by default" do
13
- num = 1337.8
14
- num.should be_a(Float)
15
- loc_num = num.localize
16
- loc_num.should be_a(LocalizedNumber)
17
- loc_num.locale.should == :en
18
- loc_num.base_obj.should == num
19
-
20
- loc_num = num.localize(:it)
21
- loc_num.should be_a(LocalizedNumber)
22
- loc_num.locale.should == :it
23
- end
24
- end
25
- end
@@ -1,39 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Copyright 2012 Twitter, Inc
4
- # http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- require 'spec_helper'
7
-
8
- include TwitterCldr
9
-
10
- describe "Numbers" do
11
- it "makes sure currency formatters for every locale don't raise errors" do
12
- TwitterCldr.supported_locales.each do |locale|
13
- lambda { 1337.localize(locale).to_currency.to_s }.should_not raise_error
14
- lambda { 1337.localize(locale).to_currency.to_s(:precision => 3) }.should_not raise_error
15
- lambda { 1337.localize(locale).to_currency.to_s(:precision => 3, :currency => "EUR") }.should_not raise_error
16
- end
17
- end
18
-
19
- it "makes sure decimal formatters for every locale don't raise errors" do
20
- TwitterCldr.supported_locales.each do |locale|
21
- lambda { 1337.localize(locale).to_decimal.to_s }.should_not raise_error
22
- lambda { 1337.localize(locale).to_decimal.to_s(:precision => 3) }.should_not raise_error
23
- end
24
- end
25
-
26
- it "makes sure percentage formatters for every locale don't raise errors" do
27
- TwitterCldr.supported_locales.each do |locale|
28
- lambda { 1337.localize(locale).to_percent.to_s }.should_not raise_error
29
- lambda { 1337.localize(locale).to_percent.to_s(:precision => 3) }.should_not raise_error
30
- end
31
- end
32
-
33
- it "makes sure basic number formatters for every locale don't raise errors" do
34
- TwitterCldr.supported_locales.each do |locale|
35
- lambda { 1337.localize(locale).to_s }.should_not raise_error
36
- lambda { 1337.localize(locale).to_s(:precision => 3) }.should_not raise_error
37
- end
38
- end
39
- end