address_composer 0.1.4.pre → 0.1.7.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/main.yml +25 -0
  3. data/.gitignore +2 -0
  4. data/.gitmodules +1 -1
  5. data/Gemfile.lock +1 -1
  6. data/README.md +3 -1
  7. data/address-formatting/.travis.yml +8 -6
  8. data/address-formatting/README.md +4 -1
  9. data/address-formatting/SECURITY.md +5 -0
  10. data/address-formatting/conf/abbreviations/{dk.yaml → da.yaml} +0 -3
  11. data/address-formatting/conf/abbreviations/de.yaml +0 -2
  12. data/address-formatting/conf/abbreviations/en.yaml +1 -1
  13. data/address-formatting/conf/abbreviations/fr.yaml +1 -1
  14. data/address-formatting/conf/abbreviations/hu.yaml +1 -2
  15. data/address-formatting/conf/abbreviations/nl.yaml +14 -1
  16. data/address-formatting/conf/abbreviations/no.yaml +16 -0
  17. data/address-formatting/conf/abbreviations/pl.yaml +24 -0
  18. data/address-formatting/conf/abbreviations/pt.yaml +0 -1
  19. data/address-formatting/conf/abbreviations/ru.yaml +2 -2
  20. data/address-formatting/conf/abbreviations/uk.yaml +0 -3
  21. data/address-formatting/conf/abbreviations/vn.yaml +7 -0
  22. data/address-formatting/conf/components.yaml +20 -4
  23. data/address-formatting/conf/countries/worldwide.yaml +147 -120
  24. data/address-formatting/conf/country2lang.yaml +3 -3
  25. data/address-formatting/conf/county_codes.yaml +359 -12
  26. data/address-formatting/conf/state_codes.yaml +1297 -139
  27. data/address-formatting/testcases/countries/be.yaml +35 -0
  28. data/address-formatting/testcases/countries/bf.yaml +15 -1
  29. data/address-formatting/testcases/countries/ca.yaml +29 -5
  30. data/address-formatting/testcases/countries/cn.yaml +9 -0
  31. data/address-formatting/testcases/countries/de.yaml +1 -1
  32. data/address-formatting/testcases/countries/fr.yaml +81 -1
  33. data/address-formatting/testcases/countries/gb.yaml +75 -9
  34. data/address-formatting/testcases/countries/gg.yaml +2 -1
  35. data/address-formatting/testcases/countries/hk.yaml +18 -8
  36. data/address-formatting/testcases/countries/ie.yaml +45 -3
  37. data/address-formatting/testcases/countries/im.yaml +2 -1
  38. data/address-formatting/testcases/countries/je.yaml +2 -1
  39. data/address-formatting/testcases/countries/no.yaml +17 -0
  40. data/address-formatting/testcases/countries/pt.yaml +22 -0
  41. data/address-formatting/testcases/countries/sh.yaml +2 -1
  42. data/address-formatting/testcases/countries/ug.yaml +13 -0
  43. data/address-formatting/testcases/countries/um.yaml +1 -1
  44. data/address-formatting/testcases/countries/us.yaml +38 -2
  45. data/address-formatting/testcases/other/xx.yaml +28 -0
  46. data/lib/address_composer/version.rb +1 -1
  47. data/lib/address_composer.rb +1 -1
  48. metadata +10 -6
  49. data/.ruby-version +0 -1
@@ -18,3 +18,38 @@ expected: |
18
18
  Vrijheidstraat 63
19
19
  2000 Antwerp
20
20
  Belgium
