worldwide 0.1.1 → 0.2.0

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: 5239439f9dda5abcf62fc8cbb59343a420a34ef5abe96c7b6cd23a17a633623a
4
- data.tar.gz: 8438623520e1065231f78707ebaadeee25c0bd2f5ec4f795cbde00284a69fd45
3
+ metadata.gz: 2c3c323e57e56b609ebdc7fe5d7965a2d5348fede9b72110627528529b3b7ab5
4
+ data.tar.gz: f4007e0986bc9702af7d95f3c352a11937292d9f6fbbd8c21e8a1a635fcc7993
5
5
  SHA512:
6
- metadata.gz: 578e7e33cf986cda84b85c4d9e2f1092d13e3fd513b63667ee757cc6bbc937b84855ca4718a262ea5b6ecffa4203924a7fc1c5395fde98582c31adda4e1ab78d
7
- data.tar.gz: 2e28c5c0b5823979d7114b466e931429ec7376a90d1e1eb7de34c93a9dff059068ae65b548f0f3cf0f75c29c6f16051f9050ae1eb337ac51486ed0949d31c54c
6
+ metadata.gz: 333628df88179b5d2696634f3dadec1a548a5a2ef4baebcac86832077565f5f826036da107cdf8d5d4ed84323563235265df4b0bf37648f7d7691ef120e81216
7
+ data.tar.gz: cdbad17228b52fc39d188fdbf2e13800aa4015caf18cd314d9cdfcd7f3a7b63f585c2cbd69eec36bb8c450dae83e649c35a0c661c651e55293c626582e03a785
data/CHANGELOG.md CHANGED
@@ -28,6 +28,14 @@ Nil.
28
28
 
29
29
  ---
30
30
 
31
+ [0.2.0] - 2023-11-01
32
+
33
+ - Add Region#group and Region#group_name [#15](https://github.com/Shopify/worldwide/pull/15)
34
+ - Ensure Region#has_zip? returns a boolean for all regions [#17](https://github.com/Shopify/worldwide/pull/17)
35
+ - Zip normalization bugfix when parent isocode is not set [#6](https://github.com/Shopify/worldwide/pull/6)
36
+ - Update region parent when alternates are defined [#18](https://github.com/Shopify/worldwide/pull/18)
37
+ - Add partial matching for Region#valid_zip? [#19](https://github.com/Shopify/worldwide/pull/19)
38
+
31
39
  [0.1.1] - 2023-10-27
32
40
 
33
41
  - Fix issue with deploy to rubygems.org failing
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- worldwide (0.1.1)
16
+ worldwide (0.2.0)
17
17
  activesupport (~> 7.0)
18
18
  i18n (~> 1.12.0)
19
19
  phonelib (~> 0.8)
data/README.md CHANGED
@@ -99,7 +99,7 @@ Worldwide exposes the notion of a "region", or political subdivision. This can
99
99
 
100
100
  Note that, when exposing geographic information to users, you should be careful what you refer
101
101
  to as a "country". For backward compatibility with historical APIs, we use the term "country"
102
- to refer to what CLDR refers to as a "territory", and what we describe in our user interfarce as
102
+ to refer to what CLDR refers to as a "territory", and what we describe in our user interface as
103
103
  a "country / region". Examples of such entities include Canada, the United States, and Russia,
104
104
  but also territories with a "dual" status such as Guernsey, Hong Kong, and Martinique.
105
105
 
@@ -19,6 +19,8 @@ module Worldwide
19
19
  :example_city,
20
20
  :flag,
21
21
  :format,
22
+ :group,
23
+ :group_name,
22
24
  :cldr_code,
23
25
  :iso_code,
24
26
  :languages,
@@ -65,6 +67,14 @@ module Worldwide
65
67
  # - show: how to arrange the fields when formatting an address for display
66
68
  attr_accessor :format
67
69
 
70
+ # The string that results from appending " Countries" to the adjectival form of the {group_name}
71
+ # @example
72
+ # CountryDb.country(code: "CA").group == "North American Countries"
73
+ attr_accessor :group
74
+
75
+ # The continent that this region is part of.
76
+ attr_accessor :group_name
77
+
68
78
  # If this flag is set, then we support provinces "under the hood" for this country, but we do not
69
79
  # show them as part of a formatted address. If the province is missing, we will auto-infer it
70
80
  # based on the zip (note that this auto-inference may be wrong for some addresses near a border).
@@ -210,6 +220,8 @@ module Worldwide
210
220
  @currency = nil
211
221
  @flag = nil
212
222
  @format = {}
223
+ @group = nil
224
+ @group_name = nil
213
225
  @languages = []
214
226
  @neighbours = []
215
227
  @partial_zip_regex = nil
@@ -289,7 +301,7 @@ module Worldwide
289
301
 
290
302
  # Does this region have postal codes?
291
303
  def has_zip?
292
- format["show"]&.include?("{zip}")
304
+ !!format["show"]&.include?("{zip}")
293
305
  end
294
306
 
295
307
  # Is this Region considered a "province" (political subdivision of a "country")?
@@ -357,12 +369,12 @@ module Worldwide
357
369
  end
358
370
 
359
371
  # is the given postal code value valid for this region?
360
- def valid_zip?(zip)
372
+ def valid_zip?(zip, partial_match: false)
361
373
  normalized = Zip.normalize(
362
- country_code: province? ? parent.iso_code : iso_code,
374
+ country_code: province? && parent.iso_code ? parent.iso_code : iso_code,
363
375
  zip: zip,
364
376
  )
365
- valid_normalized_zip?(normalized)
377
+ valid_normalized_zip?(normalized, partial_match: partial_match)
366
378
  end
367
379
 
368
380
  # are zones optional for this region?
@@ -46,6 +46,9 @@ module Worldwide
46
46
  @regions << current_region
47
47
  end
48
48
 
49
+ if parent.present? && current_region.parent != parent
50
+ current_region.parent = parent
51
+ end
49
52
  parent&.add_zone(current_region)
50
53
  return current_region if children.nil?
51
54
 
@@ -62,6 +65,8 @@ module Worldwide
62
65
  region.currency = Worldwide.currency(code: currency_code) unless currency_code.nil?
63
66
  region.flag = spec["emoji"]
64
67
  region.format = spec["format"]
68
+ region.group = spec["group"]
69
+ region.group_name = spec["group_name"]
65
70
  region.hide_provinces_from_addresses = spec["hide_provinces_from_addresses"] || false
66
71
  region.languages = spec["languages"]
67
72
  region.partial_zip_regex = spec["partial_zip_regex"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worldwide
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
data/worldwide.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = "developers@shopify.com"
12
12
 
13
13
  spec.summary = "Internationalization and localization APIs"
14
- spec.description = "APIs to support i18n and l10n of Ruby code"
14
+ spec.description = "APIs for I18n, I10n, and mailing address operations in Ruby."
15
15
  spec.homepage = "https://github.com/Shopify/worldwide"
16
16
 
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-27 00:00:00.000000000 Z
11
+ date: 2023-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.8'
55
- description: APIs to support i18n and l10n of Ruby code
55
+ description: APIs for I18n, I10n, and mailing address operations in Ruby.
56
56
  email: developers@shopify.com
57
57
  executables: []
58
58
  extensions: []