iso3166-countries 0.0.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46e129b041dd58cbe003f7694c78a819ee87e6a396681983923e8fd8e8e3cac5
4
- data.tar.gz: 5ee8cd4791a63ea349711f4e7e69acfa8254ce927499dfa5b3ed721df97e047b
3
+ metadata.gz: bf772607ef96550a4e456ecf46054f72d1cb6a4ddfac309bcaeeb9f74ea3aaa0
4
+ data.tar.gz: 6fd6d587489ce026068d44cce3a2fdb1d0c7866302c56eadfd09ef53333375f3
5
5
  SHA512:
6
- metadata.gz: 74899457a19bdda95e2c9f229f3194913d97aee03d8296e387a062ef5a862c6fa4c4598a77f0c1e30957ed56ed029050026c31a454644cb1249e501ba1af2c53
7
- data.tar.gz: 40b7778efb0fe2e8af3eb8adbd29a8bc962c31f352dc6e3b8462bf9a4d3f871b6a3b16b6674881eb93d8b8e47f1acfc9dd7ac9a01a60bf5fc878f14308b5da57
6
+ metadata.gz: 566bd4ea26485099aba48eaeffdcb37919699df5e936d6cd8f63ba496599c5599b35bf24de41838aff4afead4925c78f36d5880ebf6793ad821345af03673383
7
+ data.tar.gz: 4705de403670ffa1843aceec38aeaaa2529515b87aba736bbe31f860626d39696f95109baa41f2af0243e2e91fd96632b1d025bcb9d8981124bd93c7268a131b
@@ -15,5 +15,5 @@ jobs:
15
15
  run: |
16
16
  gem install bundler -v 2.2.11
17
17
  bundle install
18
- bundle exec rake spec
18
+ RUBYOPT='--enable-frozen-string-literal' bundle exec rake spec
19
19
  bundle exec rake standard
data/.gitignore CHANGED
@@ -11,3 +11,5 @@ Gemfile.lock
11
11
 
12
12
  # rspec failure tracking
13
13
  .rspec_status