21
+ ---
22
+ description: prefer municipality over hamlet, 50.5689247, 5.3918483
23
+ components:
24
+ country: België
25
+ country_code: be
26
+ county: Huy
27
+ hamlet: Clermont-sous-Huy
28
+ house_number: 187
29
+ municipality: Engis
30
+ postcode: 4480
31
+ region: Wallonia
32
+ road: Chaussée de Liège
33
+ state: Liège
34
+ expected: |
35
+ Chaussée de Liège 187
36
+ 4480 Engis
37
+ België
38
+ ---
39
+ description: prefer village over municipality 50.84201, 4.11871
40
+ components:
41
+ country: Belgium
42
+ country_code: be
43
+ county: Halle-Vilvoorde
44
+ municipality: Roosdaal
45
+ postcode: 1760
46
+ region: Flanders
47
+ road: Kerkveldstraat
48
+ state: Flemish Brabant
49
+ village: Strijtem
50
+ expected: |
51
+ Kerkveldstraat
52
+ 1760 Strijtem
53
+ Belgium
54
+
55
+
@@ -17,6 +17,20 @@ expected: |
17
17
  Avenue Nelson Mandela
18
18
  Ouagadougou
19
19
  Burkina Faso
20
-
20
+ ---
21
+ description: village, Bank in Ouagadougou, 10.5450,-4.5787
22
+ components:
23
+ country: Burkina Faso
24
+ country_code: bf
25
+ department: Tiéfora
26
+ province: Comoé
27
+ road: unnamed road
28
+ village: Bondorola
29
+ expected: |
30
+ unnamed road
31
+ Bondorola
32
+ Tiéfora
33
+ Comoé
34
+ Burkina Faso
21
35
 
22
36
 
@@ -65,8 +65,32 @@ expected: |
65
65
  McMurchy Avenue South
66
66
  Brampton, ON L6Y 1Z4
67
67
  Canada
68
-
69
-
70
-
71
-
72
-
68
+ ---
69
+ # 43.6666,-79.7482
70
+ description: just county
71
+ components:
72
+ country: Canada
73
+ country_code: ca
74
+ county: Springfield
75
+ state: Manitoba
76
+ expected: |
77
+ Springfield, MB
78
+ Canada
79
+ ---
80
+ # 43.60242, -79.80113
81
+ description: locality
82
+ components:
83
+ country: Canada
84
+ country_code: ca
85
+ county: Halton Region
86
+ house_number: 7931
87
+ locality: Halton Hills
88
+ municipality: Halton Hills
89
+ postcode: L5N 8P7
90
+ road: Tenth Line
91
+ state: Ontario
92
+ state_district: Golden Horseshoe
93
+ expected: |
94
+ 7931 Tenth Line
95
+ Halton Hills, ON L5N 8P7
96
+ Canada
@@ -18,6 +18,15 @@ expected: |
18
18
  Pudong New District
19
19
  200120 Shanghai
20
20
  China
21
+ ---
22
+ description: Macau
23
+ components:
24
+ country: China
25
+ country_code: cn
26
+ region: Macau
27
+ expected: |
28
+ Macau
29
+ China
21
30
 
22
31
 
23
32
 
@@ -182,7 +182,7 @@ components:
182
182
  country: Germany
183
183
  country_code: de
184
184
  county: Aschaffenburg
185
- postcode: 63739,63741,63743
185
+ postcode: '63739,63741,63743'
186
186
  road: Haselmühlweg
187
187
  state: Free State of Bavaria
188
188
  state_district: Lower Franconia
@@ -198,4 +198,84 @@ expected: |
198
198
  E 15
199
199
  77630 Arbonne-la-Forêt
200
200
  France
