worldwide 0.6.1 → 0.6.3
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/db/data/regions/GS.yml +2 -2
- data/db/data/regions/HM.yml +2 -2
- data/db/data/regions/TF.yml +2 -2
- data/lib/worldwide/region.rb +20 -9
- data/lib/worldwide/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e612eada41704a41e5aa1b7dfce0cb4d94d81c9a8022c6392e45e57ee3f4aa62
|
4
|
+
data.tar.gz: 7ff48a7f2d370b615d07c8410f62bb1464ea64be2cbd8da7e7a17a443846f1bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e2d6a9985fe09d8ed9fa5179e1525e56cd24c2603e8f4317f0ce6fe15a0cc1692738042defdc8be28fa3667e54b65b8a0e58995660e025fcfeefe4850f3bfb
|
7
|
+
data.tar.gz: e4696a9bec42809f27a803a1d39a8413eec5656666133602644faeb292fb9a0fcebf1fc64c6fd9cf8f9bd84d9b2073f34120cfcc98d6c3631b71f13d6a60fef9
|
data/CHANGELOG.md
CHANGED
@@ -31,6 +31,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
31
31
|
|
32
32
|
---
|
33
33
|
|
34
|
+
[0.6.3] - 2023-12-11
|
35
|
+
|
36
|
+
- Change HM, TF and GS `group_name` to respective continents based on M49. [#60](https://github.com/Shopify/worldwide/pull/60)
|
37
|
+
|
38
|
+
[0.6.2] - 2023-12-11
|
39
|
+
|
40
|
+
- Zone lookup by Hash [#61](https://github.com/Shopify/worldwide/pull/61)
|
41
|
+
|
34
42
|
[0.6.1] - 2023-12-11
|
35
43
|
|
36
44
|
- Allow building number in address2 for DK [#53](https://github.com/Shopify/worldwide/pull/53)
|
data/Gemfile.lock
CHANGED
data/db/data/regions/GS.yml
CHANGED
data/db/data/regions/HM.yml
CHANGED
data/db/data/regions/TF.yml
CHANGED
data/lib/worldwide/region.rb
CHANGED
@@ -249,6 +249,7 @@ module Worldwide
|
|
249
249
|
|
250
250
|
@parents = [].to_set
|
251
251
|
@zones = []
|
252
|
+
@zones_by_code = {}
|
252
253
|
end
|
253
254
|
|
254
255
|
def inspect
|
@@ -262,6 +263,7 @@ module Worldwide
|
|
262
263
|
|
263
264
|
region.parents << self
|
264
265
|
@zones.append(region)
|
266
|
+
add_zone_to_hash(region)
|
265
267
|
end
|
266
268
|
|
267
269
|
# Attributes
|
@@ -320,6 +322,7 @@ module Worldwide
|
|
320
322
|
# A user-facing name in the currently-active locale's language.
|
321
323
|
def full_name(locale: I18n.locale)
|
322
324
|
lookup_code = cldr_code
|
325
|
+
|
323
326
|
if /^[0-9]+$/.match?(lookup_code) || lookup_code.length < 3
|
324
327
|
Worldwide::Cldr.t("territories.#{lookup_code}", locale: locale, default: legacy_name)
|
325
328
|
else
|
@@ -358,17 +361,14 @@ module Worldwide
|
|
358
361
|
if Worldwide::Util.present?(code)
|
359
362
|
search_code = code.to_s.upcase
|
360
363
|
alt_search_code = "#{search_code[0..1]}-#{search_code[2..-1]}"
|
364
|
+
zone = nil
|
361
365
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
candidate == region.alpha_three ||
|
366
|
-
candidate == region.iso_code ||
|
367
|
-
candidate == region.legacy_code ||
|
368
|
-
candidate == region.numeric_three ||
|
369
|
-
region&.code_alternates&.any?(candidate)
|
370
|
-
end
|
366
|
+
[search_code, alt_search_code].each do |candidate|
|
367
|
+
zone = @zones_by_code[candidate]
|
368
|
+
break if zone
|
371
369
|
end
|
370
|
+
|
371
|
+
return zone unless zone.nil?
|
372
372
|
elsif Worldwide::Util.present?(name)
|
373
373
|
search_name = name.upcase
|
374
374
|
|
@@ -414,6 +414,17 @@ module Worldwide
|
|
414
414
|
|
415
415
|
private
|
416
416
|
|
417
|
+
def add_zone_to_hash(zone)
|
418
|
+
@zones_by_code[subdivision_code(zone.iso_code)] = zone if Util.present?(subdivision_code(zone.iso_code))
|
419
|
+
@zones_by_code[zone.alpha_three] = zone if Util.present?(zone.alpha_three)
|
420
|
+
@zones_by_code[zone.iso_code] = zone if Util.present?(zone.iso_code)
|
421
|
+
@zones_by_code[zone.legacy_code] = zone if Util.present?(zone.legacy_code)
|
422
|
+
@zones_by_code[zone.numeric_three] = zone if Util.present?(zone.numeric_three)
|
423
|
+
zone.code_alternates&.each do |code|
|
424
|
+
@zones_by_code[code] = zone
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
417
428
|
def answers_to_cldr_code(search_code)
|
418
429
|
return false if Util.blank?(search_code) || Util.blank?(cldr_code)
|
419
430
|
return true if search_code.casecmp(cldr_code).zero?
|
data/lib/worldwide/version.rb
CHANGED