icu_utils 1.0.0 → 1.0.1

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.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- icu_utils (1.0.0)
4
+ icu_utils (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -70,7 +70,10 @@ module ICU
70
70
  return nil if str.length < 3
71
71
  compile
72
72
  str = str.strip.squeeze(' ').downcase
73
- return @@codes[str] if str.length == 3
73
+ if str.length == 3
74
+ str = correct_common_errors(str)
75
+ return @@codes[str]
76
+ end
74
77
  return @@names[str] if @@names[str]
75
78
  matches = Array.new
76
79
  @@names.each_key do |name|
@@ -123,6 +126,17 @@ module ICU
123
126
  end
124
127
  end
125
128
  end
129
+
130
+ def self.correct_common_errors(str)
131
+ case str
132
+ when "icu" then "irl"
133
+ when "rom" then "rou"
134
+ when "sao" then "stp"
135
+ when "spa" then "esp"
136
+ when "wal" then "wls"
137
+ else str
138
+ end
139
+ end
126
140
 
127
141
  # The data structures compiled.
128
142
  @@objects, @@codes, @@names = nil, nil, nil
@@ -148,7 +162,7 @@ module ICU
148
162
  ['BAR', 'Barbados'],
149
163
  ['BLR', 'Belarus'],
150
164
  ['BEL', 'Belgium'],
151
- ['BIZ', 'Belize'],
165
+ ['BLZ', 'Belize'],
152
166
  ['BEN', 'Benin Republic'],
153
167
  ['BER', 'Bermuda'],
154
168
  ['BHU', 'Bhutan'],
@@ -159,7 +173,6 @@ module ICU
159
173
  ['IVB', 'British Virgin Islands'],
160
174
  ['BRU', 'Brunei Darussalam'],
161
175
  ['BUL', 'Bulgaria'],
162
- ['BUR', 'Burkina Faso'],
163
176
  ['BDI', 'Burundi'],
164
177
  ['CAM', 'Cambodia'],
165
178
  ['CMR', 'Cameroon'],
@@ -174,6 +187,7 @@ module ICU
174
187
  ['CUB', 'Cuba'],
175
188
  ['CYP', 'Cyprus'],
176
189
  ['CZE', 'Czech Republic'],
190
+ ['CGO', 'Congo-Kinshasa'],
177
191
  ['DEN', 'Denmark'],
178
192
  ['DJI', 'Djibouti'],
179
193
  ['DOM', 'Dominican Republic'],
@@ -193,6 +207,7 @@ module ICU
193
207
  ['GER', 'Germany'],
194
208
  ['GHA', 'Ghana'],
195
209
  ['GRE', 'Greece'],
210
+ ['GUM', 'Guam'],
196
211
  ['GUA', 'Guatemala'],
197
212
  ['GCI', 'Guernsey'],
198
213
  ['GUY', 'Guyana'],
@@ -217,8 +232,10 @@ module ICU
217
232
  ['KEN', 'Kenya'],
218
233
  ['KUW', 'Kuwait'],
219
234
  ['KGZ', 'Kyrgyzstan'],
235
+ ['LAO', 'Laos'],
220
236
  ['LAT', 'Latvia'],
221
237
  ['LIB', 'Lebanon'],
238
+ ['LSO', 'Lesotho'],
222
239
  ['LBA', 'Libya'],
223
240
  ['LIE', 'Liechtenstein'],
224
241
  ['LTU', 'Lithuania'],
@@ -274,6 +291,7 @@ module ICU
274
291
  ['SIN', 'Singapore'],
275
292
  ['SVK', 'Slovakia'],
276
293
  ['SLO', 'Slovenia'],
294
+ ['SOL', 'Solomon Islands'],
277
295
  ['SOM', 'Somalia'],
278
296
  ['RSA', 'South Africa'],
279
297
  ['KOR', 'South Korea'],
@@ -287,6 +305,7 @@ module ICU
287
305
  ['TJK', 'Tajikistan'],
288
306
  ['TAN', 'Tanzania'],
289
307
  ['THA', 'Thailand'],
308
+ ['TOG', 'Togo'],
290
309
  ['TRI', 'Trinidad and Tobago'],
291
310
  ['TUN', 'Tunisia'],
292
311
  ['TUR', 'Turkey'],
@@ -1,3 +1,3 @@
1
1
  module IcuUtils
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -2,6 +2,8 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  module ICU
4
4
  describe Federation do
5
+ let(:total) { 179 }
6
+
5
7
  context "#find using codes" do
6
8
  it "should find a federation given a valid code" do
7
9
  fed = Federation.find('IRL')
@@ -84,6 +86,14 @@ module ICU
84
86
  end
85
87
  end
86
88
 
89
+ context "#find from common code errors" do
90
+ it "should find IRL from ICU" do
91
+ Federation.find('ICU').code.should == 'IRL'
92
+ Federation.find('SPA').code.should == 'ESP'
93
+ Federation.find('WAL').code.should == 'WLS'
94
+ end
95
+ end
96
+
87
97
  context "#find with alternative inputs" do
88
98
  it "should behave robustly with completely invalid inputs" do
89
99
  Federation.find().should be_nil
@@ -115,13 +125,9 @@ module ICU
115
125
  end
116
126
 
117
127
  context "#menu" do
118
- before(:all) do
119
- @total = 174
120
- end
121
-
122
128
  it "should return array of name-code pairs in order of name by default" do
123
129
  menu = Federation.menu
124
- menu.should have(@total).items
130
+ menu.should have(total).items
125
131
  names = menu.map{|m| m.first}.join(',')
126
132
  codes = menu.map{|m| m.last}.join(',')
127
133
  names.index('Afghanistan').should == 0
@@ -132,7 +138,7 @@ module ICU
132
138
 
133
139
  it "should be configuarble to order the list by codes" do
134
140
  menu = Federation.menu(:order => "code")
135
- menu.should have(@total).items
141
+ menu.should have(total).items
136
142
  names = menu.map{|m| m.first}.join(',')
137
143
  codes = menu.map{|m| m.last}.join(',')
138
144
  names.index('Afghanistan').should == 0
@@ -143,7 +149,7 @@ module ICU
143
149
 
144
150
  it "should be configuarble to have a selected country at the top" do
145
151
  menu = Federation.menu(:top => 'IRL')
146
- menu.should have(@total).items
152
+ menu.should have(total).items
147
153
  names = menu.map{|m| m.first}.join(',')
148
154
  codes = menu.map{|m| m.last}.join(',')
149
155
  names.index('Ireland,Afghanistan').should == 0
@@ -154,7 +160,7 @@ module ICU
154
160
 
155
161
  it "should be configuarble to have 'None' entry at the top" do
156
162
  menu = Federation.menu(:none => 'None')
157
- menu.should have(@total + 1).items
163
+ menu.should have(total + 1).items
158
164
  names = menu.map{|m| m.first}.join(',')
159
165
  codes = menu.map{|m| m.last}.join(',')
160
166
  names.index('None,Afghanistan').should == 0
@@ -163,7 +169,7 @@ module ICU
163
169
 
164
170
  it "should be able to handle multiple configuarations" do
165
171
  menu = Federation.menu(:top => 'IRL', :order => 'code', :none => 'None')
166
- menu.should have(@total + 1).items
172
+ menu.should have(total + 1).items
167
173
  names = menu.map{|m| m.first}.join(',')
168
174
  codes = menu.map{|m| m.last}.join(',')
169
175
  names.index('None,Ireland,Afghanistan').should == 0
@@ -174,13 +180,9 @@ module ICU
174
180
  end
175
181
 
176
182
  context "#codes" do
177
- before(:all) do
178
- @total = 174
179
- end
180
-
181
183
  it "should return array of codes ordered alphabetically" do
182
184
  codes = Federation.codes
183
- codes.should have(@total).items
185
+ codes.should have(total).items
184
186
  all = codes.join(',')
185
187
  all.index('AFG').should == 0
186
188
  all.index('INA,IND,IRI,IRL,IRQ,ISL,ISR,ISV,ITA,IVB').should_not be_nil
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icu_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Mark Orr
@@ -13,6 +14,7 @@ dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rdoc
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -97,26 +106,33 @@ files:
97
106
  homepage: http://github.com/sanichi/icu_utils
98
107
  licenses:
99
108
  - MIT
100
- metadata: {}
101
109
  post_install_message:
102
110
  rdoc_options: []
103
111
  require_paths:
104
112
  - lib
105
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
106
115
  requirements:
107
116
  - - ! '>='
108
117
  - !ruby/object:Gem::Version
109
118
  version: '0'
119
+ segments:
120
+ - 0
121
+ hash: -748731329100814069
110
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
111
124
  requirements:
112
125
  - - ! '>='
113
126
  - !ruby/object:Gem::Version
114
127
  version: '0'
128
+ segments:
129
+ - 0
130
+ hash: -748731329100814069
115
131
  requirements: []
116
132
  rubyforge_project:
117
- rubygems_version: 2.1.10
133
+ rubygems_version: 1.8.23
118
134
  signing_key:
119
- specification_version: 4
135
+ specification_version: 3
120
136
  summary: Shared ICU utilities
121
137
  test_files:
122
138
  - spec/federation_spec.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZmI4OGJlNjg3MjJkZjEwNDFlMmMyZTViNmExY2RmYTczN2Q3YWI0Yw==
5
- data.tar.gz: !binary |-
6
- YzUzYTA0ZDlhN2IxZGVmYWZlNjc1NjQ1NTNkMjFjMTI1NDVhOTk4ZA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- ZmQ1Y2EyNzFlZWZiZjNiODhjMDM2Nzc4NWEyOTFlYjY3OGU4NTZjYjgwYWNi
10
- MmRmNTI1ZTYwOTNhMDg2YmFkMzlhZDc2MWI5MWU3NWFmYzdmMzQ5M2EzMDdm
11
- Njg5YjcwMDRkOThkMTFjNTZiNjM2MTZkOTEwODU4MzI3ODA5NTU=
12
- data.tar.gz: !binary |-
13
- NmFlZTU2YjNmZWM4NzM2YWE2ODJkNDM5Yzc5MWYzZjVlM2MwNTA1MDcwMThi
14
- MDk1MDgxZTNlMTliOGYzZThlNWM4OWQxMzM2NTlhNDZjM2RkZTZhY2FmMzFl
15
- ODM2ZGE4YTJjOGE3ZjA2NTI1MGFiNjcwZGEwMjQ0MWFiNWQxMGM=