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 +4 -4
- data/CHANGELOG.md +19 -9
- data/data/address_formats.dump +0 -0
- data/data/address_formats.json +3 -3
- data/data/subdivision/ID.json +16 -0
- data/data/subdivision/IN.json +4 -4
- data/data/subdivision/KZ.json +86 -0
- data/data/subdivision/PH.json +5 -2
- data/lib/addressing/address_format.rb +4 -1
- data/lib/addressing/enum.rb +1 -1
- data/lib/addressing/model.rb +2 -2
- data/lib/addressing/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f841d5e2269026b18c8731756d71c3cd03d1b5f25bed54cf6fc8e0c0351770e1
|
4
|
+
data.tar.gz: befc373ee2e5370acf8b1f35a9cfa2f171bb78f99a17acac92dc3ae2841cb7e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
5
|
+
## 0.7.0 (2024-01-30)
|
6
6
|
|
7
|
-
-
|
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 (
|
26
|
+
## 0.5.0 (2023-02-16)
|
17
27
|
|
18
28
|
- Update CLDR to v42
|
19
29
|
|
20
|
-
## 0.4.0 (
|
30
|
+
## 0.4.0 (2022-07-13)
|
21
31
|
|
22
32
|
- Update CLDR to v41
|
23
33
|
|
24
|
-
## 0.3.1 (04-04
|
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
|
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 (
|
45
|
+
## 0.2.0 (2022-02-25)
|
36
46
|
|
37
47
|
- Add ActiveRecord validations
|
38
48
|
|
39
|
-
## 0.1.1 (
|
49
|
+
## 0.1.1 (2022-02-21)
|
40
50
|
|
41
51
|
- Fix typo in DE custom format
|
42
52
|
|
43
|
-
## 0.1.0 (
|
53
|
+
## 0.1.0 (2022-02-07)
|
44
54
|
|
45
55
|
- Initial release
|
data/data/address_formats.dump
CHANGED
Binary file
|
data/data/address_formats.json
CHANGED
@@ -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":"%
|
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}"}
|
data/data/subdivision/ID.json
CHANGED
@@ -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"
|
data/data/subdivision/IN.json
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
"CH": {
|
21
21
|
"name": "Chandigarh"
|
22
22
|
},
|
23
|
-
"
|
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
|
-
"
|
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
|
-
"
|
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
|
-
"
|
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
|
+
}
|
data/data/subdivision/PH.json
CHANGED
@@ -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)
|
data/lib/addressing/enum.rb
CHANGED
data/lib/addressing/model.rb
CHANGED
@@ -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|
|
data/lib/addressing/version.rb
CHANGED
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.
|
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:
|
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
|