14
+
15
+ scripts
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Iso3166::Countries
1
+ # ISO3166::Countries
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/iso3166/countries`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This gem is heavily inspired by [hexorx/countries](https://github.com/hexorx/countries). Due to lack of maintenance of the original gem, we decided to make our own gem based on iso.org data.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,37 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ The gem is shipped with sample data that includes ISO3166 data for 3 countries(BR, CH and NZ). In order to access all countries data, you must purchase the XML data file from [iso.org](https://www.iso.org/).
24
+
25
+ ```ruby
26
+ ISO3166::Countries.data_path = "path/to/data/file.xml"
27
+ country = ISO3166::Country.new("BR")
28
+ => #<ISO3166::Country:0x00007f9253226d88 @code="BR" ...
29
+ country.alpha2
30
+ => "BR"
31
+ country.alpha3
32
+ => "BRA"
33
+ country.name
34
+ => "Brazil" # English name
35
+ country.number
36
+ => "076"
37
+ country.in_eu?
38
+ => false
39
+ country.currency_code
40
+ => "BRL"
41
+
42
+ ISO3166::Country.find_by(alpha2: "BR")
43
+ => #<ISO3166::Country:0x00007f9253226d88 @code="BR" ...
44
+ ISO3166::Country.find_by(alpha3: "BRA")
45
+ => #<ISO3166::Country:0x00007f9253226d88 @code="BR" ...
46
+ ISO3166::Country.all_names_with_codes
47
+ => [["Brazil", "BR"], ["Switzerland", "CH"], ["New Zealand", "NZ"], ["Netherlands (the)", "NL"]]
48
+ ISO3166::Country.all
49
+ => [#<ISO3166::Country:0x00007f9253226d88 @code="BR" ...
50
+
51
+ ISO3166::Country.find_by(alpha2: "BR") == ISO3166::Country["BR"]
52
+ => true
53
+ ```
26
54
 
27
55
  ## Development
28
56
 
@@ -32,7 +60,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
60
 
33
61
  ## Contributing
34
62
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/iso3166-countries.
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/viaeurope/iso3166-countries.
36
64
 
37
65
  ## License
38
66
 
data/data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ ## Sample Data
2
+
3
+ Sample data is downloaded from [iso.org](https://www.iso.org/) that's available for free.
4
+ It currently includes data for the following countries:
5
+ * BR - Brazil
6
+ * CH - the Swiss Confederation
7
+ * NZ - New Zealand
8
+
9
+ Sample data is used for testing and trying the gem. Full data must be purchased from [iso.org](https://www.iso.org/).
data/data/extended.yml ADDED
@@ -0,0 +1,579 @@
1
+ AD:
2
+ currency_code: EUR
3
+ AE:
4
+ currency_code: AED
5
+ AF:
6
+ currency_code: AFN
7
+ AG:
8
+ currency_code: XCD
9
+ AI:
10
+ currency_code: XCD
11
+ AL:
12
+ currency_code: ALL
13
+ AM:
14
+ currency_code: AMD
15
+ AO:
16
+ currency_code: AOA
17
+ AQ:
18
+ currency_code:
19
+ AR:
20
+ currency_code: ARS
21
+ AS:
22
+ currency_code: USD
23
+ AT:
24
+ eu_member: true
25
+ currency_code: EUR
26
+ postal_code_format: NNNN
27
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
28
+ AU:
29
+ currency_code: AUD
30
+ AW:
31
+ currency_code: AWG
32
+ AX:
33
+ currency_code: EUR
34
+ AZ:
35
+ currency_code: AZN
36
+ BA:
37
+ currency_code: BAM
38
+ BB:
39
+ currency_code: BBD
40
+ BD:
41
+ currency_code: BDT
42
+ BE:
43
+ eu_member: true
44
+ currency_code: EUR
45
+ postal_code_format: NNNN
46
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
47
+ BF:
48
+ currency_code: XOF
49
+ BG:
50
+ eu_member: true
51
+ currency_code: BGN
52
+ postal_code_format: NNNN
53
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
54
+ BH:
55
+ currency_code: BHD
56
+ BI:
57
+ currency_code: BIF
58
+ BJ:
59
+ currency_code: XOF
60
+ BL:
61
+ currency_code: EUR
62
+ BM:
63
+ currency_code: BMD
64
+ BN:
65
+ currency_code: BND
66
+ BO:
67
+ currency_code: BOB
68
+ BQ:
69
+ currency_code: USD
70
+ BR:
71
+ currency_code: BRL
72
+ BS:
73
+ currency_code: BSD
74
+ BT:
75
+ currency_code: INR
76
+ BV:
77
+ currency_code: NOK
78
+ BW:
79
+ currency_code: BWP
80
+ BY:
81
+ currency_code: BYN
82
+ BZ:
83
+ currency_code: BZD
84
+ CA:
85
+ currency_code: CAD
86
+ CC:
87
+ currency_code: AUD
88
+ CD:
89
+ currency_code: CDF
90
+ CF:
91
+ currency_code: XAF
92
+ CG:
93
+ currency_code: XAF
94
+ CH:
95
+ currency_code: CHF
96
+ CI:
97
+ currency_code: XOF
98
+ CK:
99
+ currency_code: NZD
100
+ CL:
101
+ currency_code: CLP
102
+ CM:
103
+ currency_code: XAF
104
+ CN:
105
+ currency_code: CNY
106
+ CO:
107
+ currency_code: COP
108
+ CR:
109
+ currency_code: CRC
110
+ CU:
111
+ currency_code: CUP
112
+ CV:
113
+ currency_code: CVE
114
+ CW:
115
+ currency_code: ANG
116
+ CX:
117
+ currency_code: AUD
118
+ CY:
119
+ eu_member: true
120
+ currency_code: EUR
121
+ postal_code_format: NNNN
122
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
123
+ CZ:
124
+ eu_member: true
125
+ currency_code: CZK
126
+ postal_code_format: NNNNN
127
+ postal_code_regexp: !ruby/regexp '/\A[1234567]\d{4}\z/'
128
+ DE:
129
+ eu_member: true
130
+ currency_code: EUR
131
+ postal_code_format: NNNNN
132
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
133
+ DJ:
134
+ currency_code: DJF
135
+ DK:
136
+ eu_member: true
137
+ currency_code: DKK
138
+ postal_code_format: NNNN
139
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
140
+ DM:
141
+ currency_code: XCD
142
+ DO:
143
+ currency_code: DOP
144
+ DZ:
145
+ currency_code: DZD
146
+ EC:
147
+ currency_code: USD
148
+ EE:
149
+ eu_member: true
150
+ currency_code: EUR
151
+ postal_code_format: NNNNN
152
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
153
+ EG:
154
+ currency_code: EGP
155
+ EH:
156
+ currency_code: MAD
157
+ ER:
158
+ currency_code: ERN
159
+ ES:
160
+ eu_member: true
161
+ currency_code: EUR
162
+ postal_code_format: NNNNN
163
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
164
+ ET:
165
+ currency_code: ETB
166
+ FI:
167
+ eu_member: true
168
+ currency_code: EUR
169
+ postal_code_format: NNNNN
170
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
171
+ FJ:
172
+ currency_code: FJD
173
+ FK:
174
+ currency_code: FKP
175
+ FM:
176
+ currency_code: USD
177
+ FO:
178
+ currency_code: DKK
179
+ FR:
180
+ eu_member: true
181
+ currency_code: EUR
182
+ postal_code_format: NNNNN
183
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
184
+ GA:
185
+ currency_code: XAF
186
+ GB:
187
+ currency_code: GBP
188
+ GD:
189
+ currency_code: XCD
190
+ GE:
191
+ currency_code: GEL
192
+ GF:
193
+ currency_code: EUR
194
+ GG:
195
+ currency_code: GBP
196
+ GH:
197
+ currency_code: GHS
198
+ GI:
199
+ currency_code: GIP
200
+ GL:
201
+ currency_code: DKK
202
+ GM:
203
+ currency_code: GMD
204
+ GN:
205
+ currency_code: GNF
206
+ GP:
207
+ currency_code: EUR
208
+ GQ:
209
+ currency_code: XAF
210
+ GR:
211
+ eu_member: true
212
+ currency_code: EUR
213
+ postal_code_format: NNNNN
214
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
215
+ GS:
216
+ currency_code:
217
+ GT:
218
+ currency_code: GTQ
219
+ GU:
220
+ currency_code: USD
221
+ GW:
222
+ currency_code: XOF
223
+ GY:
224
+ currency_code: GYD
225
+ HK:
226
+ currency_code: HKD
227
+ HM:
228
+ currency_code: AUD
229
+ HN:
230
+ currency_code: HNL
231
+ HR:
232
+ eu_member: true
233
+ currency_code: HRK
234
+ postal_code_format: NNNNN
235
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
236
+ HT:
237
+ currency_code: HTG
238
+ HU:
239
+ eu_member: true
240
+ currency_code: HUF
241
+ postal_code_format: NNNN
242
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
243
+ ID:
244
+ currency_code: IDR
245
+ IE:
246
+ eu_member: true
247
+ currency_code: EUR
248
+ postal_code_format: ANAnAnAnAnAn
249
+ postal_code_regexp: !ruby/regexp '/\A([AC-FHKNPRTV-Y]\d{2}|D6W)[0-9AC-FHKNPRTV-Y]{4}\z/'
250
+ IL:
251
+ currency_code: ILS
252
+ IM:
253
+ currency_code: GBP
254
+ IN:
255
+ currency_code: INR
256
+ IO:
257
+ currency_code: USD
258
+ IQ:
259
+ currency_code: IQD
260
+ IR:
261
+ currency_code: IRR
262
+ IS:
263
+ currency_code: ISK
264
+ IT:
265
+ eu_member: true
266
+ currency_code: EUR
267
+ postal_code_format: NNNNN
268
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
269
+ JE:
270
+ currency_code: GBP
271
+ JM:
272
+ currency_code: JMD
273
+ JO:
274
+ currency_code: JOD
275
+ JP:
276
+ currency_code: JPY
277
+ KE:
278
+ currency_code: KES
279
+ KG:
280
+ currency_code: KGS
281
+ KH:
282
+ currency_code: KHR
283
+ KI:
284
+ currency_code: AUD
285
+ KM:
286
+ currency_code: KMF
287
+ KN:
288
+ currency_code: XCD
289
+ KP:
290
+ currency_code: KPW
291
+ KR:
292
+ currency_code: KRW
293
+ KW:
294
+ currency_code: KWD
295
+ KY:
296
+ currency_code: KYD
297
+ KZ:
298
+ currency_code: KZT
299
+ LA:
300
+ currency_code: LAK
301
+ LB:
302
+ currency_code: LBP
303
+ LC:
304
+ currency_code: XCD
305
+ LI:
306
+ currency_code: CHF
307
+ LK:
308
+ currency_code: LKR
309
+ LR:
310
+ currency_code: LRD
311
+ LS:
312
+ currency_code: LSL
313
+ LT:
314
+ eu_member: true
315
+ currency_code: EUR
316
+ postal_code_format: NNNNN
317
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
318
+ LU:
319
+ eu_member: true
320
+ currency_code: EUR
321
+ postal_code_format: NNNN
322
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
323
+ LV:
324
+ eu_member: true
325
+ currency_code: EUR
326
+ postal_code_format: NNNN
327
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
328
+ LY:
329
+ currency_code: LYD
330
+ MA:
331
+ currency_code: MAD
332
+ MC:
333
+ currency_code: EUR
334
+ MD:
335
+ currency_code: MDL
336
+ ME:
337
+ currency_code: EUR
338
+ MF:
339
+ currency_code: EUR
340
+ MG:
341
+ currency_code: MGA
342
+ MH:
343
+ currency_code: USD
344
+ MK:
345
+ currency_code: MKD
346
+ ML:
347
+ currency_code: XOF
348
+ MM:
349
+ currency_code: MMK
350
+ MN:
351
+ currency_code: MNT
352
+ MO:
353
+ currency_code: MOP
354
+ MP:
355
+ currency_code: USD
356
+ MQ:
357
+ currency_code: EUR
358
+ MR:
359
+ currency_code: MRU
360
+ MS:
361
+ currency_code: XCD
362
+ MT:
363
+ eu_member: true
364
+ currency_code: EUR
365
+ postal_code_format: AAANNNN
366
+ postal_code_regexp: !ruby/regexp '/^[A-Z]{3}\d{4}$/'
367
+ MU:
368
+ currency_code: MUR
369
+ MV:
370
+ currency_code: MVR
371
+ MW:
372
+ currency_code: MWK
373
+ MX:
374
+ currency_code: MXN
375
+ MY:
376
+ currency_code: MYR
377
+ MZ:
378
+ currency_code: MZN
379
+ NA:
380
+ currency_code: NAD
381
+ NC:
382
+ currency_code: XPF
383
+ NE:
384
+ currency_code: XOF
385
+ NF:
386
+ currency_code: AUD
387
+ NG:
388
+ currency_code: NGN
389
+ NI:
390
+ currency_code: NIO
391
+ NL:
392
+ eu_member: true
393
+ currency_code: EUR
394
+ postal_code_format: "NNNNAA, NNNN AA"
395
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\s?[A-Z]{2}\z/'
396
+ 'NO':
397
+ currency_code: NOK
398
+ NP:
399
+ currency_code: NPR
400
+ NR:
401
+ currency_code: AUD
402
+ NU:
403
+ currency_code: NZD
404
+ NZ:
405
+ currency_code: NZD
406
+ OM:
407
+ currency_code: OMR
408
+ PA:
409
+ currency_code: PAB
410
+ PE:
411
+ currency_code: PEN
412
+ PF:
413
+ currency_code: XPF
414
+ PG:
415
+ currency_code: PGK
416
+ PH:
417
+ currency_code: PHP
418
+ PK:
419
+ currency_code: PKR
420
+ PL:
421
+ eu_member: true
422
+ currency_code: PLN
423
+ postal_code_format: "NN-NNN, NNNNN"
424
+ postal_code_regexp: !ruby/regexp '/\A\d{2}-?\d{3}\z/'
425
+ PM:
426
+ currency_code: EUR
427
+ PN:
428
+ currency_code: NZD
429
+ PR:
430
+ currency_code: USD
431
+ PS:
432
+ currency_code:
433
+ PT:
434
+ eu_member: true
435
+ currency_code: EUR
436
+ postal_code_format: "NNNN-NNN, NNNNNNN"
437
+ postal_code_regexp: !ruby/regexp '/\A\d{4}(-?\d{3})?\z/'
438
+ PW:
439
+ currency_code: USD
440
+ PY:
441
+ currency_code: PYG
442
+ QA:
443
+ currency_code: QAR
444
+ RE:
445
+ currency_code: EUR
446
+ RO:
447
+ eu_member: true
448
+ currency_code: RON
449
+ postal_code_format: NNNNNN
450
+ postal_code_regexp: !ruby/regexp '/\A\d{6}\z/'
451
+ RS:
452
+ currency_code: RSD
453
+ RU:
454
+ currency_code: RUB
455
+ RW:
456
+ currency_code: RWF
457
+ SA:
458
+ currency_code: SAR
459
+ SB:
460
+ currency_code: SBD
461
+ SC:
462
+ currency_code: SCR
463
+ SD:
464
+ currency_code: SDG
465
+ SE:
466
+ eu_member: true
467
+ currency_code: SEK
468
+ postal_code_format: NNNNN
469
+ postal_code_regexp: !ruby/regexp '/\A\d{5}\z/'
470
+ SG:
471
+ currency_code: SGD
472
+ SH:
473
+ currency_code: SHP
474
+ SI:
475
+ eu_member: true
476
+ currency_code: EUR
477
+ postal_code_format: NNNN
478
+ postal_code_regexp: !ruby/regexp '/\A\d{4}\z/'
479
+ SJ:
480
+ currency_code: NOK
481
+ SK:
482
+ eu_member: true
483
+ currency_code: EUR
484
+ postal_code_format: NNNNN
485
+ postal_code_regexp: !ruby/regexp '/\A[089]\d{4}\z/'
486
+ SL:
487
+ currency_code: SLL
488
+ SM:
489
+ currency_code: EUR
490
+ SN:
491
+ currency_code: XOF
492
+ SO:
493
+ currency_code: SOS
494
+ SR:
495
+ currency_code: SRD
496
+ SS:
497
+ currency_code: SSP
498
+ ST:
499
+ currency_code: STN
500
+ SV:
501
+ currency_code: SVC
502
+ SX:
503
+ currency_code: ANG
504
+ SY:
505
+ currency_code: SYP
506
+ SZ:
507
+ currency_code: SZL
508
+ TC:
509
+ currency_code: USD
510
+ TD:
511
+ currency_code: XAF
512
+ TF:
513
+ currency_code: EUR
514
+ TG:
515
+ currency_code: XOF
516
+ TH:
517
+ currency_code: THB
518
+ TJ:
519
+ currency_code: TJS
520
+ TK:
521
+ currency_code: NZD
522
+ TL:
523
+ currency_code: USD
524
+ TM:
525
+ currency_code: TMT
526
+ TN:
527
+ currency_code: TND
528
+ TO:
529
+ currency_code: TOP
530
+ TR:
531
+ currency_code: TRY
532
+ TT:
533
+ currency_code: TTD
534
+ TV:
535
+ currency_code: AUD
536
+ TW:
537
+ currency_code: TWD
538
+ TZ:
539
+ currency_code: TZS
540
+ UA:
541
+ currency_code: UAH
542
+ UG:
543
+ currency_code: UGX
544
+ UM:
545
+ currency_code: USD
546
+ US:
547
+ currency_code: USD
548
+ UY:
549
+ currency_code: UYU
550
+ UZ:
551
+ currency_code: UZS
552
+ VA:
553
+ currency_code: EUR
554
+ VC:
555
+ currency_code: XCD
556
+ VE:
557
+ currency_code: VES
558
+ VG:
559
+ currency_code: USD
560
+ VI:
561
+ currency_code: USD
562
+ VN:
563
+ currency_code: VND
564
+ VU:
565
+ currency_code: VUV
566
+ WF:
567
+ currency_code: XPF
568
+ WS:
569
+ currency_code: WST
570
+ YE:
571
+ currency_code: YER
572
+ YT:
573
+ currency_code: EUR
574
+ ZA:
575
+ currency_code: ZAR
576
+ ZM:
577
+ currency_code: ZMW
578
+ ZW:
579
+ currency_code: ZWL