iso_country_codes 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/README.rdoc +7 -6
- data/VERSION.yml +2 -2
- data/iso_country_codes.gemspec +3 -2
- data/lib/iso_country_codes.rb +1 -0
- data/lib/iso_country_codes/calling.rb +751 -0
- data/lib/iso_country_codes/code.rb +10 -1
- data/lib/iso_country_codes/iso_country_codes.rb +38 -8
- data/test/iso_country_codes_test.rb +65 -12
- metadata +6 -5
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.4.0 / 2013-01-29
|
2
|
+
|
3
|
+
* Added country calling codes, which may be accessed with the `calling` instance method
|
4
|
+
* Added `search_by_name`, `search_by_currency` and `search_by_calling_code` methods
|
5
|
+
* `:fuzzy` option on `find` is deprecated (use the `search_by_name` method instead)
|
6
|
+
|
1
7
|
=== 0.3.1 / 2013-01-28
|
2
8
|
|
3
9
|
* Updated with the latest data from Wikipedia
|
data/README.rdoc
CHANGED
@@ -6,7 +6,8 @@ Provides ISO codes, names and currencies for countries.
|
|
6
6
|
|
7
7
|
== FEATURES:
|
8
8
|
|
9
|
-
*
|
9
|
+
* Find by alpha-2, alpha-3 or numeric codes
|
10
|
+
* Search by name, currency code or calling/dialing code
|
10
11
|
|
11
12
|
== SYNOPSIS:
|
12
13
|
|
@@ -16,17 +17,17 @@ Provides ISO codes, names and currencies for countries.
|
|
16
17
|
code.numeric # => "036"
|
17
18
|
code.alpha2 # => "AU"
|
18
19
|
code.alpha3 # => "AUS"
|
20
|
+
code.calling # => "+61"
|
19
21
|
|
20
22
|
# Codes can be found via numeric, alpha-2 or alpha-3 format
|
21
23
|
IsoCountryCodes.find(36)
|
22
24
|
IsoCountryCodes.find('au')
|
23
25
|
IsoCountryCodes.find('aus')
|
24
26
|
|
25
|
-
# Codes can be
|
26
|
-
IsoCountryCodes.
|
27
|
-
|
28
|
-
|
29
|
-
IsoCountryCodes.find('united', :fuzzy => true).name # => 'United Kingdom'
|
27
|
+
# Codes can also be returned by searching country name, currency or calling/dialing code
|
28
|
+
IsoCountryCodes.search_by_name('australia')
|
29
|
+
IsoCountryCodes.search_by_currency('aud')
|
30
|
+
IsoCountryCodes.search_by_calling_code('+61')
|
30
31
|
|
31
32
|
# Fetch a country's local currency
|
32
33
|
IsoCountryCodes.find('aus').currency # => "AUD"
|
data/VERSION.yml
CHANGED
data/iso_country_codes.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{iso_country_codes}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["alex"]
|
12
|
-
s.date = %q{2013-01-
|
12
|
+
s.date = %q{2013-01-29}
|
13
13
|
s.description = %q{ISO country code and currency library}
|
14
14
|
s.email = %q{alexrabarts@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION.yml",
|
27
27
|
"iso_country_codes.gemspec",
|
28
28
|
"lib/iso_country_codes.rb",
|
29
|
+
"lib/iso_country_codes/calling.rb",
|
29
30
|
"lib/iso_country_codes/code.rb",
|
30
31
|
"lib/iso_country_codes/iso_3166_1.rb",
|
31
32
|
"lib/iso_country_codes/iso_4217.rb",
|
data/lib/iso_country_codes.rb
CHANGED
@@ -0,0 +1,751 @@
|
|
1
|
+
class IsoCountryCodes
|
2
|
+
class Code
|
3
|
+
class GBR < Code #:nodoc:
|
4
|
+
self.calling = '+44'
|
5
|
+
end
|
6
|
+
class FJI < Code #:nodoc:
|
7
|
+
self.calling = '+679'
|
8
|
+
end
|
9
|
+
class BLM < Code #:nodoc:
|
10
|
+
self.calling = '+590'
|
11
|
+
end
|
12
|
+
class RUS < Code #:nodoc:
|
13
|
+
self.calling = '+7'
|
14
|
+
end
|
15
|
+
class JOR < Code #:nodoc:
|
16
|
+
self.calling = '+962'
|
17
|
+
end
|
18
|
+
class GEO < Code #:nodoc:
|
19
|
+
self.calling = '+995'
|
20
|
+
end
|
21
|
+
class ATF < Code #:nodoc:
|
22
|
+
self.calling = '+689'
|
23
|
+
end
|
24
|
+
class ECU < Code #:nodoc:
|
25
|
+
self.calling = '+593'
|
26
|
+
end
|
27
|
+
class TWN < Code #:nodoc:
|
28
|
+
self.calling = '+886'
|
29
|
+
end
|
30
|
+
class ZWE < Code #:nodoc:
|
31
|
+
self.calling = '+263'
|
32
|
+
end
|
33
|
+
class ATG < Code #:nodoc:
|
34
|
+
self.calling = '+268'
|
35
|
+
end
|
36
|
+
class IDN < Code #:nodoc:
|
37
|
+
self.calling = '+62'
|
38
|
+
end
|
39
|
+
class BOL < Code #:nodoc:
|
40
|
+
self.calling = '+591'
|
41
|
+
end
|
42
|
+
class NPL < Code #:nodoc:
|
43
|
+
self.calling = '+977'
|
44
|
+
end
|
45
|
+
class DEU < Code #:nodoc:
|
46
|
+
self.calling = '+49'
|
47
|
+
end
|
48
|
+
class MLT < Code #:nodoc:
|
49
|
+
self.calling = '+356'
|
50
|
+
end
|
51
|
+
class TGO < Code #:nodoc:
|
52
|
+
self.calling = '+228'
|
53
|
+
end
|
54
|
+
class SRB < Code #:nodoc:
|
55
|
+
self.calling = '+381'
|
56
|
+
end
|
57
|
+
class TJK < Code #:nodoc:
|
58
|
+
self.calling = '+992'
|
59
|
+
end
|
60
|
+
class REU < Code #:nodoc:
|
61
|
+
self.calling = '+262'
|
62
|
+
end
|
63
|
+
class DNK < Code #:nodoc:
|
64
|
+
self.calling = '+45'
|
65
|
+
end
|
66
|
+
class LAO < Code #:nodoc:
|
67
|
+
self.calling = '+856'
|
68
|
+
end
|
69
|
+
class POL < Code #:nodoc:
|
70
|
+
self.calling = '+48'
|
71
|
+
end
|
72
|
+
class BLR < Code #:nodoc:
|
73
|
+
self.calling = '+375'
|
74
|
+
end
|
75
|
+
class PRI < Code #:nodoc:
|
76
|
+
self.calling = '+787'
|
77
|
+
end
|
78
|
+
class GAB < Code #:nodoc:
|
79
|
+
self.calling = '+241'
|
80
|
+
end
|
81
|
+
class TCA < Code #:nodoc:
|
82
|
+
self.calling = '+649'
|
83
|
+
end
|
84
|
+
class NIC < Code #:nodoc:
|
85
|
+
self.calling = '+505'
|
86
|
+
end
|
87
|
+
class RWA < Code #:nodoc:
|
88
|
+
self.calling = '+250'
|
89
|
+
end
|
90
|
+
class SYR < Code #:nodoc:
|
91
|
+
self.calling = '+963'
|
92
|
+
end
|
93
|
+
class URY < Code #:nodoc:
|
94
|
+
self.calling = '+598'
|
95
|
+
end
|
96
|
+
class NCL < Code #:nodoc:
|
97
|
+
self.calling = '+687'
|
98
|
+
end
|
99
|
+
class VCT < Code #:nodoc:
|
100
|
+
self.calling = '+784'
|
101
|
+
end
|
102
|
+
class PRK < Code #:nodoc:
|
103
|
+
self.calling = '+850'
|
104
|
+
end
|
105
|
+
class ZMB < Code #:nodoc:
|
106
|
+
self.calling = '+260'
|
107
|
+
end
|
108
|
+
class MKD < Code #:nodoc:
|
109
|
+
self.calling = '+389'
|
110
|
+
end
|
111
|
+
class CUW < Code #:nodoc:
|
112
|
+
self.calling = '+599'
|
113
|
+
end
|
114
|
+
class SXM < Code #:nodoc:
|
115
|
+
self.calling = '+599'
|
116
|
+
end
|
117
|
+
class SSD < Code #:nodoc:
|
118
|
+
self.calling = '+211'
|
119
|
+
end
|
120
|
+
class BES < Code #:nodoc:
|
121
|
+
self.calling = '+599'
|
122
|
+
end
|
123
|
+
class AZE < Code #:nodoc:
|
124
|
+
self.calling = '+994'
|
125
|
+
end
|
126
|
+
class BRN < Code #:nodoc:
|
127
|
+
self.calling = '+673'
|
128
|
+
end
|
129
|
+
class CMR < Code #:nodoc:
|
130
|
+
self.calling = '+237'
|
131
|
+
end
|
132
|
+
class ERI < Code #:nodoc:
|
133
|
+
self.calling = '+291'
|
134
|
+
end
|
135
|
+
class TCD < Code #:nodoc:
|
136
|
+
self.calling = '+235'
|
137
|
+
end
|
138
|
+
class DZA < Code #:nodoc:
|
139
|
+
self.calling = '+213'
|
140
|
+
end
|
141
|
+
class CCK < Code #:nodoc:
|
142
|
+
self.calling = '+891'
|
143
|
+
end
|
144
|
+
class NFK < Code #:nodoc:
|
145
|
+
self.calling = '+672'
|
146
|
+
end
|
147
|
+
class SOM < Code #:nodoc:
|
148
|
+
self.calling = '+252'
|
149
|
+
end
|
150
|
+
class GUY < Code #:nodoc:
|
151
|
+
self.calling = '+592'
|
152
|
+
end
|
153
|
+
class MRT < Code #:nodoc:
|
154
|
+
self.calling = '+222'
|
155
|
+
end
|
156
|
+
class NLD < Code #:nodoc:
|
157
|
+
self.calling = '+31'
|
158
|
+
end
|
159
|
+
class PLW < Code #:nodoc:
|
160
|
+
self.calling = '+680'
|
161
|
+
end
|
162
|
+
class VIR < Code #:nodoc:
|
163
|
+
self.calling = '+340'
|
164
|
+
end
|
165
|
+
class BEL < Code #:nodoc:
|
166
|
+
self.calling = '+32'
|
167
|
+
end
|
168
|
+
class MHL < Code #:nodoc:
|
169
|
+
self.calling = '+692'
|
170
|
+
end
|
171
|
+
class UKR < Code #:nodoc:
|
172
|
+
self.calling = '+380'
|
173
|
+
end
|
174
|
+
class UGA < Code #:nodoc:
|
175
|
+
self.calling = '+256'
|
176
|
+
end
|
177
|
+
class LTU < Code #:nodoc:
|
178
|
+
self.calling = '+370'
|
179
|
+
end
|
180
|
+
class MNE < Code #:nodoc:
|
181
|
+
self.calling = '+382'
|
182
|
+
end
|
183
|
+
class BLZ < Code #:nodoc:
|
184
|
+
self.calling = '+501'
|
185
|
+
end
|
186
|
+
class MOZ < Code #:nodoc:
|
187
|
+
self.calling = '+258'
|
188
|
+
end
|
189
|
+
class MUS < Code #:nodoc:
|
190
|
+
self.calling = '+230'
|
191
|
+
end
|
192
|
+
class IMN < Code #:nodoc:
|
193
|
+
self.calling = '+44'
|
194
|
+
end
|
195
|
+
class DMA < Code #:nodoc:
|
196
|
+
self.calling = '+767'
|
197
|
+
end
|
198
|
+
class BEN < Code #:nodoc:
|
199
|
+
self.calling = '+229'
|
200
|
+
end
|
201
|
+
class SLV < Code #:nodoc:
|
202
|
+
self.calling = '+503'
|
203
|
+
end
|
204
|
+
class LCA < Code #:nodoc:
|
205
|
+
self.calling = '+758'
|
206
|
+
end
|
207
|
+
class GNQ < Code #:nodoc:
|
208
|
+
self.calling = '+240'
|
209
|
+
end
|
210
|
+
class MNG < Code #:nodoc:
|
211
|
+
self.calling = '+976'
|
212
|
+
end
|
213
|
+
class UZB < Code #:nodoc:
|
214
|
+
self.calling = '+998'
|
215
|
+
end
|
216
|
+
class CPV < Code #:nodoc:
|
217
|
+
self.calling = '+238'
|
218
|
+
end
|
219
|
+
class JEY < Code #:nodoc:
|
220
|
+
self.calling = '+44'
|
221
|
+
end
|
222
|
+
class KIR < Code #:nodoc:
|
223
|
+
self.calling = '+686'
|
224
|
+
end
|
225
|
+
class PRT < Code #:nodoc:
|
226
|
+
self.calling = '+351'
|
227
|
+
end
|
228
|
+
class MAC < Code #:nodoc:
|
229
|
+
self.calling = '+853'
|
230
|
+
end
|
231
|
+
class AGO < Code #:nodoc:
|
232
|
+
self.calling = '+244'
|
233
|
+
end
|
234
|
+
class FSM < Code #:nodoc:
|
235
|
+
self.calling = '+691'
|
236
|
+
end
|
237
|
+
class PHL < Code #:nodoc:
|
238
|
+
self.calling = '+63'
|
239
|
+
end
|
240
|
+
class LVA < Code #:nodoc:
|
241
|
+
self.calling = '+371'
|
242
|
+
end
|
243
|
+
class COD < Code #:nodoc:
|
244
|
+
self.calling = '+243'
|
245
|
+
end
|
246
|
+
class CYM < Code #:nodoc:
|
247
|
+
self.calling = '+345'
|
248
|
+
end
|
249
|
+
class MDA < Code #:nodoc:
|
250
|
+
self.calling = '+373'
|
251
|
+
end
|
252
|
+
class DJI < Code #:nodoc:
|
253
|
+
self.calling = '+253'
|
254
|
+
end
|
255
|
+
class PER < Code #:nodoc:
|
256
|
+
self.calling = '+51'
|
257
|
+
end
|
258
|
+
class MAF < Code #:nodoc:
|
259
|
+
self.calling = '+590'
|
260
|
+
end
|
261
|
+
class GTM < Code #:nodoc:
|
262
|
+
self.calling = '+502'
|
263
|
+
end
|
264
|
+
class ISL < Code #:nodoc:
|
265
|
+
self.calling = '+354'
|
266
|
+
end
|
267
|
+
class PNG < Code #:nodoc:
|
268
|
+
self.calling = '+675'
|
269
|
+
end
|
270
|
+
class SEN < Code #:nodoc:
|
271
|
+
self.calling = '+221'
|
272
|
+
end
|
273
|
+
class GMB < Code #:nodoc:
|
274
|
+
self.calling = '+220'
|
275
|
+
end
|
276
|
+
class JAM < Code #:nodoc:
|
277
|
+
self.calling = '+876'
|
278
|
+
end
|
279
|
+
class COG < Code #:nodoc:
|
280
|
+
self.calling = '+242'
|
281
|
+
end
|
282
|
+
class CYP < Code #:nodoc:
|
283
|
+
self.calling = '+357'
|
284
|
+
end
|
285
|
+
class PRY < Code #:nodoc:
|
286
|
+
self.calling = '+595'
|
287
|
+
end
|
288
|
+
class MEX < Code #:nodoc:
|
289
|
+
self.calling = '+52'
|
290
|
+
end
|
291
|
+
class WSM < Code #:nodoc:
|
292
|
+
self.calling = '+685'
|
293
|
+
end
|
294
|
+
class BHR < Code #:nodoc:
|
295
|
+
self.calling = '+973'
|
296
|
+
end
|
297
|
+
class HUN < Code #:nodoc:
|
298
|
+
self.calling = '+36'
|
299
|
+
end
|
300
|
+
class BHS < Code #:nodoc:
|
301
|
+
self.calling = '+242'
|
302
|
+
end
|
303
|
+
class SUR < Code #:nodoc:
|
304
|
+
self.calling = '+597'
|
305
|
+
end
|
306
|
+
class OMN < Code #:nodoc:
|
307
|
+
self.calling = '+968'
|
308
|
+
end
|
309
|
+
class CUB < Code #:nodoc:
|
310
|
+
self.calling = '+53'
|
311
|
+
end
|
312
|
+
class KOR < Code #:nodoc:
|
313
|
+
self.calling = '+82'
|
314
|
+
end
|
315
|
+
class MDG < Code #:nodoc:
|
316
|
+
self.calling = '+261'
|
317
|
+
end
|
318
|
+
class FRA < Code #:nodoc:
|
319
|
+
self.calling = '+33'
|
320
|
+
end
|
321
|
+
class SHN < Code #:nodoc:
|
322
|
+
self.calling = '+290'
|
323
|
+
end
|
324
|
+
class MNP < Code #:nodoc:
|
325
|
+
self.calling = '+670'
|
326
|
+
end
|
327
|
+
class NIU < Code #:nodoc:
|
328
|
+
self.calling = '+683'
|
329
|
+
end
|
330
|
+
class BWA < Code #:nodoc:
|
331
|
+
self.calling = '+267'
|
332
|
+
end
|
333
|
+
class VEN < Code #:nodoc:
|
334
|
+
self.calling = '+58'
|
335
|
+
end
|
336
|
+
class HKG < Code #:nodoc:
|
337
|
+
self.calling = '+852'
|
338
|
+
end
|
339
|
+
class HND < Code #:nodoc:
|
340
|
+
self.calling = '+504'
|
341
|
+
end
|
342
|
+
class COK < Code #:nodoc:
|
343
|
+
self.calling = '+682'
|
344
|
+
end
|
345
|
+
class ISR < Code #:nodoc:
|
346
|
+
self.calling = '+972'
|
347
|
+
end
|
348
|
+
class FIN < Code #:nodoc:
|
349
|
+
self.calling = '+358'
|
350
|
+
end
|
351
|
+
class AIA < Code #:nodoc:
|
352
|
+
self.calling = '+264'
|
353
|
+
end
|
354
|
+
class KNA < Code #:nodoc:
|
355
|
+
self.calling = '+869'
|
356
|
+
end
|
357
|
+
class LIE < Code #:nodoc:
|
358
|
+
self.calling = '+423'
|
359
|
+
end
|
360
|
+
class FLK < Code #:nodoc:
|
361
|
+
self.calling = '+500'
|
362
|
+
end
|
363
|
+
class HRV < Code #:nodoc:
|
364
|
+
self.calling = '+385'
|
365
|
+
end
|
366
|
+
class COL < Code #:nodoc:
|
367
|
+
self.calling = '+57'
|
368
|
+
end
|
369
|
+
class CRI < Code #:nodoc:
|
370
|
+
self.calling = '+506'
|
371
|
+
end
|
372
|
+
class WLF < Code #:nodoc:
|
373
|
+
self.calling = '+681'
|
374
|
+
end
|
375
|
+
class BGD < Code #:nodoc:
|
376
|
+
self.calling = '+880'
|
377
|
+
end
|
378
|
+
class LSO < Code #:nodoc:
|
379
|
+
self.calling = '+266'
|
380
|
+
end
|
381
|
+
class MWI < Code #:nodoc:
|
382
|
+
self.calling = '+265'
|
383
|
+
end
|
384
|
+
class COM < Code #:nodoc:
|
385
|
+
self.calling = '+269'
|
386
|
+
end
|
387
|
+
class UMI < Code #:nodoc:
|
388
|
+
self.calling = '+1'
|
389
|
+
end
|
390
|
+
class USA < Code #:nodoc:
|
391
|
+
self.calling = '+1'
|
392
|
+
end
|
393
|
+
class KEN < Code #:nodoc:
|
394
|
+
self.calling = '+254'
|
395
|
+
end
|
396
|
+
class AFG < Code #:nodoc:
|
397
|
+
self.calling = '+93'
|
398
|
+
end
|
399
|
+
class ASM < Code #:nodoc:
|
400
|
+
self.calling = '+684'
|
401
|
+
end
|
402
|
+
class CIV < Code #:nodoc:
|
403
|
+
self.calling = '+225'
|
404
|
+
end
|
405
|
+
class NOR < Code #:nodoc:
|
406
|
+
self.calling = '+47'
|
407
|
+
end
|
408
|
+
class PAK < Code #:nodoc:
|
409
|
+
self.calling = '+92'
|
410
|
+
end
|
411
|
+
class YEM < Code #:nodoc:
|
412
|
+
self.calling = '+967'
|
413
|
+
end
|
414
|
+
class VUT < Code #:nodoc:
|
415
|
+
self.calling = '+678'
|
416
|
+
end
|
417
|
+
class ALA < Code #:nodoc:
|
418
|
+
self.calling = '+358'
|
419
|
+
end
|
420
|
+
class BDI < Code #:nodoc:
|
421
|
+
self.calling = '+257'
|
422
|
+
end
|
423
|
+
class MAR < Code #:nodoc:
|
424
|
+
self.calling = '+212'
|
425
|
+
end
|
426
|
+
class ALB < Code #:nodoc:
|
427
|
+
self.calling = '+355'
|
428
|
+
end
|
429
|
+
class KHM < Code #:nodoc:
|
430
|
+
self.calling = '+855'
|
431
|
+
end
|
432
|
+
class ETH < Code #:nodoc:
|
433
|
+
self.calling = '+251'
|
434
|
+
end
|
435
|
+
class PAN < Code #:nodoc:
|
436
|
+
self.calling = '+507'
|
437
|
+
end
|
438
|
+
class CHE < Code #:nodoc:
|
439
|
+
self.calling = '+41'
|
440
|
+
end
|
441
|
+
class MTQ < Code #:nodoc:
|
442
|
+
self.calling = '+596'
|
443
|
+
end
|
444
|
+
class BTN < Code #:nodoc:
|
445
|
+
self.calling = '+975'
|
446
|
+
end
|
447
|
+
class THA < Code #:nodoc:
|
448
|
+
self.calling = '+66'
|
449
|
+
end
|
450
|
+
class SWE < Code #:nodoc:
|
451
|
+
self.calling = '+46'
|
452
|
+
end
|
453
|
+
class TON < Code #:nodoc:
|
454
|
+
self.calling = '+676'
|
455
|
+
end
|
456
|
+
class VNM < Code #:nodoc:
|
457
|
+
self.calling = '+84'
|
458
|
+
end
|
459
|
+
class GGY < Code #:nodoc:
|
460
|
+
self.calling = '+1481'
|
461
|
+
end
|
462
|
+
class TLS < Code #:nodoc:
|
463
|
+
self.calling = '+670'
|
464
|
+
end
|
465
|
+
class NRU < Code #:nodoc:
|
466
|
+
self.calling = '+674'
|
467
|
+
end
|
468
|
+
class VGB < Code #:nodoc:
|
469
|
+
self.calling = '+284'
|
470
|
+
end
|
471
|
+
class GIB < Code #:nodoc:
|
472
|
+
self.calling = '+350'
|
473
|
+
end
|
474
|
+
class NER < Code #:nodoc:
|
475
|
+
self.calling = '+277'
|
476
|
+
end
|
477
|
+
class HTI < Code #:nodoc:
|
478
|
+
self.calling = '+509'
|
479
|
+
end
|
480
|
+
class MDV < Code #:nodoc:
|
481
|
+
self.calling = '+960'
|
482
|
+
end
|
483
|
+
class FRO < Code #:nodoc:
|
484
|
+
self.calling = '+298'
|
485
|
+
end
|
486
|
+
class CHL < Code #:nodoc:
|
487
|
+
self.calling = '+56'
|
488
|
+
end
|
489
|
+
class SDN < Code #:nodoc:
|
490
|
+
self.calling = '+249'
|
491
|
+
end
|
492
|
+
class IRL < Code #:nodoc:
|
493
|
+
self.calling = '+353'
|
494
|
+
end
|
495
|
+
class ARE < Code #:nodoc:
|
496
|
+
self.calling = '+971'
|
497
|
+
end
|
498
|
+
class CHN < Code #:nodoc:
|
499
|
+
self.calling = '+86'
|
500
|
+
end
|
501
|
+
class STP < Code #:nodoc:
|
502
|
+
self.calling = '+239'
|
503
|
+
end
|
504
|
+
class JPN < Code #:nodoc:
|
505
|
+
self.calling = '+81'
|
506
|
+
end
|
507
|
+
class TUN < Code #:nodoc:
|
508
|
+
self.calling = '+216'
|
509
|
+
end
|
510
|
+
class BGR < Code #:nodoc:
|
511
|
+
self.calling = '+359'
|
512
|
+
end
|
513
|
+
class IRN < Code #:nodoc:
|
514
|
+
self.calling = '+98'
|
515
|
+
end
|
516
|
+
class ARG < Code #:nodoc:
|
517
|
+
self.calling = '+54'
|
518
|
+
end
|
519
|
+
class CXR < Code #:nodoc:
|
520
|
+
self.calling = '+61'
|
521
|
+
end
|
522
|
+
class IOT < Code #:nodoc:
|
523
|
+
self.calling = '+246'
|
524
|
+
end
|
525
|
+
class SAU < Code #:nodoc:
|
526
|
+
self.calling = '+966'
|
527
|
+
end
|
528
|
+
class NGA < Code #:nodoc:
|
529
|
+
self.calling = '+234'
|
530
|
+
end
|
531
|
+
class HMD < Code #:nodoc:
|
532
|
+
self.calling = '+61'
|
533
|
+
end
|
534
|
+
class IRQ < Code #:nodoc:
|
535
|
+
self.calling = '+964'
|
536
|
+
end
|
537
|
+
class BFA < Code #:nodoc:
|
538
|
+
self.calling = '+226'
|
539
|
+
end
|
540
|
+
class TUR < Code #:nodoc:
|
541
|
+
self.calling = '+90'
|
542
|
+
end
|
543
|
+
class MMR < Code #:nodoc:
|
544
|
+
self.calling = '+95'
|
545
|
+
end
|
546
|
+
class PSE < Code #:nodoc:
|
547
|
+
self.calling = '+970'
|
548
|
+
end
|
549
|
+
class SGP < Code #:nodoc:
|
550
|
+
self.calling = '+65'
|
551
|
+
end
|
552
|
+
class CAF < Code #:nodoc:
|
553
|
+
self.calling = '+236'
|
554
|
+
end
|
555
|
+
class LKA < Code #:nodoc:
|
556
|
+
self.calling = '+94'
|
557
|
+
end
|
558
|
+
class SJM < Code #:nodoc:
|
559
|
+
self.calling = '+47'
|
560
|
+
end
|
561
|
+
class IND < Code #:nodoc:
|
562
|
+
self.calling = '+91'
|
563
|
+
end
|
564
|
+
class VAT < Code #:nodoc:
|
565
|
+
self.calling = '+379'
|
566
|
+
end
|
567
|
+
class LBN < Code #:nodoc:
|
568
|
+
self.calling = '+961'
|
569
|
+
end
|
570
|
+
class TKL < Code #:nodoc:
|
571
|
+
self.calling = '+690'
|
572
|
+
end
|
573
|
+
class GIN < Code #:nodoc:
|
574
|
+
self.calling = '+225'
|
575
|
+
end
|
576
|
+
class NAM < Code #:nodoc:
|
577
|
+
self.calling = '+264'
|
578
|
+
end
|
579
|
+
class SGS < Code #:nodoc:
|
580
|
+
self.calling = '+500'
|
581
|
+
end
|
582
|
+
class ARM < Code #:nodoc:
|
583
|
+
self.calling = '+374'
|
584
|
+
end
|
585
|
+
class GRC < Code #:nodoc:
|
586
|
+
self.calling = '+30'
|
587
|
+
end
|
588
|
+
class TUV < Code #:nodoc:
|
589
|
+
self.calling = '+688'
|
590
|
+
end
|
591
|
+
class TKM < Code #:nodoc:
|
592
|
+
self.calling = '+993'
|
593
|
+
end
|
594
|
+
class GRD < Code #:nodoc:
|
595
|
+
self.calling = '+473'
|
596
|
+
end
|
597
|
+
class DOM < Code #:nodoc:
|
598
|
+
self.calling = '+809'
|
599
|
+
end
|
600
|
+
class ESH < Code #:nodoc:
|
601
|
+
self.calling = '+212'
|
602
|
+
end
|
603
|
+
class LBR < Code #:nodoc:
|
604
|
+
self.calling = '+231'
|
605
|
+
end
|
606
|
+
class MCO < Code #:nodoc:
|
607
|
+
self.calling = '+355'
|
608
|
+
end
|
609
|
+
class ITA < Code #:nodoc:
|
610
|
+
self.calling = '+39'
|
611
|
+
end
|
612
|
+
class BMU < Code #:nodoc:
|
613
|
+
self.calling = '+441'
|
614
|
+
end
|
615
|
+
class EGY < Code #:nodoc:
|
616
|
+
self.calling = '+20'
|
617
|
+
end
|
618
|
+
class PYF < Code #:nodoc:
|
619
|
+
self.calling = '+689'
|
620
|
+
end
|
621
|
+
class CAN < Code #:nodoc:
|
622
|
+
self.calling = '+1'
|
623
|
+
end
|
624
|
+
class MSR < Code #:nodoc:
|
625
|
+
self.calling = '+664'
|
626
|
+
end
|
627
|
+
class SWZ < Code #:nodoc:
|
628
|
+
self.calling = '+268'
|
629
|
+
end
|
630
|
+
class CZE < Code #:nodoc:
|
631
|
+
self.calling = '+420'
|
632
|
+
end
|
633
|
+
class GLP < Code #:nodoc:
|
634
|
+
self.calling = '+590'
|
635
|
+
end
|
636
|
+
class SPM < Code #:nodoc:
|
637
|
+
self.calling = '+508'
|
638
|
+
end
|
639
|
+
class SYC < Code #:nodoc:
|
640
|
+
self.calling = '+248'
|
641
|
+
end
|
642
|
+
class PCN < Code #:nodoc:
|
643
|
+
self.calling = '+872'
|
644
|
+
end
|
645
|
+
class SMR < Code #:nodoc:
|
646
|
+
self.calling = '+378'
|
647
|
+
end
|
648
|
+
class GUF < Code #:nodoc:
|
649
|
+
self.calling = '+594'
|
650
|
+
end
|
651
|
+
class TZA < Code #:nodoc:
|
652
|
+
self.calling = '+255'
|
653
|
+
end
|
654
|
+
class GHA < Code #:nodoc:
|
655
|
+
self.calling = '+233'
|
656
|
+
end
|
657
|
+
class AND < Code #:nodoc:
|
658
|
+
self.calling = '+376'
|
659
|
+
end
|
660
|
+
class BIH < Code #:nodoc:
|
661
|
+
self.calling = '+387'
|
662
|
+
end
|
663
|
+
class KAZ < Code #:nodoc:
|
664
|
+
self.calling = '+7'
|
665
|
+
end
|
666
|
+
class KWT < Code #:nodoc:
|
667
|
+
self.calling = '+965'
|
668
|
+
end
|
669
|
+
class MLI < Code #:nodoc:
|
670
|
+
self.calling = '+223'
|
671
|
+
end
|
672
|
+
class NZL < Code #:nodoc:
|
673
|
+
self.calling = '+64'
|
674
|
+
end
|
675
|
+
class GRL < Code #:nodoc:
|
676
|
+
self.calling = '+299'
|
677
|
+
end
|
678
|
+
class AUS < Code #:nodoc:
|
679
|
+
self.calling = '+61'
|
680
|
+
end
|
681
|
+
class LBY < Code #:nodoc:
|
682
|
+
self.calling = '+218'
|
683
|
+
end
|
684
|
+
class ROU < Code #:nodoc:
|
685
|
+
self.calling = '+40'
|
686
|
+
end
|
687
|
+
class ABW < Code #:nodoc:
|
688
|
+
self.calling = '+297'
|
689
|
+
end
|
690
|
+
class ESP < Code #:nodoc:
|
691
|
+
self.calling = '+34'
|
692
|
+
end
|
693
|
+
class SLB < Code #:nodoc:
|
694
|
+
self.calling = '+677'
|
695
|
+
end
|
696
|
+
class LUX < Code #:nodoc:
|
697
|
+
self.calling = '+352'
|
698
|
+
end
|
699
|
+
class AUT < Code #:nodoc:
|
700
|
+
self.calling = '+43'
|
701
|
+
end
|
702
|
+
class BRA < Code #:nodoc:
|
703
|
+
self.calling = '+55'
|
704
|
+
end
|
705
|
+
class SVK < Code #:nodoc:
|
706
|
+
self.calling = '+421'
|
707
|
+
end
|
708
|
+
class QAT < Code #:nodoc:
|
709
|
+
self.calling = '+974'
|
710
|
+
end
|
711
|
+
class ATA < Code #:nodoc:
|
712
|
+
self.calling = '+672'
|
713
|
+
end
|
714
|
+
class ZAF < Code #:nodoc:
|
715
|
+
self.calling = '+27'
|
716
|
+
end
|
717
|
+
class BRB < Code #:nodoc:
|
718
|
+
self.calling = '+246'
|
719
|
+
end
|
720
|
+
class GUM < Code #:nodoc:
|
721
|
+
self.calling = '+671'
|
722
|
+
end
|
723
|
+
class MYS < Code #:nodoc:
|
724
|
+
self.calling = '+60'
|
725
|
+
end
|
726
|
+
class TTO < Code #:nodoc:
|
727
|
+
self.calling = '+868'
|
728
|
+
end
|
729
|
+
class SLE < Code #:nodoc:
|
730
|
+
self.calling = '+232'
|
731
|
+
end
|
732
|
+
class SVN < Code #:nodoc:
|
733
|
+
self.calling = '+386'
|
734
|
+
end
|
735
|
+
class BVT < Code #:nodoc:
|
736
|
+
self.calling = '+47'
|
737
|
+
end
|
738
|
+
class MYT < Code #:nodoc:
|
739
|
+
self.calling = '+262'
|
740
|
+
end
|
741
|
+
class KGZ < Code #:nodoc:
|
742
|
+
self.calling = '+996'
|
743
|
+
end
|
744
|
+
class EST < Code #:nodoc:
|
745
|
+
self.calling = '+372'
|
746
|
+
end
|
747
|
+
class GNB < Code #:nodoc:
|
748
|
+
self.calling = '+245'
|
749
|
+
end
|
750
|
+
end # end Code
|
751
|
+
end # IsoCountryCodes
|
@@ -20,6 +20,14 @@ class IsoCountryCodes
|
|
20
20
|
self.class.alpha3
|
21
21
|
end
|
22
22
|
|
23
|
+
def calling
|
24
|
+
self.class.calling
|
25
|
+
end
|
26
|
+
|
27
|
+
def calling_code
|
28
|
+
self.class.calling_code
|
29
|
+
end
|
30
|
+
|
23
31
|
def main_currency
|
24
32
|
self.class.main_currency
|
25
33
|
end
|
@@ -33,9 +41,10 @@ class IsoCountryCodes
|
|
33
41
|
end
|
34
42
|
|
35
43
|
class << self
|
36
|
-
attr_accessor :name, :numeric, :alpha2, :alpha3, :main_currency
|
44
|
+
attr_accessor :name, :numeric, :alpha2, :alpha3, :calling, :main_currency
|
37
45
|
attr_writer :currencies
|
38
46
|
alias_method :currency, :main_currency
|
47
|
+
alias_method :calling_code, :calling
|
39
48
|
|
40
49
|
@@codes = []
|
41
50
|
def inherited(code) #:nodoc:
|
@@ -11,7 +11,7 @@ class IsoCountryCodes # :nodoc:
|
|
11
11
|
Code.all
|
12
12
|
end
|
13
13
|
|
14
|
-
def find(code
|
14
|
+
def find(code)
|
15
15
|
code = code.to_s.upcase
|
16
16
|
instance = nil
|
17
17
|
|
@@ -25,17 +25,47 @@ class IsoCountryCodes # :nodoc:
|
|
25
25
|
instance = all.select { |c| c.alpha2 == code }.first
|
26
26
|
elsif code.match(/^[A-Z]{3}$/)
|
27
27
|
instance = all.select { |c| c.alpha3 == code }.first
|
28
|
-
else
|
29
|
-
instance = all.select { |c| c.name.upcase == code }.first
|
30
|
-
if opts[:fuzzy]
|
31
|
-
instance = all.select { |c| c.name.match(/^#{code}/i) }.first if instance.nil?
|
32
|
-
instance = all.select { |c| c.name.match(/#{code}/i) }.first if instance.nil?
|
33
|
-
end
|
34
28
|
end
|
35
29
|
|
36
|
-
raise UnknownCodeError, "ISO 3166-1 code '#{code}'
|
30
|
+
raise UnknownCodeError, "No ISO 3166-1 code could be found for '#{code}'." if instance.nil?
|
37
31
|
|
38
32
|
instance
|
39
33
|
end
|
34
|
+
|
35
|
+
def search_by_name(str)
|
36
|
+
instances = all.select { |c| c.name.upcase == str }
|
37
|
+
instances = all.select { |c| c.name.match(/^#{str}/i) } if instances.empty?
|
38
|
+
instances = all.select { |c| c.name.match(/#{str}/i) } if instances.empty?
|
39
|
+
|
40
|
+
raise UnknownCodeError, "No ISO 3166-1 codes could be found searching with name '#{code}'." if instances.empty?
|
41
|
+
|
42
|
+
instances
|
43
|
+
end
|
44
|
+
|
45
|
+
def search_by_calling_code(code)
|
46
|
+
code = "+#{code.to_i}" # Normalize code
|
47
|
+
instances = all.select { |c| c.calling == code }
|
48
|
+
|
49
|
+
raise UnknownCodeError, "No ISO 3166-1 codes could be found searching with calling code '#{code}'." if instances.empty?
|
50
|
+
|
51
|
+
instances
|
52
|
+
end
|
53
|
+
|
54
|
+
def search_by_calling(code) # Alias of search_by_calling_code
|
55
|
+
search_by_calling_code code
|
56
|
+
end
|
57
|
+
|
58
|
+
def search_by_currency(code)
|
59
|
+
code = code.to_str.upcase
|
60
|
+
instances = all.select { |c|
|
61
|
+
c.currencies.select { |currency|
|
62
|
+
currency != code
|
63
|
+
}.empty?
|
64
|
+
}
|
65
|
+
|
66
|
+
raise UnknownCodeError, "No ISO 3166-1 codes could be found searching with currency '#{code}'." if instances.empty?
|
67
|
+
|
68
|
+
instances
|
69
|
+
end
|
40
70
|
end
|
41
71
|
end
|
@@ -30,23 +30,66 @@ class TestIsoCountryCodes < Test::Unit::TestCase
|
|
30
30
|
assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.find('AUS')
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.
|
33
|
+
def test_search_with_lowercase_name
|
34
|
+
assert_equal [IsoCountryCodes::Code::AUS.instance], IsoCountryCodes.search_by_name('australia')
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.
|
37
|
+
def test_search_with_uppercase_name
|
38
|
+
assert_equal [IsoCountryCodes::Code::AUS.instance], IsoCountryCodes.search_by_name('AUSTRALIA')
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
assert_equal IsoCountryCodes::Code::AUS.instance, IsoCountryCodes.
|
41
|
+
def test_search_with_mixed_case_name
|
42
|
+
assert_equal [IsoCountryCodes::Code::AUS.instance], IsoCountryCodes.search_by_name('Australia')
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
assert_equal
|
47
|
-
|
48
|
-
IsoCountryCodes.
|
49
|
-
|
45
|
+
def test_search_by_name_returning_many_results_starting_wth_the_search_string
|
46
|
+
assert_equal([
|
47
|
+
IsoCountryCodes::Code::GBR.instance,
|
48
|
+
IsoCountryCodes::Code::UMI.instance,
|
49
|
+
IsoCountryCodes::Code::USA.instance,
|
50
|
+
IsoCountryCodes::Code::ARE.instance
|
51
|
+
], IsoCountryCodes.search_by_name('united'))
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_search_by_name_returning_many_results_not_starting_with_the_search_string
|
55
|
+
assert_equal([
|
56
|
+
IsoCountryCodes::Code::LAO.instance,
|
57
|
+
IsoCountryCodes::Code::PRK.instance,
|
58
|
+
IsoCountryCodes::Code::COD.instance
|
59
|
+
], IsoCountryCodes.search_by_name('democratic'))
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_search_by_currency_lowercase
|
63
|
+
assert_equal([
|
64
|
+
IsoCountryCodes::Code::CCK.instance,
|
65
|
+
IsoCountryCodes::Code::NFK.instance,
|
66
|
+
IsoCountryCodes::Code::KIR.instance,
|
67
|
+
IsoCountryCodes::Code::NRU.instance,
|
68
|
+
IsoCountryCodes::Code::CXR.instance,
|
69
|
+
IsoCountryCodes::Code::HMD.instance,
|
70
|
+
IsoCountryCodes::Code::AUS.instance
|
71
|
+
], IsoCountryCodes.search_by_currency('aud'))
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_search_by_currency_uppercase
|
75
|
+
assert_equal([
|
76
|
+
IsoCountryCodes::Code::CCK.instance,
|
77
|
+
IsoCountryCodes::Code::NFK.instance,
|
78
|
+
IsoCountryCodes::Code::KIR.instance,
|
79
|
+
IsoCountryCodes::Code::NRU.instance,
|
80
|
+
IsoCountryCodes::Code::CXR.instance,
|
81
|
+
IsoCountryCodes::Code::HMD.instance,
|
82
|
+
IsoCountryCodes::Code::AUS.instance
|
83
|
+
], IsoCountryCodes.search_by_currency('AUD'))
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_search_by_calling_code
|
87
|
+
assert_equal [IsoCountryCodes::Code::ZAF.instance], IsoCountryCodes.search_by_calling_code('+27')
|
88
|
+
assert_equal([
|
89
|
+
IsoCountryCodes::Code::CXR.instance,
|
90
|
+
IsoCountryCodes::Code::HMD.instance,
|
91
|
+
IsoCountryCodes::Code::AUS.instance
|
92
|
+
], IsoCountryCodes.search_by_calling_code('+61'))
|
50
93
|
end
|
51
94
|
|
52
95
|
def test_get_main_currency
|
@@ -54,7 +97,7 @@ class TestIsoCountryCodes < Test::Unit::TestCase
|
|
54
97
|
end
|
55
98
|
|
56
99
|
def test_currency_alias_method
|
57
|
-
code = IsoCountryCodes.
|
100
|
+
code = IsoCountryCodes::Code::AUS.instance
|
58
101
|
assert_equal code.main_currency, code.currency
|
59
102
|
end
|
60
103
|
|
@@ -78,6 +121,16 @@ class TestIsoCountryCodes < Test::Unit::TestCase
|
|
78
121
|
assert_equal 'AUS', IsoCountryCodes::Code::AUS.instance.alpha3
|
79
122
|
end
|
80
123
|
|
124
|
+
def test_get_calling
|
125
|
+
assert_equal '+61', IsoCountryCodes::Code::AUS.calling
|
126
|
+
assert_equal '+61', IsoCountryCodes::Code::AUS.instance.calling
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_get_calling_code_alias
|
130
|
+
code = IsoCountryCodes::Code::AUS.instance
|
131
|
+
assert_equal code.calling, code.calling_code
|
132
|
+
end
|
133
|
+
|
81
134
|
def test_get_name
|
82
135
|
assert_equal 'Australia', IsoCountryCodes::Code::AUS.name
|
83
136
|
assert_equal 'Australia', IsoCountryCodes::Code::AUS.instance.name
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso_country_codes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- alex
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-01-
|
18
|
+
date: 2013-01-29 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- VERSION.yml
|
39
39
|
- iso_country_codes.gemspec
|
40
40
|
- lib/iso_country_codes.rb
|
41
|
+
- lib/iso_country_codes/calling.rb
|
41
42
|
- lib/iso_country_codes/code.rb
|
42
43
|
- lib/iso_country_codes/iso_3166_1.rb
|
43
44
|
- lib/iso_country_codes/iso_4217.rb
|