201
-
201
+ #
202
+ # town and municpality
203
+ #
204
+ ---
205
+ description: 43.42981,6.77514
206
+ components:
207
+ amenity: A1X4E0
208
+ country: France
209
+ country_code: fr
210
+ county: Var
211
+ municipality: Draguignan
212
+ postcode: 83700
213
+ road: Avenue du XVe Corps
214
+ state: Provence-Alpes-Côte dAzur
215
+ suburb: Valescure
216
+ town: Saint-Raphaël
217
+ expected: |
218
+ A1X4E0
219
+ Avenue du XVe Corps
220
+ 83700 Saint-Raphaël
221
+ France
222
+ #
223
+ # Paris, remove Arrondissement
224
+ #
225
+ ---
226
+ description: 48.8564, 2.2961
227
+ components:
228
+ city: Paris 7e Arrondissement
229
+ country: France
230
+ country_code: fr
231
+ house_number: 15
232
+ postcode: 75007
233
+ state: Île-de-France
234
+ state_district: Paris
235
+ street: Avenue Charles Floquet
236
+ expected: |
237
+ 15 Avenue Charles Floquet
238
+ 75007 Paris
239
+ France
240
+ #
241
+ # village and municpality
242
+ #
243
+ ---
244
+ description: 45.08523,5.73302
245
+ components:
246
+ country: France
247
+ country_code: fr
248
+ county: Isère
249
+ house_number: 83
250
+ municipality: Grenoble
251
+ neighbourhood: Lotissement des cartonneries
252
+ postcode: 38560
253
+ road: Avenue Jean Navarre
254
+ state: Auvergne-Rhône-Alpes
255
+ state_code: ARA
256
+ village: Champ-sur-Drac
257
+ expected: |
258
+ 83 Avenue Jean Navarre
259
+ 38560 Champ-sur-Drac
260
+ France
261
+ #
262
+ # hamlet and town
263
+ #
264
+ ---
265
+ description: 7.06073496297967,6.60534772183623
266
+ components:
267
+ country: France
268
+ country_code: fr
269
+ county: Doubs
270
+ hamlet: Les Communaux
271
+ house_number: 20
272
+ municipality: Pontarlier
273
+ postcode: 25500
274
+ road: Rue Antoine de Roche
275
+ state: Bourgogne-Franche-Comté
276
+ state_code: BFC
277
+ town: Morteau
278
+ expected: |
279
+ 20 Rue Antoine de Roche
280
+ 25500 Morteau
281
+ France
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  description: Lokku office
3
3
  components:
4
- city: London Borough of Islington
4
+ city: London
5
+ city_district: London Borough of Islington
5
6
  country: United Kingdom
6
7
  country_code: GB
7
- county: London
8
8
  house: Lokku Ltd
9
9
  house_number: 82
10
10
  postcode: EC1M 5RF
@@ -15,7 +15,8 @@ components:
15
15
  expected: |
16
16
  Lokku Ltd
17
17
  82 Clerkenwell Road
18
- London EC1M 5RF
18
+ London
19
+ EC1M 5RF
19
20
  United Kingdom
20
21
 
21
22
  ---
@@ -29,6 +30,7 @@ components:
29
30
  suburb: Barbican
30
31
  expected: |
31
32
  Barbican
33
+ City of London
32
34
  London
33
35
  United Kingdom
34
36
 
@@ -62,7 +64,8 @@ expected: |
62
64
  ---
63
65
  description: just a suburb
64
66
  components:
65
- city: London Borough of Islington
67
+ city: London
68
+ city_district: London Borough of Islington
66
69
  country: United Kingdom
67
70
  country_code: gb
68
71
  county: London
@@ -91,7 +94,8 @@ components:
91
94
  expected: |
92
95
  University of Westminster
93
96
  115 New Cavendish Street
94
- London W1T 5DU
97
+ London
98
+ W1T 5DU
95
99
  United Kingdom
96
100
  ---
97
101
  description: village in Cambridgeshire, 52.281523,-0.115179
@@ -106,7 +110,28 @@ components:
106
110
  town: Huntingdonshire
107
111
  village: Hilton
108
112
  expected: |
109
- Hilton PE28 9QA
113
+ Hilton
114
+ PE28 9QA
115
+ United Kingdom
116
+ ---
117
+ description: Willoughby House, Barbican
118
+ components:
119
+ building: Willoughby House
120
+ city: London
121
+ country: United Kingdom
122
+ country_code: gb
123
+ county: City of London
124
+ postcode: EC2Y 9DP
125
+ quarter: Barbican
126
+ road: Moor Lane
127
+ state: England
128
+ state_district: Greater London
129
+ expected: |
130
+ Willoughby House
131
+ Moor Lane
132
+ Barbican
133
+ London
134
+ EC2Y 9DP
110
135
  United Kingdom
