addressing 0.6.0 → 0.7.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: e6ee075073be6a9cac2873fd9e8c1ec196bfd0d85a8f95b05567ad21abc86ca8
4
- data.tar.gz: 1049ac7e96d6940b684f517fa97cbef46dc70fe7faea01fefe4f801eda47ab1a
3
+ metadata.gz: f841d5e2269026b18c8731756d71c3cd03d1b5f25bed54cf6fc8e0c0351770e1
4
+ data.tar.gz: befc373ee2e5370acf8b1f35a9cfa2f171bb78f99a17acac92dc3ae2841cb7e6
5
5
  SHA512:
6
- metadata.gz: dcd1cf48a7fa5628bdf3c98f27eb9a5da5cece01f8f657fadd4291cb22a5d787d8f5c91fae7e51d26c6c27d205d9c1b01aa3a092bf1d16fe0e790aac04902399
7
- data.tar.gz: 361739ccf479add26fcd77e085ce7dba1e5b86b0f23d18026564e7829c6df0abdfc438ffa822a4e9d711bcfa7eecc48d57e98c0d0490d4b73cb0521604ab2f88
6
+ metadata.gz: 7a385dc9d6248fe3324e57bdad08937df3f78099e5dacaa479a0846138c141323e5ef118d3f3320ea793601a562863f1abd17656c02cd31dae554ca89e36adac
7
+ data.tar.gz: c5b315e5a7700523bbe242ebb74dd7c9068c30042a044c635fa17d55cf10f470d360eb883c13d53cb3059ef87cea63d322fc7baa731c3808e7c7fd11c5346587
data/CHANGELOG.md CHANGED
@@ -2,9 +2,19 @@
2
2
 
3
3
  All notable changes to `addressing` will be documented in this file.
4
4
 
5
- ## 0.6.0 (22-11-2023)
5
+ ## 0.7.0 (2024-01-30)
6
6
 
7
- - Sync data with commerceguys
7
+ - Update subdivisions for Philippines (PH)
8
+ - Add missing Indonesian (ID) provinces: PD, PE, PS, PT
9
+ - Update subdivisions for India (IN)
10
+ - Allow turning off postal code validation
11
+ - Singapore lacks city/locality field
12
+ - Allow address formats to declare default values
13
+ - Sync data with commerceguys repository (v2.1.1)
14
+
15
+ ## 0.6.0 (2023-11-22)
16
+
17
+ - Sync data with commerceguys repository (v2.1.0)
8
18
  - Update to CLDR v44
9
19
  - Switch to keying subdivisons by ISO code, where available
10
20
  - Add support for a third address line
@@ -13,33 +23,33 @@ All notable changes to `addressing` will be documented in this file.
13
23
  - Drop support for Ruby 2.7
14
24
  - Remove obsolete postal_code_pattern_type from subdivisions
15
25
 
16
- ## 0.5.0 (16-02-2023)
26
+ ## 0.5.0 (2023-02-16)
17
27
 
18
28
  - Update CLDR to v42
19
29
 
20
- ## 0.4.0 (13-07-2022)
30
+ ## 0.4.0 (2022-07-13)
21
31
 
22
32
  - Update CLDR to v41
23
33
 
24
- ## 0.3.1 (04-04-2022)
34
+ ## 0.3.1 (2022-04-04)
25
35
 
26
36
  - Break with both subdivisions and parents when subdivision field is empty
27
37
  - Only retrieve field if it exists on model
28
38
 
29
- ## 0.3.0 (04-04-2022)
39
+ ## 0.3.0 (2022-04-04)
30
40
 
31
41
  - Allow field validation to be overridden
32
42
  - Only verify address when one of the field changes
33
43
  - Allow used address fields to be configured
34
44
 
35
- ## 0.2.0 (25-02-2022)
45
+ ## 0.2.0 (2022-02-25)
36
46
 
37
47
  - Add ActiveRecord validations
38
48
 
39
- ## 0.1.1 (21-02-2022)
49
+ ## 0.1.1 (2022-02-21)
40
50
 
41
51
  - Fix typo in DE custom format
42
52
 
43
- ## 0.1.0 (07-02-2022)
53
+ ## 0.1.0 (2022-02-07)
44
54
 
45
55
  - Initial release
Binary file
@@ -99,7 +99,7 @@
99
99
  {"country_code":"KR","locale":"ko","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%dependent_locality\n%locality\n%administrative_area\n%postal_code","local_format":"%administrative_area %locality%dependent_locality\n%address_line1\n%address_line2\n%address_line3\n%organization\n%given_name %family_name\n%postal_code","required_fields":["address_line1","locality","administrative_area","postal_code"],"uppercase_fields":["postal_code"],"administrative_area_type":"do_si","dependent_locality_type":"district","postal_code_pattern":"\\d{5}","subdivision_depth":3}
