worldwide 1.14.4 → 1.15.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: 38658a0cbe2fcec35aa5d8d620d9cac02ada5123597d8080733904c0dd371483
4
- data.tar.gz: '08b4a6578e559996a928c9ae3600b5b48e806c5ca5e97478d5258aefb4263288'
3
+ metadata.gz: c3cf97e1bcdf0999cdec177c2d6627b190ed8d8cd55598a676dee463f1cf86ff
4
+ data.tar.gz: a7f767ba103009a596ca24c969ed7459e0a6f3235d2cbd75a137cd4d2afdfe29
5
5
  SHA512:
6
- metadata.gz: 9dcf39bb1680898cacc8da3ac4c07f89edcec9c090c4aba0b3c66040d91ed4042e349cbbab64dd7f4f0971aea325dc57a465ea673be154d175786664a85990f9
7
- data.tar.gz: c1d8df6382fa989b8c0f1dc710c85f14b4f7e2968c81d26d361038090ca95d812e1c09e46a798114bef33fcd839dcc01955ce4f0ba35801a60ba8e323e55760b
6
+ metadata.gz: 85217f6eae5ff93bffa23de787d6131e22daa5614a61560c115d3b45c701b70e905543bc7385a3b20d144003cdae4e93eddb72a3db026927cc12cd4eff59576a
7
+ data.tar.gz: ac164a247f5eb618b189ead2912d427069f33d98911e45317919ce1fd127835bf432192480a77f386c6c7809428d1a983514a9f2c4acda35dbca3f96d2c3a9d1
data/CHANGELOG.md CHANGED
@@ -28,8 +28,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
28
28
  ## [Unreleased]
29
29
 
30
30
  Nil.
31
+
32
+ ---
33
+
34
+ ## [1.15.1] - 2024-12-20
35
+ - Set Malaysia and Singapore as tax_inclusive [#323](https://github.com/Shopify/worldwide/pull/323)
36
+ - Update or correct example zips [#324](https://github.com/Shopify/worldwide/pull/324)
37
+ - Correct zip regex patterns and make them Javascript-compatible [#325](https://github.com/Shopify/worldwide/pull/325)
31
38
  ---
32
39
 
40
+ ## [1.15.0] - 2024-12-16
41
+ - Add zip requirement and tax inclusive methods to country regions [#320](https://github.com/Shopify/worldwide/pull/320)
42
+ - Set Ireland (IE) zip as a required address field [#321](https://github.com/Shopify/worldwide/pull/321)
43
+
33
44
  ## [1.14.4] - 2024-12-12
34
45
  - Speed up configure_i18n by precomputing paths and indexing descendants [#316](https://github.com/Shopify/worldwide/pull/316)
35
46
  - Update BV phone number prefix to 47 (Norway) [#318](https://github.com/Shopify/worldwide/pull/318)
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- worldwide (1.14.4)
16
+ worldwide (1.15.1)
17
17
  activesupport (>= 7.0)
18
18
  i18n
19
19
  phonelib (~> 0.8)
data/data/regions/AC.yml CHANGED
@@ -10,7 +10,7 @@ code: AC
10
10
  unit_system: metric
11
11
  currency: SHP
12
12
  zip_example: ASCN 1ZZ
13
- zip_regex: "\\A[Aa][Ss][Cc][Nn]\\s*1[Zz][Zz]\\z"
13
+ zip_regex: "^[Aa][Ss][Cc][Nn]\\s*1[Zz][Zz]$"
14
14
  phone_number_prefix: 247
15
15
  zip_autofill_enabled: true
16
16
  format:
data/data/regions/BB.yml CHANGED
@@ -7,7 +7,7 @@ unit_system: metric
7
7
  tax_name: VAT
8
8
  group: Central American Countries
9
9
  group_name: Central America
10
- zip_example: BB2306
10
+ zip_example: BB15028
11
11
  zip_regex: "^(BB-?)?\\d{5,5}$"
12
12
  zip_requirement: optional
13
13
  phone_number_prefix: 1
data/data/regions/BF.yml CHANGED
@@ -8,7 +8,7 @@ tax_name: VAT
8
8
  group: African Countries
9
9
  group_name: Africa
10
10
  zip_regex: "^[1-9]\\d{4}$"
11
- zip_example: 10010
11
+ zip_example: "10010"
12
12
  zip_requirement: optional
13
13
  phone_number_prefix: 226
14
14
  format:
data/data/regions/BL.yml CHANGED
@@ -11,8 +11,8 @@ unit_system: metric
11
11
  tags:
12
12
  - EU-OCT
13
13
  currency: EUR
14
- zip_example: '97100'
15
- zip_regex: "^(BL-?)?97133$"
14
+ zip_example: '97091'
15
+ zip_regex: "^(BL-?)?(97133|9709\\d)$"
16
16
  phone_number_prefix: 590
17
17
  format:
18
18
  edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{zip}{city}_{phone}"
data/data/regions/CA.yml CHANGED
@@ -5,7 +5,7 @@ tax: 0.05
5
5
  currency: CAD
6
6
  unit_system: metric
7
7
  tax_name: GST
8
- zip_regex: "\\A[A-Za-z]\\d[A-Za-z]\\s*\\d[A-Za-z]\\d\\z"
8
+ zip_regex: "^[A-Za-z]\\d[A-Za-z]\\s*\\d[A-Za-z]\\d$"
9
9
  partial_zip_regex: "^[A-Z][0-9][A-Z]$"
10
10
  group: North American Countries
11
11
  group_name: North America
data/data/regions/CR.yml CHANGED
@@ -7,7 +7,7 @@ unit_system: metric
7
7
  tax_name: VAT
8
8
  group: Central American Countries
9
9
  group_name: Central America
10
- zip_example: '1000'
10
+ zip_example: '10108'
11
11
  phone_number_prefix: 506
12
12
  week_start_day: sunday
13
13
  format:
data/data/regions/GB.yml CHANGED
@@ -11,7 +11,7 @@ ignore_zones: true
11
11
  group: European Countries
12
12
  group_name: Europe
13
13
  zip_label: Postcode
14
- zip_regex: '\A[A-Za-z]{1,2}[\d]{1,2}(?:[A-Za-z])?\s?[\d][A-Za-z]{2}\z'
14
+ zip_regex: "^[A-Za-z]{1,2}[\\d]{1,2}(?:[A-Za-z])?\\s?[\\d][A-Za-z]{2}$"
15
15
  partial_zip_regex: "^[A-Z]{1,2}[0-9]{1,2}[A-Z]?$"
16
16
  zip_example: SE22 8DL
17
17
  phone_number_prefix: 44
data/data/regions/IE.yml CHANGED
@@ -13,7 +13,6 @@ tags:
13
13
  zip_regex: "^(D6W|[AC-FHKNPRT-Z]\\d{2}) ?[0-9AC-FHKNPRT-Z]{4}$"
14
14
  partial_zip_regex: "^(D6W|[AC-FHKNPRT-Z]\\d{2})$"
15
15
  zip_example: A65 F4E2
16
- zip_requirement: recommended
17
16
  phone_number_prefix: 353
18
17
  week_start_day: monday
19
18
  format:
data/data/regions/IN.yml CHANGED
@@ -8,7 +8,7 @@ tax_name: CGST
8
8
  tax_inclusive: true
9
9
  group: Asian Countries
10
10
  group_name: Asia
11
- zip_regex: "\\A\\d{6}\\z"
11
+ zip_regex: "^\\d{6}$"
12
12
  zip_example: '110034'
13
13
  phone_number_prefix: 91
14
14
  week_start_day: monday
data/data/regions/JE.yml CHANGED
@@ -9,8 +9,8 @@ tax_inclusive: true
9
9
  group: European Countries
10
10
  group_name: Europe
11
11
  zip_example: JE1 1AA
12
- zip_regex: "^JE[1-6] {0,2}\\d[A-Z]{2}$"
13
- partial_zip_regex: "^JE[1-6]$"
12
+ zip_regex: "^JE\\d{1,2} {0,2}\\d[A-Z]{2}$"
13
+ partial_zip_regex: "^JE\\d{1,2}$"
14
14
  phone_number_prefix: 44
15
15
  format:
16
16
  edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{city}{zip}_{phone}"
data/data/regions/JP.yml CHANGED
@@ -9,8 +9,8 @@ tax_inclusive: true
9
9
  group: Asian Countries
10
10
  group_name: Asia
11
11
  zip_example: 154-0023
12
- zip_regex: "\\A〒?(\\d{7}|[0-9|0-9]{3}(-|ー)[0-9|0-9]{4})\\z"
13
- partial_zip_regex: "\\A〒?([0-9|0-9]{0,3})(-|ー?)([0-9|0-9]{0,4})\\z"
12
+ zip_regex: "^〒?(\\d{7}|[0-9|0-9]{3}(-|ー)[0-9|0-9]{4})$"
13
+ partial_zip_regex: "^〒?([0-9|0-9]{0,3})(-|ー?)([0-9|0-9]{0,4})$"
14
14
  phone_number_prefix: 81
15
15
  building_number_required: true
16
16
  building_number_may_be_in_address2: true
data/data/regions/KH.yml CHANGED
@@ -7,7 +7,7 @@ unit_system: metric
7
7
  tax_name: VAT
8
8
  group: Asian Countries
9
9
  group_name: Asia
10
- zip_example: '12203'
10
+ zip_example: '120203'
11
11
  phone_number_prefix: 855
12
12
  format:
13
13
  edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{city}{zip}_{phone}"
data/data/regions/KR.yml CHANGED
@@ -7,7 +7,7 @@ unit_system: metric
7
7
  tax_name: VAT
8
8
  group: Asian Countries
9
9
  group_name: Asia
10
- zip_regex: "(\\A\\d{5}\\z|\\A\\d{3}-\\d{3}\\z)"
10
+ zip_regex: "^(\\d{5}|\\d{3}-\\d{3})$"
11
11
  zip_example: '01600'
12
12
  phone_number_prefix: 82
13
13
  week_start_day: sunday
data/data/regions/MM.yml CHANGED
@@ -7,7 +7,7 @@ unit_system: metric
7
7
  tax_name: GST
8
8
  group: Asian Countries
9
9
  group_name: Asia
10
- zip_example: '11181'
10
+ zip_example: '1508203'
11
11
  phone_number_prefix: 95
12
12
  format:
13
13
  edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{city}{zip}_{phone}"
data/data/regions/MQ.yml CHANGED
@@ -13,14 +13,14 @@ group_name: Central America
13
13
  tags:
14
14
  - EU-OMR
15
15
  zip_example: '97220'
16
- zip_regex: "\\A(MQ-?)?((972)\\d{2,2})\\Z"
16
+ zip_regex: "^(MQ-?)?((972)\\d{2,2})$"
17
17
  phone_number_prefix: 596
18
18
  format:
19
19
  edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{zip}{city}_{phone}"
20
20
  show: "{firstName} {lastName}_{company}_{address1}_{address2}_{zip} {city}_{country}_{phone}"
21
21
  # The only flag with official standing in Martinique is the French flag.
22
22
  # The emoji flag sequence MQ renders as the "snake flag", which is resented by some as a symbol
23
- # of the slave trade. A new local flag, the Iséité flag, was brought into use in 2019, but
23
+ # of the slave trade. A new local flag, the Iséité flag, was brought into use in 2019, but
24
24
  # revoked in 2021. At this point, the safest course of action seems to be to use the French flag.
25
25
  # Sources: https://en.wikipedia.org/wiki/Flag_of_Martinique
26
26
  # https://www.rci.fm/martinique/infos/Justice/La-justice-annule-lutilisation-du-drapeau-et-de-lhymne-choisis-en-2019-par-la-CTM#
data/data/regions/MS.yml CHANGED
@@ -7,7 +7,7 @@ code: MS
7
7
  unit_system: metric
8
8
  currency: XCD
9
9
  zip_regex: "^MSR ?1[1-3][1235]0$"
10
- zip_example: MSR 1210
10
+ zip_example: MSR1210
11
11
  phone_number_prefix: 1
12
12
  format:
13
13
  edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{city}{zip}_{phone}"
data/data/regions/MU.yml CHANGED
@@ -8,7 +8,7 @@ tax_name: VAT
8
8
  tax_inclusive: true
9
9
  group: African Countries
10
10
  group_name: Africa
11
- zip_example: 11106
11
+ zip_example: "11106"
12
12
  zip_regex: "^[1-9AR]\\d{4}$"
13
13
  zip_requirement: optional
14
14
  phone_number_prefix: 230
data/data/regions/MW.yml CHANGED
@@ -11,7 +11,7 @@ group_name: Africa
11
11
  # https://macra.mw/malawi-post-codes/
12
12
  # https://www.grcdi.nl/gsb/malawi.html
13
13
  zip_regex: "^[1-3]\\d{5}$"
14
- zip_example: 207201
14
+ zip_example: "207201"
15
15
  zip_requirement: optional
16
16
  phone_number_prefix: 265
17
17
  format:
data/data/regions/MY.yml CHANGED
@@ -2,6 +2,7 @@
2
2
  name: Malaysia
3
3
  code: MY
4
4
  tax: 0.1
5
+ tax_inclusive: true
5
6
  currency: MYR
6
7
  unit_system: metric
7
8
  tax_name: SST
data/data/regions/NL.yml CHANGED
@@ -10,7 +10,7 @@ group: European Countries
10
10
  group_name: Europe
11
11
  tags:
12
12
  - EU-member
13
- zip_regex: "(?-mix:\\A[1-9][0-9]{3} ?[A-Z]{2}\\z)"
13
+ zip_regex: "^[1-9][0-9]{3} ?[A-Z]{2}$"
14
14
  partial_zip_regex: "^\\d{4}$"
15
15
  zip_example: 1065 AM
16
16
  phone_number_prefix: 31
data/data/regions/NZ.yml CHANGED
@@ -8,7 +8,7 @@ tax_name: GST
8
8
  tax_inclusive: true
9
9
  group: Oceanian Countries
10
10
  group_name: Oceania
11
- zip_regex: "\\A\\d{4}\\z"
11
+ zip_regex: "^\\d{4}$"
12
12
  zip_example: '6001'
13
13
  phone_number_prefix: 64
14
14
  building_number_required: true
data/data/regions/PH.yml CHANGED
@@ -8,7 +8,7 @@ tax_name: VAT
8
8
  zone_key: province
9
9
  group: Asian Countries
10
10
  group_name: Asia
11
- zip_regex: "\\A\\d{4}\\z"
11
+ zip_regex: "^\\d{4}$"
12
12
  zip_example: '1008'
13
13
  phone_number_prefix: 63
14
14
  week_start_day: sunday
data/data/regions/PM.yml CHANGED
@@ -12,7 +12,7 @@ tags:
12
12
  - EU-OCT
13
13
  zip_example: '97500'
14
14
  phone_number_prefix: 508
15
- zip_regex: "\\A(PM-?)?((975)\\d{2,2})\\Z"
15
+ zip_regex: "^(PM-?)?((975)\\d{2,2})$"
16
16
  format:
17
17
  edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{zip}{city}_{phone}"
18
18
  show: "{firstName} {lastName}_{company}_{address1}_{address2}_{zip} {city}_{country}_{phone}"
data/data/regions/PY.yml CHANGED
@@ -5,7 +5,7 @@ tax: 0.1
5
5
  currency: PYG
6
6
  unit_system: metric
7
7
  tax_name: IVA
8
- zip_example: '1536'
8
+ zip_example: '001015'
9
9
  group: South American Countries
10
10
  group_name: South America
11
11
  phone_number_prefix: 595
data/data/regions/SA.yml CHANGED
@@ -5,7 +5,7 @@ tax: 0.15
5
5
  currency: SAR
6
6
  unit_system: metric
7
7
  tax_name: VAT
8
- zip_regex: "(?-mix:\\A\\d{5}(-\\d{4})?\\z)"
8
+ zip_regex: "^\\d{5}(-\\d{4})?$"
9
9
  zip_requirement: optional
10
10
  group: Asian Countries
11
11
  group_name: Asia
data/data/regions/SG.yml CHANGED
@@ -2,6 +2,7 @@
2
2
  name: Singapore
3
3
  code: SG
4
4
  tax: 0.09
5
+ tax_inclusive: true
5
6
  currency: SGD
6
7
  unit_system: metric
7
8
  tax_name: GST
data/data/regions/SS.yml CHANGED
@@ -11,7 +11,7 @@ group_name: Africa
11
11
  # It is possible that some people may still be using old Sudan postcodes for addresses in South Sudan.
12
12
  # For that reason, we permit the entry of a postal code, but it is optional.
13
13
  zip_regex: "^\\d{5}$"
14
- zip_example: 81111 # Juba
14
+ zip_example: "81111" # Juba
15
15
  zip_requirement: optional
16
16
  phone_number_prefix: 211
17
17
  format:
data/data/regions/TA.yml CHANGED
@@ -9,7 +9,7 @@ unit_system: metric
9
9
  # Source: https://en.wikipedia.org/wiki/Saint_Helena_pound
10
10
  currency: GBP
11
11
  zip_example: TDCU 1ZZ
12
- zip_regex: "\\A[Tt][Dd][Cc][Uu]\\s*1[Zz][Zz]\\z"
12
+ zip_regex: "^[Tt][Dd][Cc][Uu]\\s*1[Zz][Zz]$"
13
13
  phone_number_prefix: 2908
14
14
  zip_autofill_enabled: true
15
15
  autofill_city_enabled: true
data/data/regions/UA.yml CHANGED
@@ -9,7 +9,7 @@ tax_inclusive: true
9
9
  group: European Countries
10
10
  group_name: Europe
11
11
  zip_example: '15432'
12
- zip_regex: "\\A\\d{5}\\z"
12
+ zip_regex: "^\\d{5}$"
13
13
  phone_number_prefix: 380
14
14
  week_start_day: monday
15
15
  format:
data/data/regions/US.yml CHANGED
@@ -10,7 +10,7 @@ group_name: North America
10
10
  name_alternates:
11
11
  - United States of America
12
12
  zip_label: Zip code
13
- zip_regex: "(?-mix:\\A\\d{5}(-\\d{4})?\\z)|(?i-mx:\\AFPO\\s*A[A-Z]\\s*\\d{5}-\\d{4}\\z)"
13
+ zip_regex: "^\\d{5}(-\\d{4})?$"
14
14
  zip_example: '90210'
15
15
  phone_number_prefix: 1
16
16
  building_number_required: true
data/data/regions/UZ.yml CHANGED
@@ -7,7 +7,7 @@ unit_system: metric
7
7
  tax_name: VAT
8
8
  group: Asian Countries
9
9
  group_name: Asia
10
- zip_example: '702100'
10
+ zip_example: '140100'
11
11
  zip_regex: "^(100|11[0-2]|12[01]|13[01]|14[01]|15[01]|16[01]|17[01]|18[01]|19[01]|20[01]|21[01]|22[01]|23[01])\\d{3}$"
12
12
  zip_requirement: optional
13
13
  phone_number_prefix: 998
data/data/regions/XK.yml CHANGED
@@ -11,7 +11,7 @@ tax_inclusive: true
11
11
  group: European Countries
12
12
  group_name: Europe
13
13
  zip_regex: "^((RKS|XK)-?)?[1-7]\\d{4}$"
14
- zip_example: 10000
14
+ zip_example: "10000"
15
15
  phone_number_prefix: 383
16
16
  week_start_day: monday
17
17
  zip_requirement: recommended
@@ -163,6 +163,9 @@ module Worldwide
163
163
  # Note that this should really be translated; showing this untranslated name to users is a bad idea.
164
164
  attr_reader :tax_name
165
165
 
166
+ # Whether the region uses tax-inclusive pricing.
167
+ attr_accessor :tax_inclusive
168
+
166
169
  # "generic" VAT tax rate on "most" goods
167
170
  attr_reader :tax_rate
168
171
 
@@ -198,7 +201,7 @@ module Worldwide
198
201
  attr_accessor :zip_example
199
202
 
200
203
  # Is a zip value required in this region? (Possible values: "optional", "recommended", "required")
201
- attr_accessor :zip_requirement
204
+ attr_writer :zip_requirement
202
205
 
203
206
  # A list of character sequences with which a postal code in this region may start.
204
207
  attr_accessor :zip_prefixes
@@ -276,6 +279,7 @@ module Worldwide
276
279
  @partial_zip_regex = nil
277
280
  @phone_number_prefix = nil
278
281
  @tags = []
282
+ @tax_inclusive = false
279
283
  @timezone = nil
280
284
  @timezones = {}
281
285
  @unit_system = nil
@@ -435,13 +439,23 @@ module Worldwide
435
439
 
436
440
  # is a postal code required for this region?
437
441
  def zip_required?
438
- if zip_requirement.nil?
442
+ if @zip_requirement.nil?
439
443
  !zip_regex.nil?
440
444
  else
441
- REQUIRED == zip_requirement
445
+ REQUIRED == @zip_requirement
442
446
  end
443
447
  end
444
448
 
449
+ # Returns whether (and how firmly) we require a value in the zip field
450
+ # Possible returns:
451
+ # - "required" means a value must be supplied
452
+ # - "recommended" means a value is optional, but we recommend providing one
453
+ # - "optional" means a value is optional, and we say it is optional
454
+ # @return [String]
455
+ def zip_requirement
456
+ @zip_requirement || (zip_required? ? REQUIRED : OPTIONAL)
457
+ end
458
+
445
459
  # is a neighborhood required for this region?
446
460
  def neighborhood_required?
447
461
  additional_field_required?("neighborhood")
@@ -114,6 +114,7 @@ module Worldwide
114
114
  region.partial_zip_regex = spec["partial_zip_regex"]
115
115
  region.phone_number_prefix = spec["phone_number_prefix"]
116
116
  region.tags = spec["tags"] || []
117
+ region.tax_inclusive = spec["tax_inclusive"] || false
117
118
  region.timezone = spec["timezone"]
118
119
  region.timezones = spec["timezones"] || {}
119
120
  region.week_start_day = spec["week_start_day"] || "sunday"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worldwide
4
- VERSION = "1.14.4"
4
+ VERSION = "1.15.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldwide
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.4
4
+ version: 1.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
10
+ date: 2025-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -8494,7 +8493,6 @@ licenses: []
8494
8493
  metadata:
8495
8494
  allowed_push_host: https://rubygems.org/
8496
8495
  changelog_uri: https://github.com/Shopify/worldwide/blob/main/CHANGELOG.md
8497
- post_install_message:
8498
8496
  rdoc_options: []
8499
8497
  require_paths:
8500
8498
  - lib
@@ -8509,8 +8507,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
8509
8507
  - !ruby/object:Gem::Version
8510
8508
  version: '0'
8511
8509
  requirements: []
8512
- rubygems_version: 3.5.23
8513
- signing_key:
8510
+ rubygems_version: 3.6.2
8514
8511
  specification_version: 4
8515
8512
  summary: Internationalization and localization APIs
8516
8513
  test_files: []