111
136
  ---
112
137
  description: City of Nottingham
@@ -123,7 +148,8 @@ components:
123
148
  suburb: St Ann's
124
149
  expected: |
125
150
  121 Abbotsford Drive
126
- Nottingham NG3 1NB
151
+ Nottingham
152
+ NG3 1NB
127
153
  United Kingdom
128
154
  ---
129
155
  description: London Borough of Waltham Forest
@@ -141,7 +167,8 @@ components:
141
167
  suburb: Leyton
142
168
  expected: |
143
169
  64 Melbourne Road
144
- London E10
170
+ London
171
+ E10
145
172
  United Kingdom
146
173
  ---
147
174
  description: London Borough of Waltham Forest - partial_postcode
@@ -159,5 +186,44 @@ components:
159
186
  suburb: Leyton
160
187
  expected: |
161
188
  64 Melbourne Road
162
- London E10
189
+ London
190
+ E10
163
191
  United Kingdom
192
+ ---
193
+ description: Prefer town over city (Ossett vs Wakefield)
194
+ components:
195
+ building: Orchard House
196
+ city: Wakefield
197
+ country: United Kingdom
198
+ country_code: gb
199
+ county: West Yorkshire
200
+ postcode: WF5 8PG
201
+ road: West Wells Road
202
+ state: England
203
+ state_code: ENG
204
+ state_district: Yorkshire and the Humber
205
+ town: Ossett
206
+ expected: |
207
+ Orchard House
208
+ West Wells Road
209
+ Ossett
210
+ WF5 8PG
211
+ United Kingdom
212
+ ---
213
+ description: Farmland
214
+ components:
215
+ country: United Kingdom
216
+ country_code: gb
217
+ county: York
218
+ farmland: Fair Field
219
+ hamlet: Kexby
220
+ state: England
221
+ state_district: Yorkshire and the Humber
222
+ expected: |
223
+ Fair Field
224
+ Kexby
225
+ York
226
+ England
227
+ United Kingdom
228
+
229
+
@@ -12,7 +12,8 @@ components:
12
12
  expected: |
13
13
  Post Office
14
14
  Le Marchant Street
15
- Saint Peter Port GY1
15
+ Saint Peter Port
16
+ GY1
16
17
  Guernsey, Channel Islands
17
18
 
18
19
 
@@ -2,19 +2,29 @@
2
2
  ---
3
3
  description: Cinema in HK, 22.29987,114.17933
4
4
  components:
5
- cinema: Chinachem Golden Plaza Cinema
6
- country: Hong Kong
7
- country_code: hk
8
- county: Yau Tsim Mong District
9
- road: Science Museum Road
10
- state: Hong Kong
11
- state_district: Kowloon
12
- suburb: Tsim Sha Tsui
5
+ cinema: Chinachem Golden Plaza Cinema
6
+ country: Hong Kong
7
+ country_code: hk
8
+ county: Yau Tsim Mong District
9
+ road: Science Museum Road
10
+ state: Hong Kong
11
+ state_district: Kowloon
12
+ suburb: Tsim Sha Tsui
13
13
  expected: |
14
14
  Chinachem Golden Plaza Cinema
15
15
  Science Museum Road
16
16
  Kowloon
17
17
  Hong Kong
18
+ ---
19
+ description: just city, no state
20
+ components:
21
+ city: Hong Kong
22
+ country: Hong Kong
23
+ country_code: hk
24
+ road: 211 Test Street
25
+ expected: |
26
+ 211 Test Street
27
+ Hong Kong
18
28
 
19
29
 
20
30
 
@@ -28,7 +28,6 @@ components:
28
28
  expected: |
29
29
  Kilkenny
30
30
  Ireland
31
-
32
31
  ---
33
32
  # Friar's Hill - 52.54593995, -6.95706874120767
34
33
  description: Friar's Hill, Graiguenamanagh
