worldwide 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/db/data/regions/DK.yml +1 -0
- data/lib/worldwide/region.rb +6 -5
- data/lib/worldwide/version.rb +1 -1
- data/lib/worldwide/zip.rb +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a941ce0c45311eb558bbe78d3585613c38da718f2880533182d39ac8b1017b
|
4
|
+
data.tar.gz: 8553b4c0e92338eeec626987ccbde3e28b3e8bd3b3f7eee82ae0c4315b519a23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 676b6e8903ef04b777c44ea464d7d77413a67f5b69993d4c3821252e554ee093ec07dde4f147684e2ad5cd57a8c5245beab11d116f19e74fd24fffba1ec4284d
|
7
|
+
data.tar.gz: 15f67c2fdda70190a1742144577600f067b05e1f769785c582e7d44d858b8597b9263a3b604b1eed03ae6a0e0d3400afe6bdf67d47e836184645b95c178aa0ce
|
data/CHANGELOG.md
CHANGED
@@ -31,6 +31,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
31
31
|
|
32
32
|
---
|
33
33
|
|
34
|
+
[0.6.1] - 2023-12-11
|
35
|
+
|
36
|
+
- Allow building number in address2 for DK [#53](https://github.com/Shopify/worldwide/pull/53)
|
37
|
+
- Avoid .present? and .blank? so we don't require Rails [#57](https://github.com/Shopify/worldwide/pull/57)
|
38
|
+
- (bugfix) Zone lookup by name [#58](https://github.com/Shopify/worldwid/pull/58)
|
39
|
+
|
34
40
|
[0.6.0] - 2023-12-08
|
35
41
|
|
36
42
|
- Add localized concern messages for address1 + 2 warnings and address may not exist message [#54](https://github.com/Shopify/worldwide/pull/54)
|
data/Gemfile.lock
CHANGED
data/db/data/regions/DK.yml
CHANGED
data/lib/worldwide/region.rb
CHANGED
@@ -373,9 +373,10 @@ module Worldwide
|
|
373
373
|
search_name = name.upcase
|
374
374
|
|
375
375
|
zones.find do |region|
|
376
|
-
search_name == region.legacy_name
|
377
|
-
search_name ==
|
378
|
-
search_name ==
|
376
|
+
search_name == region.legacy_name&.upcase ||
|
377
|
+
region.name_alternates&.any? { |a| search_name == a.upcase } ||
|
378
|
+
search_name == region.full_name&.upcase ||
|
379
|
+
search_name == I18n.with_locale(:en) { region.full_name&.upcase }
|
379
380
|
end
|
380
381
|
else # Worldwide::Util.present?(zip)
|
381
382
|
zone_by_normalized_zip(Zip.normalize(country_code: iso_code, zip: zip))
|
@@ -444,7 +445,7 @@ module Worldwide
|
|
444
445
|
# Returns true if this country has zones defined, and has postal code prefix data for the zones
|
445
446
|
def has_zip_prefixes?
|
446
447
|
@zones&.any? do |zone|
|
447
|
-
zone.zip_prefixes
|
448
|
+
Util.present?(zone.zip_prefixes)
|
448
449
|
end
|
449
450
|
end
|
450
451
|
|
@@ -471,7 +472,7 @@ module Worldwide
|
|
471
472
|
|
472
473
|
adjusted_value = partial_match ? value.strip : value
|
473
474
|
|
474
|
-
Regexp.new(regex_prefix).match(adjusted_value)
|
475
|
+
Util.present?(Regexp.new(regex_prefix).match(adjusted_value))
|
475
476
|
end
|
476
477
|
|
477
478
|
# Search a list of zip prefixes (by province or timezone) to find the element that corresponds to the zip
|
data/lib/worldwide/version.rb
CHANGED
data/lib/worldwide/zip.rb
CHANGED
@@ -50,7 +50,7 @@ module Worldwide
|
|
50
50
|
# @param min_confidence [Integer] The minimum confidence level (between 0-100) that is accepted from a suggestion (optional)
|
51
51
|
# @return [Region] which is a "country" if we have a suggestion, or `nil` if we do not.
|
52
52
|
def find_country(country_code: nil, zip:, min_confidence: 0)
|
53
|
-
return nil unless
|
53
|
+
return nil unless Util.present?(zip)
|
54
54
|
|
55
55
|
country = Worldwide.region(code: country_code) unless country_code.nil?
|
56
56
|
return country if country&.valid_zip?(zip)
|
@@ -68,8 +68,8 @@ module Worldwide
|
|
68
68
|
# We'll see if we have only a single suggestion and, if so, return it.
|
69
69
|
# In cases where there's more than one possible match, we'll return nil.
|
70
70
|
suggestions = find_country_using_zip_alone(adjusted_zip)
|
71
|
-
suggestion = suggestions.first[0] unless
|
72
|
-
confidence = suggestions.first[1] unless
|
71
|
+
suggestion = suggestions.first[0] unless Util.blank?(suggestions)
|
72
|
+
confidence = suggestions.first[1] unless Util.blank?(suggestions)
|
73
73
|
|
74
74
|
return suggestion if suggestions.length == 1 && confidence && confidence >= min_confidence
|
75
75
|
|
@@ -90,7 +90,7 @@ module Worldwide
|
|
90
90
|
|
91
91
|
if allow_autofill
|
92
92
|
autofill = country.autofill_zip
|
93
|
-
return autofill if
|
93
|
+
return autofill if Util.present?(autofill)
|
94
94
|
end
|
95
95
|
|
96
96
|
return nil if zip.nil?
|
@@ -163,7 +163,7 @@ module Worldwide
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def strip_optional_country_prefix(country_code:, zip:)
|
166
|
-
return zip if
|
166
|
+
return zip if Util.blank?(zip)
|
167
167
|
|
168
168
|
unless OPTIONAL_PREFIX_COUNTRIES.include?(country_code&.to_sym)
|
169
169
|
return zip
|
@@ -604,7 +604,7 @@ module Worldwide
|
|
604
604
|
return zip
|
605
605
|
end
|
606
606
|
|
607
|
-
return zip if
|
607
|
+
return zip if Util.blank?(zip)
|
608
608
|
|
609
609
|
autocorrected_zips = []
|
610
610
|
input = zip
|
@@ -727,7 +727,7 @@ module Worldwide
|
|
727
727
|
end
|
728
728
|
|
729
729
|
def normalize_for_bd(zip:)
|
730
|
-
return zip if
|
730
|
+
return zip if Util.blank?(zip)
|
731
731
|
|
732
732
|
m = zip.match(/^(GPO:?|DHAKA)(\d{4})$/)
|
733
733
|
if m.nil?
|
@@ -834,10 +834,10 @@ module Worldwide
|
|
834
834
|
return zip if zip.nil?
|
835
835
|
|
836
836
|
m = zip.match(/^0?0?0?0?([1-9])0?0?$/)
|
837
|
-
return "00#{m[1]}00" if
|
837
|
+
return "00#{m[1]}00" if Util.present?(m)
|
838
838
|
|
839
839
|
m = zip.match(/^0?0?1([1-9])0?0?$/)
|
840
|
-
return "01#{m[1]}00" if
|
840
|
+
return "01#{m[1]}00" if Util.present?(m)
|
841
841
|
|
842
842
|
if zip.match?(/^[1-9][0-9]00$/)
|
843
843
|
"#{zip}0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worldwide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|