iso3166-countries 0.0.1 → 0.3.1

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: 46e129b041dd58cbe003f7694c78a819ee87e6a396681983923e8fd8e8e3cac5
4
- data.tar.gz: 5ee8cd4791a63ea349711f4e7e69acfa8254ce927499dfa5b3ed721df97e047b
3
+ metadata.gz: 62a830530ae738efe92803ef3a12ce398052272d182c8899213100926f3049f8
4
+ data.tar.gz: a31c514f5776e8e062de20c078d85b47bad2cf5cfa71aa0297a8f53463cb6421
5
5
  SHA512:
6
- metadata.gz: 74899457a19bdda95e2c9f229f3194913d97aee03d8296e387a062ef5a862c6fa4c4598a77f0c1e30957ed56ed029050026c31a454644cb1249e501ba1af2c53
7
- data.tar.gz: 40b7778efb0fe2e8af3eb8adbd29a8bc962c31f352dc6e3b8462bf9a4d3f871b6a3b16b6674881eb93d8b8e47f1acfc9dd7ac9a01a60bf5fc878f14308b5da57
6
+ metadata.gz: f3a828b908b817a6e8044cfd093fc3db3ab865ff90bc6147485b3fd04fad09ff3005802bf32c21cc65eb71dbfc3992bb8ae32b2e251ae4f12374cba546cac035
7
+ data.tar.gz: 97ee6ca0be721df95420a013a4f450215961a8dc60b80cdfa077c06f1cd2a1e3908eac811b848a0c533058188cebf4022ab4f91fbd9760f678a2a557f0b0d158
@@ -10,10 +10,10 @@ jobs:
10
10
  - name: Set up Ruby
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
13
- ruby-version: 3.0.0
13
+ ruby-version: 3.1.0
14
14
  - name: Run the default task
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/CHANGELOG.md CHANGED
@@ -5,3 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
+
9
+ ## 0.3.1
10
+
11
+ - GB postal code format and regexp
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,581 @@
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: \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: \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: \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: \A\d{4}\z
123
+ CZ:
124
+ eu_member: true
125
+ currency_code: CZK
126
+ postal_code_format: NNNNN
127
+ postal_code_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: \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: \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: \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: \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: \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: \A\d{5}\z
184
+ GA:
185
+ currency_code: XAF
186
+ GB:
187
+ postal_code_format: AANNNAA
188
+ postal_code_regexp: \A[A-Z]{1,2}\d{1,3}[A-Z]{1,2}(\d[A-Z]{2})?\z
189
+ currency_code: GBP
190
+ GD:
191
+ currency_code: XCD
192
+ GE:
193
+ currency_code: GEL
194
+ GF:
195
+ currency_code: EUR
196
+ GG:
197
+ currency_code: GBP
198
+ GH:
199
+ currency_code: GHS
200
+ GI:
201
+ currency_code: GIP
202
+ GL:
203
+ currency_code: DKK
204
+ GM:
205
+ currency_code: GMD
206
+ GN:
207
+ currency_code: GNF
208
+ GP:
209
+ currency_code: EUR
210
+ GQ:
211
+ currency_code: XAF
212
+ GR:
213
+ eu_member: true
214
+ currency_code: EUR
215
+ postal_code_format: NNNNN
216
+ postal_code_regexp: \A\d{5}\z
217
+ GS:
218
+ currency_code:
219
+ GT:
220
+ currency_code: GTQ
221
+ GU:
222
+ currency_code: USD
223
+ GW:
224
+ currency_code: XOF
225
+ GY:
226
+ currency_code: GYD
227
+ HK:
228
+ currency_code: HKD
229
+ HM:
230
+ currency_code: AUD
231
+ HN:
232
+ currency_code: HNL
233
+ HR:
234
+ eu_member: true
235
+ currency_code: HRK
236
+ postal_code_format: NNNNN
237
+ postal_code_regexp: \A\d{5}\z
238
+ HT:
239
+ currency_code: HTG
240
+ HU:
241
+ eu_member: true
242
+ currency_code: HUF
243
+ postal_code_format: NNNN
244
+ postal_code_regexp: \A\d{4}\z
245
+ ID:
246
+ currency_code: IDR
247
+ IE:
248
+ eu_member: true
249
+ currency_code: EUR
250
+ postal_code_format: ANAnAnAnAnAn
251
+ postal_code_regexp: \A([AC-FHKNPRTV-Y]\d{2}|D6W)[0-9AC-FHKNPRTV-Y]{4}\z
252
+ IL:
253
+ currency_code: ILS
254
+ IM:
255
+ currency_code: GBP
256
+ IN:
257
+ currency_code: INR
258
+ IO:
259
+ currency_code: USD
260
+ IQ:
261
+ currency_code: IQD
262
+ IR:
263
+ currency_code: IRR
264
+ IS:
265
+ currency_code: ISK
266
+ IT:
267
+ eu_member: true
268
+ currency_code: EUR
269
+ postal_code_format: NNNNN
270
+ postal_code_regexp: \A\d{5}\z
271
+ JE:
272
+ currency_code: GBP
273
+ JM:
274
+ currency_code: JMD
275
+ JO:
276
+ currency_code: JOD
277
+ JP:
278
+ currency_code: JPY
279
+ KE:
280
+ currency_code: KES
281
+ KG:
282
+ currency_code: KGS
283
+ KH:
284
+ currency_code: KHR
285
+ KI:
286
+ currency_code: AUD
287
+ KM:
288
+ currency_code: KMF
289
+ KN:
290
+ currency_code: XCD
291
+ KP:
292
+ currency_code: KPW
293
+ KR:
294
+ currency_code: KRW
295
+ KW:
296
+ currency_code: KWD
297
+ KY:
298
+ currency_code: KYD
299
+ KZ:
300
+ currency_code: KZT
301
+ LA:
302
+ currency_code: LAK
303
+ LB:
304
+ currency_code: LBP
305
+ LC:
306
+ currency_code: XCD
307
+ LI:
308
+ currency_code: CHF
309
+ LK:
310
+ currency_code: LKR
311
+ LR:
312
+ currency_code: LRD
313
+ LS:
314
+ currency_code: LSL
315
+ LT:
316
+ eu_member: true
317
+ currency_code: EUR
318
+ postal_code_format: NNNNN
319
+ postal_code_regexp: \A\d{5}\z
320
+ LU:
321
+ eu_member: true
322
+ currency_code: EUR
323
+ postal_code_format: NNNN
324
+ postal_code_regexp: \A\d{4}\z
325
+ LV:
326
+ eu_member: true
327
+ currency_code: EUR
328
+ postal_code_format: NNNN
329
+ postal_code_regexp: \A\d{4}\z
330
+ LY:
331
+ currency_code: LYD
332
+ MA:
333
+ currency_code: MAD
334
+ MC:
335
+ currency_code: EUR
336
+ MD:
337
+ currency_code: MDL
338
+ ME:
339
+ currency_code: EUR
340
+ MF:
341
+ currency_code: EUR
342
+ MG:
343
+ currency_code: MGA
344
+ MH:
345
+ currency_code: USD
346
+ MK:
347
+ currency_code: MKD
348
+ ML:
349
+ currency_code: XOF
350
+ MM:
351
+ currency_code: MMK
352
+ MN:
353
+ currency_code: MNT
354
+ MO:
355
+ currency_code: MOP
356
+ MP:
357
+ currency_code: USD
358
+ MQ:
359
+ currency_code: EUR
360
+ MR:
361
+ currency_code: MRU
362
+ MS:
363
+ currency_code: XCD
364
+ MT:
365
+ eu_member: true
366
+ currency_code: EUR
367
+ postal_code_format: AAANNNN
368
+ postal_code_regexp: ^[A-Z]{3}\d{4}$
369
+ MU:
370
+ currency_code: MUR
371
+ MV:
372
+ currency_code: MVR
373
+ MW:
374
+ currency_code: MWK
375
+ MX:
376
+ currency_code: MXN
377
+ MY:
378
+ currency_code: MYR
379
+ MZ:
380
+ currency_code: MZN
381
+ NA:
382
+ currency_code: NAD
383
+ NC:
384
+ currency_code: XPF
385
+ NE:
386
+ currency_code: XOF
387
+ NF:
388
+ currency_code: AUD
389
+ NG:
390
+ currency_code: NGN
391
+ NI:
392
+ currency_code: NIO
393
+ NL:
394
+ eu_member: true
395
+ currency_code: EUR
396
+ postal_code_format: "NNNNAA, NNNN AA"
397
+ postal_code_regexp: \A\d{4}\s?[A-Z]{2}\z
398
+ 'NO':
399
+ currency_code: NOK
400
+ NP:
401
+ currency_code: NPR
402
+ NR:
403
+ currency_code: AUD
404
+ NU:
405
+ currency_code: NZD
406
+ NZ:
407
+ currency_code: NZD
408
+ OM:
409
+ currency_code: OMR
410
+ PA:
411
+ currency_code: PAB
412
+ PE:
413
+ currency_code: PEN
414
+ PF:
415
+ currency_code: XPF
416
+ PG:
417
+ currency_code: PGK
418
+ PH:
419
+ currency_code: PHP
420
+ PK:
421
+ currency_code: PKR
422
+ PL:
423
+ eu_member: true
424
+ currency_code: PLN
425
+ postal_code_format: "NN-NNN, NNNNN"
426
+ postal_code_regexp: \A\d{2}-?\d{3}\z
427
+ PM:
428
+ currency_code: EUR
429
+ PN:
430
+ currency_code: NZD
431
+ PR:
432
+ currency_code: USD
433
+ PS:
434
+ currency_code:
435
+ PT:
436
+ eu_member: true
437
+ currency_code: EUR
438
+ postal_code_format: "NNNN-NNN, NNNNNNN"
439
+ postal_code_regexp: \A\d{4}(-?\d{3})?\z
440
+ PW:
441
+ currency_code: USD
442
+ PY:
443
+ currency_code: PYG
444
+ QA:
445
+ currency_code: QAR
446
+ RE:
447
+ currency_code: EUR
448
+ RO:
449
+ eu_member: true
450
+ currency_code: RON
451
+ postal_code_format: NNNNNN
452
+ postal_code_regexp: \A\d{6}\z
453
+ RS:
454
+ currency_code: RSD
455
+ RU:
456
+ currency_code: RUB
457
+ RW:
458
+ currency_code: RWF
459
+ SA:
460
+ currency_code: SAR
461
+ SB:
462
+ currency_code: SBD
463
+ SC:
464
+ currency_code: SCR
465
+ SD:
466
+ currency_code: SDG
467
+ SE:
468
+ eu_member: true
469
+ currency_code: SEK
470
+ postal_code_format: NNNNN
471
+ postal_code_regexp: \A\d{5}\z
472
+ SG:
473
+ currency_code: SGD
474
+ SH:
475
+ currency_code: SHP
476
+ SI:
477
+ eu_member: true
478
+ currency_code: EUR
479
+ postal_code_format: NNNN
480
+ postal_code_regexp: \A\d{4}\z
481
+ SJ:
482
+ currency_code: NOK
483
+ SK:
484
+ eu_member: true
485
+ currency_code: EUR
486
+ postal_code_format: NNNNN
487
+ postal_code_regexp: \A[089]\d{4}\z
488
+ SL:
489
+ currency_code: SLL
490
+ SM:
491
+ currency_code: EUR
492
+ SN:
493
+ currency_code: XOF
494
+ SO:
495
+ currency_code: SOS
496
+ SR:
497
+ currency_code: SRD
498
+ SS:
499
+ currency_code: SSP
500
+ ST:
501
+ currency_code: STN
502
+ SV:
503
+ currency_code: SVC
504
+ SX:
505
+ currency_code: ANG
506
+ SY:
507
+ currency_code: SYP
508
+ SZ:
509
+ currency_code: SZL
510
+ TC:
511
+ currency_code: USD
512
+ TD:
513
+ currency_code: XAF
514
+ TF:
515
+ currency_code: EUR
516
+ TG:
517
+ currency_code: XOF
518
+ TH:
519
+ currency_code: THB
520
+ TJ:
521
+ currency_code: TJS
522
+ TK:
523
+ currency_code: NZD
524
+ TL:
525
+ currency_code: USD
526
+ TM:
527
+ currency_code: TMT
528
+ TN:
529
+ currency_code: TND
530
+ TO:
531
+ currency_code: TOP
532
+ TR:
533
+ currency_code: TRY
534
+ TT:
535
+ currency_code: TTD
536
+ TV:
537
+ currency_code: AUD
538
+ TW:
539
+ currency_code: TWD
540
+ TZ:
541
+ currency_code: TZS
542
+ UA:
543
+ currency_code: UAH
544
+ UG:
545
+ currency_code: UGX
546
+ UM:
547
+ currency_code: USD
548
+ US:
549
+ currency_code: USD
550
+ UY:
551
+ currency_code: UYU
552
+ UZ:
553
+ currency_code: UZS
554
+ VA:
555
+ currency_code: EUR
556
+ VC:
557
+ currency_code: XCD
558
+ VE:
559
+ currency_code: VES
560
+ VG:
561
+ currency_code: USD
562
+ VI:
563
+ currency_code: USD
564
+ VN:
565
+ currency_code: VND
566
+ VU:
567
+ currency_code: VUV
568
+ WF:
569
+ currency_code: XPF
570
+ WS:
571
+ currency_code: WST
572
+ YE:
573
+ currency_code: YER
574
+ YT:
575
+ currency_code: EUR
576
+ ZA:
577
+ currency_code: ZAR
578
+ ZM:
579
+ currency_code: ZMW
580
+ ZW:
581
+ currency_code: ZWL