worldwide 1.26.3 → 1.28.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: c7fafadf542d060d153b05e52fd503b7eba9c2348448c5206586fcea77148038
4
- data.tar.gz: 93a6f8ec9eab7a34f9641c3fa004b6ab343f1eb8eb26ca6b870cfd305d9acfb9
3
+ metadata.gz: 909c8730bf69311da55d2880b5b246d70af5df8eedc3e9de3c162f537b585188
4
+ data.tar.gz: 2a7eb3d5613c11b63719ea415acec13b5347496284faa44b28223bd93420bd5d
5
5
  SHA512:
6
- metadata.gz: 695024436d230a8cf893dfce768b8218428617d6ae1ebf13242e247367f16cf8982664d3ad19f9bf9e23402e1b6878698c54bc08c872f77eb8dbe94fbf23ee2b
7
- data.tar.gz: '07621898fa7e6641e769f27aab9c5d70bff151a38ce6216eade00a3b911b279383a1ecc9f266c66193b64b4629adb56357cc7f6195de51b03fa43076b1a39022'
6
+ metadata.gz: 6ece942742ed16568e01763b5ef6033f05f873e9cbfb6fae933dfa3b5552bb81210e7c57f0f78dd916c1680c8b05f9c60e64da4901744a28d00dc7a01f337ae3
7
+ data.tar.gz: 5af292484d8cbe28f47ddf2acc3976d31c5fba811e140b9222844b3234cfbce3d14682bab4b4167ac684052772b614c7d97a1e7734b98dd0b550e23f0f1548bd
data/CHANGELOG.md CHANGED
@@ -29,6 +29,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
29
29
 
30
30
  ---
31
31
 
32
+ ## [1.28.0] - 2026-09-21
33
+
34
+ - Add `Region#iso_3166_code_assigned?` to distinguish currently assigned ISO 3166-1 alpha-2 codes from other region codes. [#598](https://github.com/Shopify/worldwide/pull/598)
35
+ - Reject malformed currency codes before caching. [#596](https://github.com/Shopify/worldwide/pull/596)
36
+ - Add IE Eircode routing keys `N39` (Longford) and `N41` (Carrick-on-Shannon) to each other's `zips_crossing_provinces` entries, so both are valid for Longford and Leitrim. [#601](https://github.com/Shopify/worldwide/pull/601)
37
+ - Avoid retaining unknown locale codes in the global locale cache. [#597](https://github.com/Shopify/worldwide/pull/597)
38
+ - Avoid excessive backtracking in Dutch address fallback parsing. [#599](https://github.com/Shopify/worldwide/pull/599)
39
+
40
+ ---
41
+
42
+ ## [1.27.0] - 2026-09-11
43
+ - Add the 81 province (il) zones for Türkiye (`TR-01`..`TR-81`), staged behind `ignore_provinces` and `hide_provinces_from_addresses`. Each zone carries its plaka number as a `zip_prefix`, so a province can be inferred from the postal code. Address forms and validation are unchanged until the flags are removed.
44
+
45
+ ---
46
+
32
47
  ## [1.26.3] - 2026-09-01
33
48
  - Select CLDR storage based on i18n's config behavior instead of Ruby's Fiber API. [#586](https://github.com/Shopify/worldwide/pull/586)
34
49
  - No longer require building number for Chile. [#585](https://github.com/Shopify/worldwide/pull/585)
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- worldwide (1.26.3)
16
+ worldwide (1.28.0)
17
17
  activesupport (>= 7.0)
18
18
  i18n (>= 1.15)
19
19
  phonelib (~> 0.8)
@@ -137,6 +137,7 @@ PLATFORMS
137
137
  arm64-darwin-22
138
138
  arm64-darwin-23
139
139
  arm64-darwin-24
140
+ arm64-darwin-25
140
141
  x86_64-linux
141
142
 
142
143
  DEPENDENCIES
data/README.md CHANGED
@@ -230,6 +230,7 @@ and also answer questions about its status:
230
230
  - `continent?`: is this region a continent?
231
231
  - `country?`: is this region a "country"? (Note that, for backward compatibility with legacy code in Shopify's ecosystem, we do not consider dependent territories of Spain and the United States to be countries, but we do consider dependencies of Australia, Britain, Denmark, Finland, France and Norway to be "countries")
232
232
  - `deprecated?`: has this territory ceased to exist? (e.g. `AN` which dissolved in 2010)
233
+ - `iso_3166_code_assigned?`: is this region's own code currently assigned in ISO 3166-1 alpha-2? Returns false for reserved, withdrawn, user-assigned, unknown, subdivision, and numeric region codes. This checks the resolved region's code, not the original lookup input.
233
234
 
234
235
  ```ruby
235
236
  $ ca = Worldwide.region(code: "CA")
@@ -0,0 +1,252 @@
1
+ ---
2
+ # Currently assigned ISO 3166-1 alpha-2 codes, checked on 2026-09-17.
3
+ # https://www.iso.org/iso-3166-country-codes.html
4
+ - AD
5
+ - AE
6
+ - AF
7
+ - AG
8
+ - AI
9
+ - AL
10
+ - AM
11
+ - AO
12
+ - AQ
13
+ - AR
14
+ - AS
15
+ - AT
16
+ - AU
17
+ - AW
18
+ - AX
19
+ - AZ
20
+ - BA
21
+ - BB
22
+ - BD
23
+ - BE
24
+ - BF
25
+ - BG
26
+ - BH
27
+ - BI
28
+ - BJ
29
+ - BL
30
+ - BM
31
+ - BN
32
+ - BO
33
+ - BQ
34
+ - BR
35
+ - BS
36
+ - BT
37
+ - BV
38
+ - BW
39
+ - BY
40
+ - BZ
41
+ - CA
42
+ - CC
43
+ - CD
44
+ - CF
45
+ - CG
46
+ - CH
47
+ - CI
48
+ - CK
49
+ - CL
50
+ - CM
51
+ - CN
52
+ - CO
53
+ - CR
54
+ - CU
55
+ - CV
56
+ - CW
57
+ - CX
58
+ - CY
59
+ - CZ
60
+ - DE
61
+ - DJ
62
+ - DK
63
+ - DM
64
+ - DO
65
+ - DZ
66
+ - EC
67
+ - EE
68
+ - EG
69
+ - EH
70
+ - ER
71
+ - ES
72
+ - ET
73
+ - FI
74
+ - FJ
75
+ - FK
76
+ - FM
77
+ - FO
78
+ - FR
79
+ - GA
80
+ - GB
81
+ - GD
82
+ - GE
83
+ - GF
84
+ - GG
85
+ - GH
86
+ - GI
87
+ - GL
88
+ - GM
89
+ - GN
90
+ - GP
91
+ - GQ
92
+ - GR
93
+ - GS
94
+ - GT
95
+ - GU
96
+ - GW
97
+ - GY
98
+ - HK
99
+ - HM
100
+ - HN
101
+ - HR
102
+ - HT
103
+ - HU
104
+ - ID
105
+ - IE
106
+ - IL
107
+ - IM
108
+ - IN
109
+ - IO
110
+ - IQ
111
+ - IR
112
+ - IS
113
+ - IT
114
+ - JE
115
+ - JM
116
+ - JO
117
+ - JP
118
+ - KE
119
+ - KG
120
+ - KH
121
+ - KI
122
+ - KM
123
+ - KN
124
+ - KP
125
+ - KR
126
+ - KW
127
+ - KY
128
+ - KZ
129
+ - LA
130
+ - LB
131
+ - LC
132
+ - LI
133
+ - LK
134
+ - LR
135
+ - LS
136
+ - LT
137
+ - LU
138
+ - LV
139
+ - LY
140
+ - MA
141
+ - MC
142
+ - MD
143
+ - ME
144
+ - MF
145
+ - MG
146
+ - MH
147
+ - MK
148
+ - ML
149
+ - MM
150
+ - MN
151
+ - MO
152
+ - MP
153
+ - MQ
154
+ - MR
155
+ - MS
156
+ - MT
157
+ - MU
158
+ - MV
159
+ - MW
160
+ - MX
161
+ - MY
162
+ - MZ
163
+ - NA
164
+ - NC
165
+ - NE
166
+ - NF
167
+ - NG
168
+ - NI
169
+ - NL
170
+ - 'NO'
171
+ - NP
172
+ - NR
173
+ - NU
174
+ - NZ
175
+ - OM
176
+ - PA
177
+ - PE
178
+ - PF
179
+ - PG
180
+ - PH
181
+ - PK
182
+ - PL
183
+ - PM
184
+ - PN
185
+ - PR
186
+ - PS
187
+ - PT
188
+ - PW
189
+ - PY
190
+ - QA
191
+ - RE
192
+ - RO
193
+ - RS
194
+ - RU
195
+ - RW
196
+ - SA
197
+ - SB
198
+ - SC
199
+ - SD
200
+ - SE
201
+ - SG
202
+ - SH
203
+ - SI
204
+ - SJ
205
+ - SK
206
+ - SL
207
+ - SM
208
+ - SN
209
+ - SO
210
+ - SR
211
+ - SS
212
+ - ST
213
+ - SV
214
+ - SX
215
+ - SY
216
+ - SZ
217
+ - TC
218
+ - TD
219
+ - TF
220
+ - TG
221
+ - TH
222
+ - TJ
223
+ - TK
224
+ - TL
225
+ - TM
226
+ - TN
227
+ - TO
228
+ - TR
229
+ - TT
230
+ - TV
231
+ - TW
232
+ - TZ
233
+ - UA
234
+ - UG
235
+ - UM
236
+ - US
237
+ - UY
238
+ - UZ
239
+ - VA
240
+ - VC
241
+ - VE
242
+ - VG
243
+ - VI
244
+ - VN
245
+ - VU
246
+ - WF
247
+ - WS
248
+ - YE
249
+ - YT
250
+ - ZA
251
+ - ZM
252
+ - ZW
data/data/regions/IE.yml CHANGED
@@ -643,10 +643,12 @@ zips_crossing_provinces:
643
643
  - LD
644
644
  - CN
645
645
  - RN
646
+ - LM
646
647
  N41:
647
648
  - LM
648
649
  - CN
649
650
  - RN
651
+ - LD
650
652
  P36:
651
653
  - CO
652
654
  - WD
data/data/regions/NL.yml CHANGED
@@ -33,7 +33,8 @@ format:
33
33
  format_extended:
34
34
  edit: "{country}_{firstName}{lastName}_{company}_{streetName}{streetNumber}_{address2}_{zip}{city}_{phone}"
35
35
  address1_regex:
36
- - "^(?<streetName>(?:\\d+[a-z]+\\s+)?[^\\d]+)\\s+(?<streetNumber>\\d+(?:-[A-Za-z0-9]+)?(?: ?[A-Za-z])?)$"
36
+ # streetName already consumes extra whitespace; repeated separators cause backtracking.
37
+ - "^(?<streetName>(?:\\d+[a-z]+\\s)?[^\\d]+)\\s(?<streetNumber>\\d+(?:-[A-Za-z0-9]+)?(?: ?[A-Za-z])?)$"
37
38
  additional_address_fields:
38
39
  - name: streetName
39
40
  required: true
data/data/regions/TR.yml CHANGED
@@ -6,6 +6,8 @@ currency: TRY
6
6
  unit_system: metric
7
7
  tax_name: KDV
8
8
  tax_inclusive: true
9
+ ignore_provinces: true
10
+ hide_provinces_from_addresses: true
9
11
  group: European Countries
10
12
  group_name: Europe
11
13
  zip_example: '01960'
@@ -34,7 +36,497 @@ languages:
34
36
  example_address:
35
37
  address1: Küçük Ayasofya Mahallesi
36
38
  address2: Camii Sokagi No:20 ⁠Küçük Ayasofya
37
- city: Fatih/İstanbul
39
+ city: Fatih
38
40
  zip: '34122'
41
+ province_code: TR-34
39
42
  phone: "+90 212 491 16 63"
40
43
  timezone: Europe/Istanbul
44
+ zones:
45
+ - name: Adana
46
+ code: TR-01
47
+ iso_code: TR-01
48
+ tax: 0.0
49
+ zip_prefixes:
50
+ - '01'
51
+ - name: Adıyaman
52
+ code: TR-02
53
+ iso_code: TR-02
54
+ tax: 0.0
55
+ zip_prefixes:
56
+ - '02'
57
+ - name: Afyonkarahisar
58
+ code: TR-03
59
+ iso_code: TR-03
60
+ tax: 0.0
61
+ zip_prefixes:
62
+ - '03'
63
+ - name: Ağrı
64
+ code: TR-04
65
+ iso_code: TR-04
66
+ tax: 0.0
67
+ zip_prefixes:
68
+ - '04'
69
+ - name: Aksaray
70
+ code: TR-68
71
+ iso_code: TR-68
72
+ tax: 0.0
73
+ zip_prefixes:
74
+ - '68'
75
+ - name: Amasya
76
+ code: TR-05
77
+ iso_code: TR-05
78
+ tax: 0.0
79
+ zip_prefixes:
80
+ - '05'
81
+ - name: Ankara
82
+ code: TR-06
83
+ iso_code: TR-06
84
+ tax: 0.0
85
+ zip_prefixes:
86
+ - '06'
87
+ - name: Antalya
88
+ code: TR-07
89
+ iso_code: TR-07
90
+ tax: 0.0
91
+ zip_prefixes:
92
+ - '07'
93
+ - name: Ardahan
94
+ code: TR-75
95
+ iso_code: TR-75
96
+ tax: 0.0
97
+ zip_prefixes:
98
+ - '75'
99
+ - name: Artvin
100
+ code: TR-08
101
+ iso_code: TR-08
102
+ tax: 0.0
103
+ zip_prefixes:
104
+ - '08'
105
+ - name: Aydın
106
+ code: TR-09
107
+ iso_code: TR-09
108
+ tax: 0.0
109
+ zip_prefixes:
110
+ - '09'
111
+ - name: Balıkesir
112
+ code: TR-10
113
+ iso_code: TR-10
114
+ tax: 0.0
115
+ zip_prefixes:
116
+ - '10'
117
+ - name: Bartın
118
+ code: TR-74
119
+ iso_code: TR-74
120
+ tax: 0.0
121
+ zip_prefixes:
122
+ - '74'
123
+ - name: Batman
124
+ code: TR-72
125
+ iso_code: TR-72
126
+ tax: 0.0
127
+ zip_prefixes:
128
+ - '72'
129
+ - name: Bayburt
130
+ code: TR-69
131
+ iso_code: TR-69
132
+ tax: 0.0
133
+ zip_prefixes:
134
+ - '69'
135
+ - name: Bilecik
136
+ code: TR-11
137
+ iso_code: TR-11
138
+ tax: 0.0
139
+ zip_prefixes:
140
+ - '11'
141
+ - name: Bingöl
142
+ code: TR-12
143
+ iso_code: TR-12
144
+ tax: 0.0
145
+ zip_prefixes:
146
+ - '12'
147
+ - name: Bitlis
148
+ code: TR-13
149
+ iso_code: TR-13
150
+ tax: 0.0
151
+ zip_prefixes:
152
+ - '13'
153
+ - name: Bolu
154
+ code: TR-14
155
+ iso_code: TR-14
156
+ tax: 0.0
157
+ zip_prefixes:
158
+ - '14'
159
+ - name: Burdur
160
+ code: TR-15
161
+ iso_code: TR-15
162
+ tax: 0.0
163
+ zip_prefixes:
164
+ - '15'
165
+ - name: Bursa
166
+ code: TR-16
167
+ iso_code: TR-16
168
+ tax: 0.0
169
+ zip_prefixes:
170
+ - '16'
171
+ - name: Çanakkale
172
+ code: TR-17
173
+ iso_code: TR-17
174
+ tax: 0.0
175
+ zip_prefixes:
176
+ - '17'
177
+ - name: Çankırı
178
+ code: TR-18
179
+ iso_code: TR-18
180
+ tax: 0.0
181
+ zip_prefixes:
182
+ - '18'
183
+ - name: Çorum
184
+ code: TR-19
185
+ iso_code: TR-19
186
+ tax: 0.0
187
+ zip_prefixes:
188
+ - '19'
189
+ - name: Denizli
190
+ code: TR-20
191
+ iso_code: TR-20
192
+ tax: 0.0
193
+ zip_prefixes:
194
+ - '20'
195
+ - name: Diyarbakır
196
+ code: TR-21
197
+ iso_code: TR-21
198
+ tax: 0.0
199
+ zip_prefixes:
200
+ - '21'
201
+ - name: Düzce
202
+ code: TR-81
203
+ iso_code: TR-81
204
+ tax: 0.0
205
+ zip_prefixes:
206
+ - '81'
207
+ - name: Edirne
208
+ code: TR-22
209
+ iso_code: TR-22
210
+ tax: 0.0
211
+ zip_prefixes:
212
+ - '22'
213
+ - name: Elazığ
214
+ code: TR-23
215
+ iso_code: TR-23
216
+ tax: 0.0
217
+ zip_prefixes:
218
+ - '23'
219
+ - name: Erzincan
220
+ code: TR-24
221
+ iso_code: TR-24
222
+ tax: 0.0
223
+ zip_prefixes:
224
+ - '24'
225
+ - name: Erzurum
226
+ code: TR-25
227
+ iso_code: TR-25
228
+ tax: 0.0
229
+ zip_prefixes:
230
+ - '25'
231
+ - name: Eskişehir
232
+ code: TR-26
233
+ iso_code: TR-26
234
+ tax: 0.0
235
+ zip_prefixes:
236
+ - '26'
237
+ - name: Gaziantep
238
+ code: TR-27
239
+ iso_code: TR-27
240
+ tax: 0.0
241
+ zip_prefixes:
242
+ - '27'
243
+ - name: Giresun
244
+ code: TR-28
245
+ iso_code: TR-28
246
+ tax: 0.0
247
+ zip_prefixes:
248
+ - '28'
249
+ - name: Gümüşhane
250
+ code: TR-29
251
+ iso_code: TR-29
252
+ tax: 0.0
253
+ zip_prefixes:
254
+ - '29'
255
+ - name: Hakkâri
256
+ code: TR-30
257
+ iso_code: TR-30
258
+ tax: 0.0
259
+ zip_prefixes:
260
+ - '30'
261
+ - name: Hatay
262
+ code: TR-31
263
+ iso_code: TR-31
264
+ tax: 0.0
265
+ zip_prefixes:
266
+ - '31'
267
+ - name: Iğdır
268
+ code: TR-76
269
+ iso_code: TR-76
270
+ tax: 0.0
271
+ zip_prefixes:
272
+ - '76'
273
+ - name: Isparta
274
+ code: TR-32
275
+ iso_code: TR-32
276
+ tax: 0.0
277
+ zip_prefixes:
278
+ - '32'
279
+ - name: Istanbul
280
+ code: TR-34
281
+ iso_code: TR-34
282
+ tax: 0.0
283
+ zip_prefixes:
284
+ - '34'
285
+ - name: Izmir
286
+ code: TR-35
287
+ iso_code: TR-35
288
+ tax: 0.0
289
+ zip_prefixes:
290
+ - '35'
291
+ - name: Kahramanmaraş
292
+ code: TR-46
293
+ iso_code: TR-46
294
+ tax: 0.0
295
+ zip_prefixes:
296
+ - '46'
297
+ - name: Karabük
298
+ code: TR-78
299
+ iso_code: TR-78
300
+ tax: 0.0
301
+ zip_prefixes:
302
+ - '78'
303
+ - name: Karaman
304
+ code: TR-70
305
+ iso_code: TR-70
306
+ tax: 0.0
307
+ zip_prefixes:
308
+ - '70'
309
+ - name: Kars
310
+ code: TR-36
311
+ iso_code: TR-36
312
+ tax: 0.0
313
+ zip_prefixes:
314
+ - '36'
315
+ - name: Kastamonu
316
+ code: TR-37
317
+ iso_code: TR-37
318
+ tax: 0.0
319
+ zip_prefixes:
320
+ - '37'
321
+ - name: Kayseri
322
+ code: TR-38
323
+ iso_code: TR-38
324
+ tax: 0.0
325
+ zip_prefixes:
326
+ - '38'
327
+ - name: Kilis
328
+ code: TR-79
329
+ iso_code: TR-79
330
+ tax: 0.0
331
+ zip_prefixes:
332
+ - '79'
333
+ - name: Kırıkkale
334
+ code: TR-71
335
+ iso_code: TR-71
336
+ tax: 0.0
337
+ zip_prefixes:
338
+ - '71'
339
+ - name: Kırklareli
340
+ code: TR-39
341
+ iso_code: TR-39
342
+ tax: 0.0
343
+ zip_prefixes:
344
+ - '39'
345
+ - name: Kırşehir
346
+ code: TR-40
347
+ iso_code: TR-40
348
+ tax: 0.0
349
+ zip_prefixes:
350
+ - '40'
351
+ - name: Kocaeli
352
+ code: TR-41
353
+ iso_code: TR-41
354
+ tax: 0.0
355
+ zip_prefixes:
356
+ - '41'
357
+ - name: Konya
358
+ code: TR-42
359
+ iso_code: TR-42
360
+ tax: 0.0
361
+ zip_prefixes:
362
+ - '42'
363
+ - name: Kütahya
364
+ code: TR-43
365
+ iso_code: TR-43
366
+ tax: 0.0
367
+ zip_prefixes:
368
+ - '43'
369
+ - name: Malatya
370
+ code: TR-44
371
+ iso_code: TR-44
372
+ tax: 0.0
373
+ zip_prefixes:
374
+ - '44'
375
+ - name: Manisa
376
+ code: TR-45
377
+ iso_code: TR-45
378
+ tax: 0.0
379
+ zip_prefixes:
380
+ - '45'
381
+ - name: Mardin
382
+ code: TR-47
383
+ iso_code: TR-47
384
+ tax: 0.0
385
+ zip_prefixes:
386
+ - '47'
387
+ - name: Mersin
388
+ code: TR-33
389
+ iso_code: TR-33
390
+ tax: 0.0
391
+ zip_prefixes:
392
+ - '33'
393
+ # Northern Cyprus is addressed via Türkiye as "Mersin 10" and uses the 99xxx postal code range
394
+ - '99'
395
+ - name: Muğla
396
+ code: TR-48
397
+ iso_code: TR-48
398
+ tax: 0.0
399
+ zip_prefixes:
400
+ - '48'
401
+ - name: Muş
402
+ code: TR-49
403
+ iso_code: TR-49
404
+ tax: 0.0
405
+ zip_prefixes:
406
+ - '49'
407
+ - name: Nevşehir
408
+ code: TR-50
409
+ iso_code: TR-50
410
+ tax: 0.0
411
+ zip_prefixes:
412
+ - '50'
413
+ - name: Niğde
414
+ code: TR-51
415
+ iso_code: TR-51
416
+ tax: 0.0
417
+ zip_prefixes:
418
+ - '51'
419
+ - name: Ordu
420
+ code: TR-52
421
+ iso_code: TR-52
422
+ tax: 0.0
423
+ zip_prefixes:
424
+ - '52'
425
+ - name: Osmaniye
426
+ code: TR-80
427
+ iso_code: TR-80
428
+ tax: 0.0
429
+ zip_prefixes:
430
+ - '80'
431
+ - name: Rize
432
+ code: TR-53
433
+ iso_code: TR-53
434
+ tax: 0.0
435
+ zip_prefixes:
436
+ - '53'
437
+ - name: Sakarya
438
+ code: TR-54
439
+ iso_code: TR-54
440
+ tax: 0.0
441
+ zip_prefixes:
442
+ - '54'
443
+ - name: Samsun
444
+ code: TR-55
445
+ iso_code: TR-55
446
+ tax: 0.0
447
+ zip_prefixes:
448
+ - '55'
449
+ - name: Şanlıurfa
450
+ code: TR-63
451
+ iso_code: TR-63
452
+ tax: 0.0
453
+ zip_prefixes:
454
+ - '63'
455
+ - name: Siirt
456
+ code: TR-56
457
+ iso_code: TR-56
458
+ tax: 0.0
459
+ zip_prefixes:
460
+ - '56'
461
+ - name: Sinop
462
+ code: TR-57
463
+ iso_code: TR-57
464
+ tax: 0.0
465
+ zip_prefixes:
466
+ - '57'
467
+ - name: Şırnak
468
+ code: TR-73
469
+ iso_code: TR-73
470
+ tax: 0.0
471
+ zip_prefixes:
472
+ - '73'
473
+ - name: Sivas
474
+ code: TR-58
475
+ iso_code: TR-58
476
+ tax: 0.0
477
+ zip_prefixes:
478
+ - '58'
479
+ - name: Tekirdağ
480
+ code: TR-59
481
+ iso_code: TR-59
482
+ tax: 0.0
483
+ zip_prefixes:
484
+ - '59'
485
+ - name: Tokat
486
+ code: TR-60
487
+ iso_code: TR-60
488
+ tax: 0.0
489
+ zip_prefixes:
490
+ - '60'
491
+ - name: Trabzon
492
+ code: TR-61
493
+ iso_code: TR-61
494
+ tax: 0.0
495
+ zip_prefixes:
496
+ - '61'
497
+ - name: Tunceli
498
+ code: TR-62
499
+ iso_code: TR-62
500
+ tax: 0.0
501
+ zip_prefixes:
502
+ - '62'
503
+ - name: Uşak
504
+ code: TR-64
505
+ iso_code: TR-64
506
+ tax: 0.0
507
+ zip_prefixes:
508
+ - '64'
509
+ - name: Van
510
+ code: TR-65
511
+ iso_code: TR-65
512
+ tax: 0.0
513
+ zip_prefixes:
514
+ - '65'
515
+ - name: Yalova
516
+ code: TR-77
517
+ iso_code: TR-77
518
+ tax: 0.0
519
+ zip_prefixes:
520
+ - '77'
521
+ - name: Yozgat
522
+ code: TR-66
523
+ iso_code: TR-66
524
+ tax: 0.0
525
+ zip_prefixes:
526
+ - '66'
527
+ - name: Zonguldak
528
+ code: TR-67
529
+ iso_code: TR-67
530
+ tax: 0.0
531
+ zip_prefixes:
532
+ - '67'
@@ -28,10 +28,10 @@ module Worldwide
28
28
 
29
29
  def initialize(code:)
30
30
  adjusted_code = code.to_s.upcase.rjust(3, "0")
31
- if adjusted_code.match?(/[A-Z][A-Z][A-Z]/)
31
+ if adjusted_code.match?(/\A[A-Z]{3}\z/)
32
32
  @currency_code = adjusted_code
33
33
  @numeric_code = Currencies.numeric_code_for(adjusted_code)
34
- elsif adjusted_code.match?(/[0-9]+/)
34
+ elsif adjusted_code.match?(/\A[0-9]{3}\z/)
35
35
  @currency_code = Currencies.alpha_code_for(adjusted_code)
36
36
  @numeric_code = adjusted_code
37
37
  else
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "set"
4
+
3
5
  module Worldwide
4
6
  class Region
5
7
  # When faced with the question, "Is a postal code required in this country?", we treat the answer
@@ -9,6 +11,12 @@ module Worldwide
9
11
  RECOMMENDED = "recommended"
10
12
  OPTIONAL = "optional"
11
13
 
14
+ ISO_3166_ASSIGNED_COUNTRY_CODES = YAML.safe_load_file(
15
+ File.join(Worldwide::Paths::DATA_ROOT, "iso_3166_assigned_country_codes.yml"),
16
+ freeze: true,
17
+ ).to_set.freeze
18
+ private_constant :ISO_3166_ASSIGNED_COUNTRY_CODES
19
+
12
20
  # Accpetable format types of the postal code.
13
21
  FORMAT_TYPES = {
14
22
  ALPHANUMERIC: "ALPHANUMERIC",
@@ -372,6 +380,11 @@ module Worldwide
372
380
  @deprecated
373
381
  end
374
382
 
383
+ # Is this region's own code currently assigned in ISO 3166-1 alpha-2?
384
+ def iso_3166_code_assigned?
385
+ ISO_3166_ASSIGNED_COUNTRY_CODES.include?(iso_code)
386
+ end
387
+
375
388
  # An Worldwide::Field that can be used to ask about the field, including
376
389
  # labels, error messages, and an autofill value if there is one.
377
390
  def field(key:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worldwide
4
- VERSION = "1.26.3"
4
+ VERSION = "1.28.0"
5
5
  end
data/lib/worldwide.rb CHANGED
@@ -69,7 +69,11 @@ module Worldwide
69
69
  end
70
70
 
71
71
  def locale(code:)
72
- @locales_cache[code] ||= Locale.new(code)
72
+ @locales_cache.fetch(code) do
73
+ locale = Locale.new(code)
74
+ @locales_cache[code] = locale if locales.include?(locale.code)
75
+ locale
76
+ end
73
77
  end
74
78
 
75
79
  def locales
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldwide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.26.3
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -4715,6 +4715,7 @@ files:
4715
4715
  - data/country_codes.yml
4716
4716
  - data/extant_outcodes.yml
4717
4717
  - data/iana_to_rails_time_zone.yml
4718
+ - data/iso_3166_assigned_country_codes.yml
4718
4719
  - data/other/currency/bg.yml
4719
4720
  - data/other/currency/cs.yml
4720
4721
  - data/other/currency/da.yml
@@ -8736,7 +8737,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
8736
8737
  - !ruby/object:Gem::Version
8737
8738
  version: '0'
8738
8739
  requirements: []
8739
- rubygems_version: 4.0.19
8740
+ rubygems_version: 4.0.21
8740
8741
  specification_version: 4
8741
8742
  summary: Internationalization and localization APIs
8742
8743
  test_files: []