worldwide 0.14.0 → 0.15.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 +4 -4
- data/.github/workflows/ci-typescript.yml +32 -0
- data/.github/workflows/npm-release.yml +38 -0
- data/.vscode/settings.json +8 -0
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/db/data/regions/BE.yml +5 -2
- data/db/data/regions/BR.yml +7 -4
- data/db/data/regions/CL.yml +7 -4
- data/db/data/regions/CO.yml +3 -2
- data/db/data/regions/ES.yml +5 -2
- data/db/data/regions/ID.yml +3 -2
- data/db/data/regions/IL.yml +5 -2
- data/db/data/regions/MX.yml +7 -4
- data/db/data/regions/NL.yml +5 -2
- data/db/data/regions/PH.yml +4 -2
- data/db/data/regions/TR.yml +4 -2
- data/db/data/regions/TW.yml +8 -0
- data/db/data/regions/VN.yml +4 -2
- data/db/data/regions/_default/cs.yml +27 -2
- data/db/data/regions/_default/da.yml +25 -1
- data/db/data/regions/_default/el.yml +28 -1
- data/db/data/regions/_default/es.yml +29 -1
- data/db/data/regions/_default/fi.yml +25 -1
- data/db/data/regions/_default/fr.yml +28 -1
- data/db/data/regions/_default/hi.yml +25 -1
- data/db/data/regions/_default/hu.yml +28 -2
- data/db/data/regions/_default/id.yml +26 -1
- data/db/data/regions/_default/ja.yml +20 -1
- data/db/data/regions/_default/lt.yml +28 -1
- data/db/data/regions/_default/ms.yml +26 -1
- data/db/data/regions/_default/pt-BR.yml +26 -1
- data/db/data/regions/_default/ro.yml +26 -1
- data/db/data/regions/_default/ru.yml +25 -1
- data/db/data/regions/_default/sk.yml +25 -1
- data/db/data/regions/_default/sl.yml +27 -1
- data/db/data/regions/_default/sv.yml +25 -1
- data/db/data/regions/_default/th.yml +24 -1
- data/db/data/regions/_default/tr.yml +24 -1
- data/db/data/regions/_default/vi.yml +24 -1
- data/db/data/regions/_default/zh-CN.yml +20 -1
- data/db/data/regions/_default/zh-TW.yml +20 -1
- data/lib/worldwide/address.rb +4 -4
- data/lib/worldwide/region.rb +27 -2
- data/lib/worldwide/regions_loader.rb +2 -1
- data/lib/worldwide/version.rb +1 -1
- data/worldwide.gemspec +1 -1
- metadata +5 -2
data/lib/worldwide/region.rb
CHANGED
@@ -34,6 +34,7 @@ module Worldwide
|
|
34
34
|
:zip_regex,
|
35
35
|
:zip_requirement,
|
36
36
|
:additional_address_fields,
|
37
|
+
:combined_address_format,
|
37
38
|
]
|
38
39
|
|
39
40
|
# A region may have more than one parent.
|
@@ -197,9 +198,12 @@ module Worldwide
|
|
197
198
|
# If true, then the province is optional for addresses in this region.
|
198
199
|
attr_accessor :province_optional
|
199
200
|
|
200
|
-
#
|
201
|
+
# An array of the additional address fields that are defined for this region
|
201
202
|
attr_accessor :additional_address_fields
|
202
203
|
|
204
|
+
# A hash of the rules for concatening the additional address fields into the standard fields
|
205
|
+
attr_accessor :combined_address_format
|
206
|
+
|
203
207
|
def initialize(
|
204
208
|
alpha_three: nil,
|
205
209
|
continent: false,
|
@@ -235,7 +239,8 @@ module Worldwide
|
|
235
239
|
@tax_rate = tax_rate
|
236
240
|
@use_zone_code_as_short_name = use_zone_code_as_short_name
|
237
241
|
|
238
|
-
@additional_address_fields =
|
242
|
+
@additional_address_fields = []
|
243
|
+
@combined_address_format = {}
|
239
244
|
@building_number_required = false
|
240
245
|
@building_number_may_be_in_address2 = false
|
241
246
|
@currency = nil
|
@@ -414,6 +419,21 @@ module Worldwide
|
|
414
419
|
end
|
415
420
|
end
|
416
421
|
|
422
|
+
# is a neighborhood required for this region?
|
423
|
+
def neighborhood_required?
|
424
|
+
additional_field_required?("neighborhood")
|
425
|
+
end
|
426
|
+
|
427
|
+
# is a street name required for this region?
|
428
|
+
def street_name_required?
|
429
|
+
additional_field_required?("streetName")
|
430
|
+
end
|
431
|
+
|
432
|
+
# is a street number required for this region?
|
433
|
+
def street_number_required?
|
434
|
+
additional_field_required?("streetNumber")
|
435
|
+
end
|
436
|
+
|
417
437
|
# is the given postal code value valid for this region?
|
418
438
|
def valid_zip?(zip, partial_match: false)
|
419
439
|
normalized = Zip.normalize(
|
@@ -441,6 +461,11 @@ module Worldwide
|
|
441
461
|
end
|
442
462
|
end
|
443
463
|
|
464
|
+
def additional_field_required?(field_name)
|
465
|
+
field = additional_address_fields.find { |f| f["name"] == field_name }
|
466
|
+
field ? !!field["required"] : false
|
467
|
+
end
|
468
|
+
|
444
469
|
def answers_to_cldr_code(search_code)
|
445
470
|
return false if Util.blank?(search_code) || Util.blank?(cldr_code)
|
446
471
|
return true if search_code.casecmp(cldr_code).zero?
|
@@ -95,7 +95,8 @@ module Worldwide
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def apply_territory_attributes(region, spec)
|
98
|
-
region.additional_address_fields = spec["additional_address_fields"] ||
|
98
|
+
region.additional_address_fields = spec["additional_address_fields"] || []
|
99
|
+
region.combined_address_format = spec["combined_address_format"] || {}
|
99
100
|
region.building_number_required = spec["building_number_required"] || false
|
100
101
|
region.building_number_may_be_in_address2 = spec["building_number_may_be_in_address2"] || false
|
101
102
|
currency_code = spec["currency"]
|
data/lib/worldwide/version.rb
CHANGED
data/worldwide.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata["changelog_uri"] = "https://github.com/Shopify/worldwide/blob/main/CHANGELOG.md"
|
19
19
|
|
20
20
|
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
|
21
|
-
f.match(%r{^(rake|test|spec|features)/})
|
21
|
+
f.match(%r{^(rake|test|spec|features|lang/typescript)/})
|
22
22
|
end
|
23
23
|
spec.bindir = "exe"
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
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.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -64,11 +64,14 @@ files:
|
|
64
64
|
- ".github/CONTRIBUTING.md"
|
65
65
|
- ".github/dependabot.yml"
|
66
66
|
- ".github/pull_request_template.md"
|
67
|
+
- ".github/workflows/ci-typescript.yml"
|
67
68
|
- ".github/workflows/ci.yml"
|
68
69
|
- ".github/workflows/cla.yml"
|
70
|
+
- ".github/workflows/npm-release.yml"
|
69
71
|
- ".gitignore"
|
70
72
|
- ".rubocop.yml"
|
71
73
|
- ".ruby-version"
|
74
|
+
- ".vscode/settings.json"
|
72
75
|
- CHANGELOG.md
|
73
76
|
- Gemfile
|
74
77
|
- Gemfile.lock
|