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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 246832b6ca4adeaa2bb6e1dd5b236962316581b22ec49fa28db9d461e0065995
4
- data.tar.gz: '0569123a25ae7afae4dd9d09e7049e2c86dd26c8924f15a935916dbe982f128f'
3
+ metadata.gz: 43a941ce0c45311eb558bbe78d3585613c38da718f2880533182d39ac8b1017b
4
+ data.tar.gz: 8553b4c0e92338eeec626987ccbde3e28b3e8bd3b3f7eee82ae0c4315b519a23
5
5
  SHA512:
6
- metadata.gz: 93b987051a980e244e817f1194e69e5e61a61544064029a5fabfe8d1739e385e803b19608bc3f0e3487c707f4deebd7186db584f8ba560d29f6c9cdb34272963
7
- data.tar.gz: 4bd8196e846f3339f0f50607efe8a288a670563a087665e2082ed90d180d9f89b11b21c7976e3449961f9fc517f44022a1029d4c5b470ff06810455e312c0304
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
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- worldwide (0.6.0)
16
+ worldwide (0.6.1)
17
17
  activesupport (~> 7.0)
18
18
  i18n (~> 1.12.0)
19
19
  phonelib (~> 0.8)
@@ -18,6 +18,7 @@ zip_regex: "^(DK( |-)?)?(?!38\\d{2}|39\\d{2})((0[89]\\d{2})|([1-9]\\d{3}))$"
18
18
  zip_example: '8660'
19
19
  phone_number_prefix: 45
20
20
  building_number_required: true
21
+ building_number_may_be_in_address2: true
21
22
  week_start_day: monday
22
23
  languages:
23
24
  - da
@@ -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.upcase ||
377
- search_name == region.full_name.upcase ||
378
- search_name == I18n.with_locale(:en) { region.full_name.upcase }
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.present?
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).present?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worldwide
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
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 zip.present?
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 suggestions.blank?
72
- confidence = suggestions.first[1] unless suggestions.blank?
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 autofill.present?
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 zip.blank?
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 zip.blank?
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 zip.blank?
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 m.present?
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 m.present?
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.0
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-08 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport