Skip to content

Commit

Permalink
Merge pull request #28 from Shopify/add-building-number-may-be-in-add…
Browse files Browse the repository at this point in the history
…ress2

added building-number-may-be-in-address2
  • Loading branch information
kunwar45 authored Nov 3, 2023
2 parents cf21fbf + 0a50a84 commit 6cc6e9e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add code alternates for Japan [#23](https://github.com/Shopify/worldwide/pull/23)
- Add code alternates for Puerto Rico [#24](https://github.com/Shopify/worldwide/pull/24)
- Record multiple parents per region [#27](https://github.com/Shopify/worldwide/pull/27)
- Add region.building_number_may_be_in_address2 [#28](https://github.com/Shopify/worldwide/pull/28)
- Lookup by parent-child ISO and CLDR codes for dual-status territories
[#29](https://github.com/Shopify/worldwide/pull/29)

Expand Down
1 change: 1 addition & 0 deletions db/data/regions/IT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ zip_regex: "^(IT?-?)?\\d{5}$"
zip_example: '00144'
phone_number_prefix: 39
building_number_required: true
building_number_may_be_in_address2: true
week_start_day: monday
languages:
- it
Expand Down
5 changes: 5 additions & 0 deletions lib/worldwide/region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class Region
# If we require a building number in an address, then this will be true.
attr_accessor :building_number_required

# In some countries, an address may have the building number in address2.
# If we are allowed to have a building number in address2, then this will be true.
attr_accessor :building_number_may_be_in_address2

# Alternate codes which may be used to designate this region
attr_accessor :code_alternates

Expand Down Expand Up @@ -219,6 +223,7 @@ def initialize(
@use_zone_code_as_short_name = use_zone_code_as_short_name

@building_number_required = false
@building_number_may_be_in_address2 = false
@currency = nil
@flag = nil
@format = {}
Expand Down
1 change: 1 addition & 0 deletions lib/worldwide/regions_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def apply_hierarchy(parent:, code:, children:)

def apply_territory_attributes(region, spec)
region.building_number_required = spec["building_number_required"] || true
region.building_number_may_be_in_address2 = spec["building_number_may_be_in_address2"] || false
currency_code = spec["currency"]
region.currency = Worldwide.currency(code: currency_code) unless currency_code.nil?
region.flag = spec["emoji"]
Expand Down

0 comments on commit 6cc6e9e

Please sign in to comment.