100
100
  {"country_code":"KW","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code %locality","postal_code_pattern":"\\d{5}"}
101
101
  {"country_code":"KY","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%administrative_area %postal_code","required_fields":["address_line1","administrative_area"],"administrative_area_type":"island","postal_code_pattern":"KY\\d-\\d{4}","subdivision_depth":1}
102
- {"country_code":"KZ","format":"%postal_code\n%administrative_area\n%locality\n%address_line1\n%address_line2\n%address_line3\n%organization\n%family_name %given_name %additional_name","postal_code_pattern":"\\d{6}"}
102
+ {"country_code":"KZ","format":"%family_name %given_name %additional_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code, %locality\n%administrative_area","required_fields":["address_line1","locality","postal_code"],"administrative_area_type":"region","postal_code_pattern":"\\d{6}|[A-Z0-9]{7}","subdivision_depth":1}
103
103
  {"country_code":"LA","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code %locality","postal_code_pattern":"\\d{5}"}
104
104
  {"country_code":"LB","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality %postal_code","postal_code_pattern":"(?:\\d{4})(?: ?(?:\\d{4}))?"}
105
105
  {"country_code":"LI","format":"%organization\n%given_name %family_name\n%address_line1\n%address_line2\n%address_line3\n%postal_code %locality","required_fields":["address_line1","locality","postal_code"],"postal_code_pattern":"948[5-9]|949[0-8]","postal_code_prefix":"FL-"}
@@ -140,7 +140,7 @@
140
140
  {"country_code":"NO","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code %locality","required_fields":["address_line1","locality","postal_code"],"locality_type":"post_town","postal_code_pattern":"\\d{4}"}
141
141
  {"country_code":"NP","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality %postal_code","postal_code_pattern":"\\d{5}"}
142
142
  {"country_code":"NR","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%administrative_area","required_fields":["address_line1","administrative_area"],"administrative_area_type":"district","subdivision_depth":1}
143
- {"country_code":"NZ","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%dependent_locality\n%locality %postal_code","required_fields":["address_line1","locality","postal_code"],"postal_code_pattern":"\\d{4}"}
143
+ {"country_code":"NZ","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%dependent_locality\n%locality %postal_code","required_fields":["address_line1","locality","postal_code"],"locality_type":"town_city","postal_code_pattern":"\\d{4}"}
144
144
  {"country_code":"OM","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code\n%locality","postal_code_pattern":"(?:PC )?\\d{3}"}
145
145
  {"country_code":"PA","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality\n%administrative_area","uppercase_fields":["locality","administrative_area"],"subdivision_depth":1}
146
146
  {"country_code":"PE","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality %postal_code\n%administrative_area","locality_type":"district","postal_code_pattern":"(?:LIMA \\d{1,2}|CALLAO 0?\\d)|[0-2]\\d{4}","subdivision_depth":1}
@@ -165,7 +165,7 @@
165
165
  {"country_code":"SC","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality\n%administrative_area","uppercase_fields":["administrative_area"],"administrative_area_type":"island","subdivision_depth":1}
166
166
  {"country_code":"SD","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality\n%postal_code","locality_type":"district","postal_code_pattern":"\\d{5}"}
167
167
  {"country_code":"SE","format":"%organization\n%given_name %family_name\n%address_line1\n%address_line2\n%address_line3\n%postal_code %locality","required_fields":["address_line1","locality","postal_code"],"locality_type":"post_town","postal_code_pattern":"\\d{3} ?\\d{2}","postal_code_prefix":"SE-"}
168
- {"country_code":"SG","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code","required_fields":["address_line1","postal_code"],"postal_code_pattern":"\\d{6}"}
168
+ {"country_code":"SG","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality %postal_code","required_fields":["address_line1","locality","postal_code"],"default_values":{"locality":"Singapore"},"postal_code_pattern":"\\d{6}"}
169
169
  {"country_code":"SH","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%locality\n%postal_code","required_fields":["address_line1","locality","postal_code"],"uppercase_fields":["locality","postal_code"],"postal_code_pattern":"(?:ASCN|STHL) 1ZZ"}
170
170
  {"country_code":"SI","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code %locality","postal_code_pattern":"\\d{4}","postal_code_prefix":"SI-"}
171
171
  {"country_code":"SJ","format":"%given_name %family_name\n%organization\n%address_line1\n%address_line2\n%address_line3\n%postal_code %locality","required_fields":["address_line1","locality","postal_code"],"locality_type":"post_town","postal_code_pattern":"\\d{4}"}