@@ -44,7 +43,28 @@ expected: |
44
43
  Graiguenamanagh
45
44
  County Kilkenny
46
45
  Ireland
47
-
46
+ ---
47
+ # 53.3388,-6.2691
48
+ description: condense "Dublin, County Dublin"
49
+ components:
50
+ city: Dublin
51
+ city_district: Wood Quay A ED
52
+ continent: Europe
53
+ country: Ireland
54
+ country_code: ie
55
+ county: County Dublin
56
+ county_code: D
57
+ library: The National Archives
58
+ postcode: D02 TD99
59
+ road: Bishop Street
60
+ state: Leinster
61
+ state_code: L
62
+ expected: |
63
+ The National Archives
64
+ Bishop Street
65
+ Wood Quay A ED
66
+ Dublin
67
+ Ireland
48
68
  ---
49
69
  # 52.6726,-8.6407
50
70
  description: remove "The Metropolitan District of"
@@ -63,5 +83,27 @@ expected: |
63
83
  Shelbourne Road
64
84
  Farranshone
65
85
  Limerick
66
- County Limerick
67
86
  Ireland
87
+ ---
88
+ # 53.49137,-10.02117
89
+ description: no "Electoral Division"
90
+ components:
91
+ city_district: Clifden Electoral Division
92
+ continent: Europe
93
+ country: Ireland
94
+ country_code: ie
95
+ county: County Galway
96
+ county_code: G
97
+ guest_house: Connemara Country Lodge
98
+ region: Conamara Municipal District
99
+ road: N59
100
+ state: Connacht
101
+ state_code: C
102
+ town: Clifden
103
+ expected: |
104
+ Connemara Country Lodge
105
+ N59
106
+ Clifden
107
+ County Galway
108
+ Ireland
109
+
@@ -13,7 +13,8 @@ components:
13
13
  expected: |
14
14
  3FM
15
15
  45 Victoria Street
16
- Douglas IM1 2AY
16
+ Douglas
17
+ IM1 2AY
17
18
  Isle of Man
18
19
 
19
20
 
@@ -11,5 +11,6 @@ components:
11
11
  town: Saint Helier
12
12
  expected: |
13
13
  5 Le Geyt Street
14
- Saint Helier JE2 4TN
14
+ Saint Helier
15
+ JE2 4TN
15
16
  Jersey, Channel Islands
@@ -16,3 +16,20 @@ expected: |
16
16
  Åkebergveien 28
17
17
  0650 Oslo
18
18
  Norway
19
+ ---
20
+ description: house in village with postal_city
21
+ components:
22
+ country: Norge
23
+ country_code: "no"
24
+ county: Viken
25
+ house_number: 33
26
+ neighbourhood: Belset
27
+ postal_city: Rykkinn
28
+ postcode: 1349
29
+ road: Grindstuveien
30
+ suburb: Angerst
31
+ village: Ringvoll
32
+ expected: |
33
+ Grindstuveien 33
34
+ 1349 Rykkinn
35
+ Norge
@@ -14,3 +14,25 @@ expected: |
14
14
  Avenida Conselheiro Barjona de Freitas 11
15
15
  1500-203 Lisbon
16
16
  Portugal
17
+ ---
18
+ # Guest house in the Azores
19
+ description: 37.74851,-25.60450
20
+ components:
21
+ archipelago: Azores
22
+ city: Ponta Delgada
23
+ city_district: Rosto do Cão (Livramento)
24
+ country: Portugal
25
+ country_code: pt
26
+ guest_house: Casa Do Populo
27
+ house_number: 1015
28
+ neighbourhood: Livramento
29
+ postcode: 9500-614
30
+ road: Rua Padre Domingos da Silva Costay
31
+ state_district: São Miguel
32
+ expected: |
33
+ Casa Do Populo
34
+ Rua Padre Domingos da Silva Costay 1015
35
+ 9500-614 Ponta Delgada
36
+ Azores
37
+ Portugal
38
+
@@ -26,7 +26,8 @@ components:
26
26
  state: Tristan da Cunha
