ruby-cldr 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2730108a5324c951320fd218ac7c4be0bbfb0f98fd0640c40ac45cd3c9c1bc8
4
- data.tar.gz: f3f218f3e52903be3bc9f7e46d1a9406e995a03fbc56c413dadf47b668799215
3
+ metadata.gz: bb38e30dfe8504c39a6d42b6cce5ad833b36f4f8ead5372187302e7a458c4a44
4
+ data.tar.gz: e68125a9223246cbaf2b9f9f702dad54cb86453fd48dae044c018cb9f7516e4f
5
5
  SHA512:
6
- metadata.gz: c9928d8c1f33e5c8e651492cf8b801e6fd642e6a4c1913268f8ac976dbe4185e23d4e1e7662c0a3e81ab7eabbbc603bd1cf9db727d6e278fe18e5119faeb58e5
7
- data.tar.gz: c2a868e0af577e0fe61550daa773f8a13ee2cb92f71307ac761eb7b1b2ba0eea626423d811897c5de00cd16b19532693544bf4f35e797971ca8b156a8cd8ba60
6
+ metadata.gz: a7429066a453c2929db798149aa0e691788286f900bcd8249f46c569932649d4ca595a5e07b92f007ac022a94b8d21d57711a150cd33e60aa412546f61e9e34a
7
+ data.tar.gz: 8360156badeada8c54955b010770c6462db89b141246c718c0ca25f6a56d1c669e268cf72d2504fefda7e724ee28af17e8d2aea62e92dfef955bf9efb7299236
@@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
27
27
  - Added Travis CI for testing, [#48](https://github.com/ruby-i18n/ruby-cldr/pull/48)
28
28
  - Added root fallback to en language, [#47](https://github.com/ruby-i18n/ruby-cldr/pull/47)
29
29
  - Added subdivisions to the list of exportable components, [#46](https://github.com/ruby-i18n/ruby-cldr/pull/46)
30
+ - Added country codes as an exportable component, [#61](https://github.com/ruby-i18n/ruby-cldr/pull/61)
30
31
 
31
32
  ---
32
33
 
@@ -41,4 +42,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
41
42
  - Bring back root fallback for english [#47](https://github.com/ruby-i18n/ruby-cldr/pull/47)
42
43
  - Export subdivisions [#46](https://github.com/ruby-i18n/ruby-cldr/pull/46)
43
44
 
44
- [Unreleased]: https://github.com/ruby-i18n/ruby-cldr/compare/v0.3.0...HEAD
45
+ ## [0.4.0] - 2020-09-01
46
+
47
+ - Support pluralization codes with missing spaces [#53](https://github.com/ruby-i18n/ruby-cldr/pull/53)
48
+ - Add in functionality to export country codes [#61](https://github.com/ruby-i18n/ruby-cldr/pull/61)
49
+
50
+ [Unreleased]: https://github.com/ruby-i18n/ruby-cldr/compare/v0.4.0...HEAD
@@ -39,7 +39,7 @@ GEM
39
39
  multi_json (1.13.1)
40
40
  multi_xml (0.6.0)
41
41
  multipart-post (2.0.0)
42
- nokogiri (1.10.1)
42
+ nokogiri (1.10.8)
43
43
  mini_portile2 (~> 2.4.0)
44
44
  oauth2 (1.4.1)
45
45
  faraday (>= 0.8, < 0.16.0)
@@ -55,10 +55,10 @@ GEM
55
55
  pry-nav (0.2.4)
56
56
  pry (>= 0.9.10, < 0.11.0)
57
57
  psych (3.1.0)
58
- rack (2.0.6)
59
- rake (12.3.2)
58
+ rack (2.2.3)
59
+ rake (13.0.1)
60
60
  rdoc (6.1.1)
61
- rubyzip (1.2.2)
61
+ rubyzip (1.3.0)
62
62
  semver2 (3.4.2)
63
63
  slop (3.6.0)
64
64
  test-unit (3.3.0)
@@ -68,7 +68,6 @@ GEM
68
68
 
69
69
  PLATFORMS
70
70
  ruby
71
- x86_64-darwin-17
72
71
 
73
72
  DEPENDENCIES
74
73
  i18n
@@ -81,4 +80,4 @@ DEPENDENCIES
81
80
  thor
82
81
 
83
82
  BUNDLED WITH
84
- 2.0.2
83
+ 2.1.4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -14,6 +14,7 @@ module Cldr
14
14
  autoload :Yaml, 'cldr/export/yaml'
15
15
 
16
16
  SHARED_COMPONENTS = %w[
17
+ CountryCodes
17
18
  CurrencyDigitsAndRounding
18
19
  Metazones
19
20
  NumberingSystems
@@ -7,6 +7,7 @@ module Cldr
7
7
  autoload :Base, 'cldr/export/data/base'
8
8
  autoload :Calendars, 'cldr/export/data/calendars'
9
9
  autoload :Characters, 'cldr/export/data/characters'
10
+ autoload :CountryCodes, 'cldr/export/data/country_codes'
10
11
  autoload :Currencies, 'cldr/export/data/currencies'
11
12
  autoload :CurrencyDigitsAndRounding, 'cldr/export/data/currency_digits_and_rounding'
12
13
  autoload :Delimiters, 'cldr/export/data/delimiters'
@@ -0,0 +1,29 @@
1
+ module Cldr
2
+ module Export
3
+ module Data
4
+ class CountryCodes < Base
5
+ def initialize
6
+ super(nil)
7
+ update(:country_codes => country_codes)
8
+ end
9
+
10
+ private
11
+
12
+ def country_codes
13
+ doc.xpath("//codeMappings/*").each_with_object({}) do |node, hash|
14
+ if node.name == "territoryCodes"
15
+ type = node.attribute('type').to_s.to_sym
16
+ hash[type] = {}
17
+ hash[type]["numeric"] = node[:numeric] if node[:numeric]
18
+ hash[type]["alpha3"] = node[:alpha3] if node[:alpha3]
19
+ end
20
+ end
21
+ end
22
+
23
+ def path
24
+ @path ||= "#{Cldr::Export::Data.dir}/supplemental/supplementalData.xml"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -57,6 +57,8 @@ module Cldr
57
57
  end
58
58
 
59
59
  def parse(code)
60
+ code = scrub_code(code)
61
+
60
62
  code = code.split('@').first.to_s
61
63
  operand = /(n|i|f|t|v|w)/i
62
64
  expr = /#{operand}(?:\s+(?:mod|%)\s+([\d]+))?/i
@@ -78,6 +80,15 @@ module Cldr
78
80
  raise "can not parse '#{code}'"
79
81
  end
80
82
  end
83
+
84
+ private
85
+
86
+ def scrub_code(code)
87
+ code
88
+ .gsub(/(n)%(\d+)/, '\1 % \2') # n%1000 -> n % 1000
89
+ .gsub(/(\d+)=(\d+)/, '\1 = \2') # 10=100-> 10 = 100
90
+ .gsub(/(n)!=(\d+)/, '\1 != \2') # n!=100 -> n != 100
91
+ end
81
92
  end
82
93
 
83
94
  attr_reader :locales
@@ -199,4 +210,4 @@ module Cldr
199
210
  end
200
211
  end
201
212
  end
202
- end
213
+ end
@@ -0,0 +1,157 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: ruby-cldr 0.2.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "ruby-cldr".freeze
9
+ s.version = "0.4.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Sven Fuchs".freeze]
14
+ s.date = "2019-03-21"
15
+ s.description = "Ruby library for exporting and using data from CLDR, see http://cldr.unicode.org".freeze
16
+ s.email = "svenfuchs@artweb-design.de".freeze
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.textile",
20
+ "TODO"
21
+ ]
22
+ s.files = [
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE",
26
+ "README.textile",
27
+ "Rakefile",
28
+ "TODO",
29
+ "VERSION",
30
+ "cldr.thor",
31
+ "lib/cldr.rb",
32
+ "lib/cldr/data.rb",
33
+ "lib/cldr/download.rb",
34
+ "lib/cldr/export.rb",
35
+ "lib/cldr/export/code.rb",
36
+ "lib/cldr/export/code/numbers.rb",
37
+ "lib/cldr/export/data.rb",
38
+ "lib/cldr/export/data/aliases.rb",
39
+ "lib/cldr/export/data/base.rb",
40
+ "lib/cldr/export/data/calendars.rb",
41
+ "lib/cldr/export/data/calendars/gregorian.rb",
42
+ "lib/cldr/export/data/characters.rb",
43
+ "lib/cldr/export/data/currencies.rb",
44
+ "lib/cldr/export/data/currency_digits_and_rounding.rb",
45
+ "lib/cldr/export/data/delimiters.rb",
46
+ "lib/cldr/export/data/fields.rb",
47
+ "lib/cldr/export/data/languages.rb",
48
+ "lib/cldr/export/data/layout.rb",
49
+ "lib/cldr/export/data/likely_subtags.rb",
50
+ "lib/cldr/export/data/lists.rb",
51
+ "lib/cldr/export/data/metazones.rb",
52
+ "lib/cldr/export/data/numbering_systems.rb",
53
+ "lib/cldr/export/data/numbers.rb",
54
+ "lib/cldr/export/data/parent_locales.rb",
55
+ "lib/cldr/export/data/plural_rules.rb",
56
+ "lib/cldr/export/data/plurals.rb",
57
+ "lib/cldr/export/data/plurals/cldr_grammar.treetop",
58
+ "lib/cldr/export/data/plurals/grammar.rb",
59
+ "lib/cldr/export/data/plurals/rules.rb",
60
+ "lib/cldr/export/data/rbnf.rb",
61
+ "lib/cldr/export/data/rbnf_root.rb",
62
+ "lib/cldr/export/data/region_currencies.rb",
63
+ "lib/cldr/export/data/segments_root.rb",
64
+ "lib/cldr/export/data/territories.rb",
65
+ "lib/cldr/export/data/territories_containment.rb",
66
+ "lib/cldr/export/data/timezones.rb",
67
+ "lib/cldr/export/data/transforms.rb",
68
+ "lib/cldr/export/data/units.rb",
69
+ "lib/cldr/export/data/variables.rb",
70
+ "lib/cldr/export/data/windows_zones.rb",
71
+ "lib/cldr/export/ruby.rb",
72
+ "lib/cldr/export/yaml.rb",
73
+ "lib/cldr/format.rb",
74
+ "lib/cldr/format/currency.rb",
75
+ "lib/cldr/format/date.rb",
76
+ "lib/cldr/format/datetime.rb",
77
+ "lib/cldr/format/datetime/base.rb",
78
+ "lib/cldr/format/decimal.rb",
79
+ "lib/cldr/format/decimal/base.rb",
80
+ "lib/cldr/format/decimal/fraction.rb",
81
+ "lib/cldr/format/decimal/integer.rb",
82
+ "lib/cldr/format/decimal/number.rb",
83
+ "lib/cldr/format/percent.rb",
84
+ "lib/cldr/format/time.rb",
85
+ "lib/cldr/thor.rb",
86
+ "lib/core_ext/hash/deep_merge.rb",
87
+ "lib/core_ext/hash/deep_stringify_keys.rb",
88
+ "lib/core_ext/hash/symbolize_keys.rb",
89
+ "lib/core_ext/string/camelize.rb",
90
+ "lib/core_ext/string/underscore.rb",
91
+ "test/all.rb",
92
+ "test/export/code/numbers_test.rb",
93
+ "test/export/data/all.rb",
94
+ "test/export/data/calendars_test.rb",
95
+ "test/export/data/currencies_test.rb",
96
+ "test/export/data/delimiters_test.rb",
97
+ "test/export/data/languages_test.rb",
98
+ "test/export/data/metazones_test.rb",
99
+ "test/export/data/numbers_test.rb",
100
+ "test/export/data/plurals_test.rb",
101
+ "test/export/data/territories_containment_test.rb",
102
+ "test/export/data/territories_test.rb",
103
+ "test/export/data/timezones_test.rb",
104
+ "test/export/data/units_test.rb",
105
+ "test/export/data/windows_zones_test.rb",
106
+ "test/export_test.rb",
107
+ "test/format/all.rb",
108
+ "test/format/currency_test.rb",
109
+ "test/format/date_test.rb",
110
+ "test/format/datetime_test.rb",
111
+ "test/format/decimal/fraction_test.rb",
112
+ "test/format/decimal/integer_test.rb",
113
+ "test/format/decimal/number_test.rb",
114
+ "test/format/decimal_test.rb",
115
+ "test/format/percent_test.rb",
116
+ "test/format/time_test.rb",
117
+ "test/test_autotest.rb",
118
+ "test/test_helper.rb"
119
+ ]
120
+ s.homepage = "http://github.com/ruby-i18n/ruby-cldr".freeze
121
+ s.rubygems_version = "2.7.9".freeze
122
+ s.summary = "Ruby library for exporting and using data from CLDR".freeze
123
+
124
+ if s.respond_to? :specification_version then
125
+ s.specification_version = 4
126
+
127
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
128
+ s.add_runtime_dependency(%q<thor>.freeze, [">= 0"])
129
+ s.add_runtime_dependency(%q<i18n>.freeze, [">= 0"])
130
+ s.add_runtime_dependency(%q<nokogiri>.freeze, [">= 0"])
131
+ s.add_development_dependency(%q<rubyzip>.freeze, [">= 0"])
132
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
133
+ s.add_development_dependency(%q<pry>.freeze, [">= 0"])
134
+ s.add_development_dependency(%q<pry-nav>.freeze, [">= 0"])
135
+ s.add_development_dependency(%q<test-unit>.freeze, [">= 0"])
136
+ else
137
+ s.add_dependency(%q<thor>.freeze, [">= 0"])
138
+ s.add_dependency(%q<i18n>.freeze, [">= 0"])
139
+ s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
140
+ s.add_dependency(%q<rubyzip>.freeze, [">= 0"])
141
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
142
+ s.add_dependency(%q<pry>.freeze, [">= 0"])
143
+ s.add_dependency(%q<pry-nav>.freeze, [">= 0"])
144
+ s.add_dependency(%q<test-unit>.freeze, [">= 0"])
145
+ end
146
+ else
147
+ s.add_dependency(%q<thor>.freeze, [">= 0"])
148
+ s.add_dependency(%q<i18n>.freeze, [">= 0"])
149
+ s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
150
+ s.add_dependency(%q<rubyzip>.freeze, [">= 0"])
151
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
152
+ s.add_dependency(%q<pry>.freeze, [">= 0"])
153
+ s.add_dependency(%q<pry-nav>.freeze, [">= 0"])
154
+ s.add_dependency(%q<test-unit>.freeze, [">= 0"])
155
+ end
156
+ end
157
+
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__) + '/../../test_helper'))
4
+
5
+ class TestCldrDataCountryCodes < Test::Unit::TestCase
6
+ test 'country codes' do
7
+ expected =
8
+ {
9
+ AA: {
10
+ "numeric" => "958",
11
+ "alpha3" => "AAA",
12
+ },
13
+ AC: {
14
+ "alpha3" => "ASC",
15
+ }
16
+ }
17
+ country_codes = Cldr::Export::Data::CountryCodes.new
18
+ assert_equal(country_codes[:country_codes][:AA], expected[:AA])
19
+ assert_equal(country_codes[:country_codes][:AC], expected[:AC])
20
+ end
21
+ end
@@ -176,6 +176,12 @@ class TestCldrDataPluralParser < Test::Unit::TestCase
176
176
  assert_equal false, eval(Cldr::Export::Data::Plurals::Rule.parse('n mod 100 in 3..6').to_ruby, binding)
177
177
  end
178
178
 
179
+ def test_codes_with_missing_spaces
180
+ assert_equal 'n.to_f % 100 == 0', Cldr::Export::Data::Plurals::Rule.parse('n%100 = 0').to_ruby
181
+ assert_equal 'n.to_f % 100 == 0', Cldr::Export::Data::Plurals::Rule.parse('n % 100=0').to_ruby
182
+ assert_equal 'n.to_f != 0', Cldr::Export::Data::Plurals::Rule.parse('n!=0').to_ruby
183
+ end
184
+
179
185
  def test_n_negative
180
186
  # one: i = 1 and v = 0 @integer 1
181
187
  # other: @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-cldr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-17 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -127,6 +127,7 @@ email: svenfuchs@artweb-design.de
127
127
  executables: []
128
128
  extensions: []
129
129
  extra_rdoc_files:
130
+ - CHANGELOG.md
130
131
  - LICENSE
131
132
  - README.textile
132
133
  - TODO
@@ -152,6 +153,7 @@ files:
152
153
  - lib/cldr/export/data/calendars.rb
153
154
  - lib/cldr/export/data/calendars/gregorian.rb
154
155
  - lib/cldr/export/data/characters.rb
156
+ - lib/cldr/export/data/country_codes.rb
155
157
  - lib/cldr/export/data/currencies.rb
156
158
  - lib/cldr/export/data/currency_digits_and_rounding.rb
157
159
  - lib/cldr/export/data/delimiters.rb
@@ -201,10 +203,12 @@ files:
201
203
  - lib/core_ext/hash/symbolize_keys.rb
202
204
  - lib/core_ext/string/camelize.rb
203
205
  - lib/core_ext/string/underscore.rb
206
+ - ruby-cldr.gemspec
204
207
  - test/all.rb
205
208
  - test/export/code/numbers_test.rb
206
209
  - test/export/data/all.rb
207
210
  - test/export/data/calendars_test.rb
211
+ - test/export/data/country_codes_test.rb
208
212
  - test/export/data/currencies_test.rb
209
213
  - test/export/data/delimiters_test.rb
210
214
  - test/export/data/languages_test.rb
@@ -233,7 +237,7 @@ files:
233
237
  homepage: http://github.com/ruby-i18n/ruby-cldr
234
238
  licenses: []
235
239
  metadata: {}
236
- post_install_message:
240
+ post_install_message:
237
241
  rdoc_options: []
238
242
  require_paths:
239
243
  - lib
@@ -248,8 +252,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
252
  - !ruby/object:Gem::Version
249
253
  version: '0'
250
254
  requirements: []
251
- rubygems_version: 3.0.4
252
- signing_key:
255
+ rubygems_version: 3.1.4
256
+ signing_key:
253
257
  specification_version: 4
254
258
  summary: Ruby library for exporting and using data from CLDR
255
259
  test_files: []