@@ -102,6 +102,22 @@
102
102
  "name": "West Papua",
103
103
  "local_name": "Papua Barat"
104
104
  },
105
+ "PD": {
106
+ "name": "Southwest Papua",
107
+ "local_name": "Papua Barat Daya"
108
+ },
109
+ "PE": {
110
+ "name": "Highland Papua",
111
+ "local_name": "Papua Pengunungan"
112
+ },
113
+ "PS": {
114
+ "name": "South Papua",
115
+ "local_name": "Papua Selatan"
116
+ },
117
+ "PT": {
118
+ "name": "Central Papua",
119
+ "local_name": "Papua Tengah"
120
+ },
105
121
  "RI": {
106
122
  "name": "Riau",
107
123
  "local_name": "Riau"
@@ -20,7 +20,7 @@
20
20
  "CH": {
21
21
  "name": "Chandigarh"
22
22
  },
23
- "CT": {
23
+ "CG": {
24
24
  "name": "Chhattisgarh"
25
25
  },
26
26
  "DH": {
@@ -79,7 +79,7 @@
79
79
  "NL": {
80
80
  "name": "Nagaland"
81
81
  },
82
- "OR": {
82
+ "OD": {
83
83
  "name": "Odisha"
84
84
  },
85
85
  "PY": {
@@ -97,7 +97,7 @@
97
97
  "TN": {
98
98
  "name": "Tamil Nadu"
99
99
  },
100
- "TG": {
100
+ "TS": {
101
101
  "name": "Telangana"
102
102
  },
103
103
  "TR": {
@@ -106,7 +106,7 @@
106
106
  "UP": {
107
107
  "name": "Uttar Pradesh"
108
108
  },
109
- "UT": {
109
+ "UK": {
110
110
  "name": "Uttarakhand"
111
111
  },
112
112
  "WB": {
@@ -0,0 +1,86 @@
1
+ {
2
+ "country_code": "KZ",
3
+ "locale": "kk",
4
+ "subdivisions": {
5
+ "10": {
6
+ "name": "Abai Region",
7
+ "local_name": "Abay oblysy"
8
+ },
9
+ "11": {
10
+ "name": "Akmola Region",
11
+ "local_name": "Aqmola oblysy"
12
+ },
13
+ "15": {
14
+ "name": "Aktobe Region",
15
+ "local_name": "Aqtöbe oblysy"
16
+ },
17
+ "75": {
18
+ "name": "Almaty",
19
+ "local_name": "Almaty"
20
+ },
21
+ "19": {
22
+ "name": "Almaty Region",
23
+ "local_name": "Almaty oblysy"
24
+ },
25
+ "71": {
26
+ "name": "Astana",
27
+ "local_name": "Astana"
28
+ },
29
+ "23": {
30
+ "name": "Atyrau Region",
31
+ "local_name": "Atyraū oblysy"
32
+ },
33
+ "63": {
34
+ "name": "East Kazakhstan Region",
35
+ "local_name": "Shyghys Qazaqstan oblysy"
36
+ },
37
+ "31": {
38
+ "name": "Jambyl Region",
39
+ "local_name": "Zhambyl oblysy"
40
+ },
41
+ "33": {
42
+ "name": "Jetisu Region",
43
+ "local_name": "Zhetisū oblysy"
44
+ },
45
+ "35": {
46
+ "name": "Karaganda Region",
47
+ "local_name": "Qaraghandy oblysy"
48
+ },
49
+ "39": {
50
+ "name": "Kostanay Region",
51
+ "local_name": "Qostanay oblysy"
52
+ },
53
+ "43": {
54
+ "name": "Kyzylorda Region",
55
+ "local_name": "Qyzylorda oblysy"
56
+ },
57
+ "47": {
58
+ "name": "Mangystau Region",
59
+ "local_name": "Mangghystaū oblysy"
60
+ },
61
+ "59": {
62
+ "name": "North Kazakhstan Region",
63
+ "local_name": "Soltüstik Qazaqstan oblysy"
64
+ },
65
+ "55": {
66
+ "name": "Pavlodar Region",
67
+ "local_name": "Pavlodar oblysy"
68
+ },
69
+ "79": {
70
+ "name": "Shymkent",
71
+ "local_name": "Shymkent"
72
+ },
73
+ "61": {
74
+ "name": "Turkistan Region",
75
+ "local_name": "Türkistan oblysy"
76
+ },
77
+ "62": {
78
+ "name": "Ulytau Region",
79
+ "local_name": "Ulytaū oblysy"
80
+ },
81
+ "27": {
82
+ "name": "West Kazakhstan Region",
83
+ "local_name": "Batys Qazaqstan oblysy"
84
+ }
85
+ }
86
+ }
@@ -136,8 +136,11 @@
136
136
  "LEY": {
137
137
  "name": "Leyte"
138
138
  },
139
- "MAG": {
140
- "name": "Maguindanao"
139
+ "MGN": {
140
+ "name": "Maguindanao del Norte"
141
+ },
142
+ "MGS": {
143
+ "name": "Maguindanao del Sur"
141
144
  },
142
145
  "MAD": {
143
146
  "name": "Marinduque"
@@ -58,7 +58,7 @@ module Addressing
58
58
  end
59
59
  end
60
60
 
61
- attr_reader :country_code, :locale, :format, :local_format, :required_fields, :uppercase_fields, :administrative_area_type, :locality_type, :dependent_locality_type, :postal_code_type, :postal_code_pattern, :postal_code_prefix, :subdivision_depth
61
+ attr_reader :country_code, :locale, :format, :local_format, :required_fields, :uppercase_fields, :default_values, :administrative_area_type, :locality_type, :dependent_locality_type, :postal_code_type, :postal_code_pattern, :postal_code_prefix, :subdivision_depth
62
62
 
63
63
  def initialize(definition = {})
64
64
  # Validate the presence of required properties.
@@ -74,6 +74,7 @@ module Addressing
74
74
  local_format: nil,
75
75
  required_fields: [],
76
76
  uppercase_fields: [],
77
+ default_values: {},
77
78
  postal_code_pattern: nil,
78
79
  postal_code_prefix: nil,
79
80
  subdivision_depth: 0
@@ -81,6 +82,7 @@ module Addressing
81
82
 
82
83
  AddressField.assert_all_exist(definition[:required_fields])
83
84
  AddressField.assert_all_exist(definition[:uppercase_fields])
85
+ AddressField.assert_all_exist(definition[:default_values].keys)
84
86
 
85
87
  @country_code = definition[:country_code]
86
88
  @locale = definition[:locale]
@@ -88,6 +90,7 @@ module Addressing
88
90
  @local_format = definition[:local_format]
89
91
  @required_fields = definition[:required_fields]
90
92
  @uppercase_fields = definition[:uppercase_fields]
93
+ @default_values = definition[:default_values]
91
94
  @subdivision_depth = definition[:subdivision_depth]
92
95
 
93
96
  if used_fields.include?(AddressField::ADMINISTRATIVE_AREA)
@@ -31,7 +31,7 @@ module Addressing
31
31
 
32
32
  # Asserts that all provided values are defined.
33
33
  def assert_all_exist(values)
34
- values.each { |value| assert_exists(value) }
34
+ values.each { |value| assert_exists(value.to_s) }
35
35
  end
36
36
  end
37
37
  end
@@ -3,7 +3,7 @@
3
3
  module Addressing
4
4
  module Model
5
5
  def validates_address_format(
6
- fields: [:country_code, :administrative_area, :locality, :dependent_locality, :postal_code, :sorting_code, :address_line1, :address_line2, :organization, :given_name, :additional_name, :family_name, :locale], field_overrides: nil, **options
6
+ fields: [:country_code, :administrative_area, :locality, :dependent_locality, :postal_code, :sorting_code, :address_line1, :address_line2, :organization, :given_name, :additional_name, :family_name, :locale], field_overrides: nil, verify_postal_code: true, **options
7
7
  )
8
8
  fields = Array(fields)
9
9
  field_overrides ||= FieldOverrides.new({})
@@ -48,7 +48,7 @@ module Addressing
48
48
  subdivisions = verify_subdivisions(address, address_format, field_overrides)
49
49
 
50
50
  # Validate postal code.
51
- verify_postal_code(address.postal_code, subdivisions, address_format) if used_fields.include?(AddressField::POSTAL_CODE)
51
+ verify_postal_code(address.postal_code, subdivisions, address_format) if used_fields.include?(AddressField::POSTAL_CODE) && verify_postal_code
52
52
  end
53
53
 
54
54
  define_method :verify_subdivisions do |address, address_format, field_overrides|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Addressing
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin van der Vleuten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-22 00:00:00.000000000 Z
11
+ date: 2024-01-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: robinvdvleuten@gmail.com
@@ -653,6 +653,7 @@ files:
653
653
  - data/subdivision/KR-50.json
654
654
  - data/subdivision/KR.json
655
655
  - data/subdivision/KY.json
656
+ - data/subdivision/KZ.json
656
657
  - data/subdivision/MX.json
657
658
  - data/subdivision/MY.json
658
659
  - data/subdivision/MZ.json