27
27
  expected: |
28
28
  Prince Philip Hall
29
- Edinburgh of the Seven Seas TDCU 1ZZ
29
+ Edinburgh of the Seven Seas
30
+ TDCU 1ZZ
30
31
  Tristan da Cunha
31
32
  United Kingdom
32
33
 
@@ -18,6 +18,19 @@ expected: |
18
18
  6/6A Kampala Road
19
19
  Kampala
20
20
  Uganda
21
+ ---
22
+ description: subcounty
23
+ components:
24
+ country: Uganda
25
+ country_code: ug
26
+ state: Arua
27
+ subcounty: Ayivuni
28
+ expected: |
29
+ Ayivuni
30
+ Arua
31
+ Uganda
32
+
33
+
21
34
 
22
35
 
23
36
 
@@ -6,7 +6,7 @@ components:
6
6
  country_code: um
7
7
  island: Wake Island
8
8
  expected: |
9
- Wake Island, UM
9
+ Wake Island, US Minor Outlying Islands
10
10
  United States of America
11
11
 
12
12
 
@@ -75,7 +75,7 @@ components:
75
75
  county: Santa Clara County
76
76
  state: California
77
77
  expected: |
78
- Palo Alto, CA
78
+ Palo Alto, California
79
79
  United States of America
80
80
  ---
81
81
  description: NY, NY
@@ -85,7 +85,7 @@ components:
85
85
  country_code: US
86
86
  state: New York
87
87
  expected: |
88
- New York, NY
88
+ New York, New York
89
89
  United States of America
90
90
  ---
91
91
  description: house number in New York, no city
@@ -183,3 +183,39 @@ expected: |
183
183
  Dronningens Gade
184
184
  Charlotte Amalie, VI 00803
185
185
  United States of America
186
+ #
187
+ # state_district
188
+ ---
189
+ description: state_district
190
+ components:
191
+ country: United States of America
192
+ country_code: us
193
+ state: New York
194
+ state_district: New York
195
+ expected: |
196
+ New York, New York
197
+ United States of America
198
+ ---
199
+ description: just state
200
+ components:
201
+ country: United States of America
202
+ country_code: us
203
+ state: New York
204
+ expected: |
205
+ New York
206
+ United States of America
207
+ #
208
+ # municipality
209
+ ---
210
+ description: municipality
211
+ components:
212
+ country: United States of America
213
+ country_code: us
214
+ county: Saginaw County
215
+ municipality: Taymouth Township
216
+ state: Michigan
217
+ village: Burt
218
+ expected: |
219
+ Burt
220
+ Taymouth Township, Michigan
221
+ United States of America
@@ -0,0 +1,28 @@
1
+ # Dummy test country to check that we fall back to the defaults
2
+ ---
3
+ description: generic format
4
+ components:
5
+ city: City
6
+ country: Null Island
7
+ country_code: XX
8
+ county: County
9
+ house_number: 123
10
+ postcode: PCPCPC
11
+ road: Main Street
12
+ state: State
13
+ suburb: The Hood
14
+ expected: |
15
+ Main Street 123
16
+ PCPCPC City
17
+ Null Island
18
+ ---
19
+ description: generic fallback
20
+ components:
21
+ city: City
22
+ country: Null Island
23
+ country_code: XX
24
+ state: State
25
+ expected: |
26
+ City
27
+ State
28
+ Null Island
@@ -1,3 +1,3 @@
1
1
  class AddressComposer
2
- VERSION = "0.1.4.pre".freeze
2
+ VERSION = "0.1.7.pre".freeze
3
3
  end
@@ -155,7 +155,7 @@ class AddressComposer
155
155
  unknown_components = components.keys - AllComponents
156
156
 
157
157
  components["attention"] = unknown_components.map do |unknown|
158
- components[unknown]
158
+ components.delete(unknown)
159
159
  end.join(" ")
160
160
  end
161
161