address_composer 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30e870bd8e39f5cf689942c7b4343f2d885f4de4ebdcb01878f8627c1b685039
4
- data.tar.gz: '07117792510f3dd522c3443fabf1844f8039fbca6f08e94e550a59a86198244d'
3
+ metadata.gz: 4c044946e2cf8967b36aa267c126579b5bcbf4e529abed3a121bac815265fb6f
4
+ data.tar.gz: 4849d192a1073e378624714e536e964846aff9e9297fc5a32ea96238e5abdbc0
5
5
  SHA512:
6
- metadata.gz: 7b2063f714d1f0100f71274808375364677430d213794b63e4d1eb4cfc95e8ac2e6eb56e7dd8464699da03a7614a6d3d7ac5578fa4106ea1bbcae1a605390dda
7
- data.tar.gz: 385f17417dc4884f44ced76e8a5d48b631395a53213554e840ef87072315df43caddd5fde7515d3f5da75824c64f4de3bc8d288783e0419d2c9e6b29c9c7e9a0
6
+ metadata.gz: 105c406cc5cf4f269ab44a07ebb31ed7f5db74705f38f0f3379dd23c1331cd86c873dd00f5846a608e221fef402f97a55c9a5320af92d8af61fe8dfa7d06abbb
7
+ data.tar.gz: eab56b159a893271e8815c2f4bc2d3ce3686cda249e6376e18fcafe444c08ef5831a10aba4e16ee220b0228de24fb62f2fd140895cd857b660f08137907c9784
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- address_composer (1.0.0)
4
+ address_composer (1.0.1)
5
5
  mustache (~> 1.1)
6
6
 
7
7
  GEM
@@ -52,11 +52,14 @@ Unlike [physical post (office) mail](http://www.bitboost.com/ref/international-a
52
52
  Our goal with this repository is a series of (programming) language independent templates. Those templates can then be processed by whatever software you like.
53
53
 
54
54
  There are open-source implementations in
55
+
55
56
  * [Elixir](https://github.com/dkuku/ex_address_formatting)
57
+ * [Go](https://github.com/timonmasberg/address-formatter)
56
58
  * [Java](https://github.com/placemarkt/address-formatter-java)
57
59
  * [Javascript](https://github.com/fragaria/address-formatter)
58
60
  * [Perl](https://metacpan.org/release/Geo-Address-Formatter)
59
61
  * [PHP](https://github.com/predicthq/address-formatter-php)
62
+ * [Python](https://github.com/dunkelstern/international_address_formatter)
60
63
  * [Ruby](https://github.com/mirubiri/address_composer)
61
64
  * [Rust](https://github.com/CanalTP/address-formatter-rs)
62
65
  * [Scala](https://github.com/ben-willis/address-formatter)
@@ -1930,6 +1930,8 @@ US:
1930
1930
  - ["\nUS$","\nUnited States of America"]
1931
1931
  - ["\nUSA$","\nUnited States of America"]
1932
1932
  - ["\nUnited States$","\nUnited States of America"]
1933
+ - ["Town of ",""]
1934
+ - ["Township of ",""]
1933
1935
 
1934
1936
  # Uzbekistan
1935
1937
  UZ:
@@ -1215,6 +1215,85 @@ HU:
1215
1215
  VM: Veszprém
1216
1216
  ZA: Zala
1217
1217
  ZE: Zalaegerszeg
1218
+ ID:
1219
+ AC: Aceh
1220
+ BA: Bali
1221
+ BB:
1222
+ default: Kepulauan Bangka Belitung
1223
+ alt_en: Bangka-Belitung Islands
1224
+ BE: Bengkulu
1225
+ BT: Banten
1226
+ GO: Gorontalo
1227
+ JA: Jambi
1228
+ JB:
1229
+ default: Jawa Barat
1230
+ alt_en: West Java
1231
+ JI:
1232
+ default: Jawa Timur
1233
+ alt_en: East Java
1234
+ JK:
1235
+ default: Daerah Khusus Ibukota Jakarta
1236
+ alt_en: Jakarta Special Capital Region
1237
+ JT:
1238
+ default: Jawa Tengah
1239
+ alt_en: Central Java
1240
+ KB:
1241
+ default: Kalimantan Barat
1242
+ alt_en: West Kalimantan
1243
+ KI:
1244
+ default: Kalimantan Timur
1245
+ alt_en: East Kalimantan
1246
+ KR:
1247
+ default: Kepulauan Riau
1248
+ alt_en: Riau Islands
1249
+ KS:
1250
+ default: Kalimantan Selatan
1251
+ alt_en: South Kalimantan
1252
+ KT:
1253
+ default: Kalimantan Tengah
1254
+ alt_en: Central Kalimantan
1255
+ KU:
1256
+ default: Kalimantan Utara
1257
+ alt_en: North Kalimantan
1258
+ LA: Lampung
1259
+ MA: Maluku
1260
+ MU:
1261
+ default: Maluku Utara
1262
+ alt_en: North Maluku
1263
+ NB: Nusa Tenggara Barat
1264
+ NT: Nusa Tenggara Timur
1265
+ PA: Papua
1266
+ PB:
1267
+ default: Papua Barat
1268
+ alt_en: West Papua
1269
+ RI: Riau
1270
+ SA:
1271
+ default: Sulawesi Utara
1272
+ alt_en: North Sulawesi
1273
+ SB:
1274
+ default: Sumatera Barat
1275
+ alt_en: West Sumatra
1276
+ SG:
1277
+ default: Sulawesi Tenggara
1278
+ alt_en: Southeast Sulawesi
1279
+ SN:
1280
+ default: Sulawesi Selatan
1281
+ alt_en: South Sulawesi
1282
+ SR:
1283
+ default: Sulawesi Barat
1284
+ alt_en: West Sulawesi
1285
+ SS:
1286
+ default: Sumatera Selatan
1287
+ alt_en: South Sumatra
1288
+ ST:
1289
+ default: Sulawesi Tengah
1290
+ alt_en: Central Sulawesi
1291
+ SU:
1292
+ default: Sumatera Utara
1293
+ alt_en: North Sumatra
1294
+ YO:
1295
+ default: Daerah Istimewa Yogyakarta
1296
+ alt_en: Special Region of Yogyakarta
1218
1297
  IE:
1219
1298
  C: Connacht
1220
1299
  L: Leinster
@@ -1696,6 +1775,38 @@ MU:
1696
1775
  PW: Plaines Wilhems
1697
1776
  RR: Rivière du Rempart
1698
1777
  SA: Savanne
1778
+ MW:
1779
+ BA: Balaka
1780
+ BL: Blantyre
1781
+ C: Central
1782
+ CK: Chikwawa
1783
+ CR: Chiradzulu
1784
+ CT: Chitipa
1785
+ DE: Dedza
1786
+ DO: Dowa
1787
+ KR: Karonga
1788
+ KS: Kasungu
1789
+ LI: Lilongwe
1790
+ LK: Likoma
1791
+ MC: Mchinji
1792
+ MG: Mangochi
1793
+ MH: Machinga
1794
+ MU: Mulanje
1795
+ MW: Mwanza
1796
+ MZ: Mzimba
1797
+ N: Northern
1798
+ NB: Nkhata Bay
1799
+ NE: Neno
1800
+ NI: Ntchisi
1801
+ NK: Nkhotakota
1802
+ NS: Nsanje
1803
+ NU: Ntcheu
1804
+ PH: Phalombe
1805
+ RU: Rumphi
1806
+ S: Southern
1807
+ SA: Salima
1808
+ TH: Thyolo
1809
+ ZO: Zomba
1699
1810
  MX:
1700
1811
  AGU: Aguascalientes
1701
1812
  BCN: Baja California
@@ -139,6 +139,24 @@ expected: |
139
139
  928 Flagler Avenue
140
140
  Edgewater, FL 32132
141
141
  United States of America
142
+
143
+ ---
144
+ description: clean up "Town of " 40.7805,-73.4875
145
+ components:
146
+ country: United States
147
+ country_code: us
148
+ county: Nassau County
149
+ house_number: 4
150
+ municipality: Town of Oyster Bay
151
+ postcode: 11803
152
+ road: Lakeville Lane
153
+ state: New York
154
+ state_code: NY
155
+ expected: |
156
+ 4 Lakeville Lane
157
+ Oyster Bay, NY 11803
158
+ United States of America
159
+
142
160
  ---
143
161
  description: use county if no city
144
162
  components:
@@ -170,14 +188,14 @@ expected: |
170
188
  ---
171
189
  description: Library in Charlotte Amalie, 18.34119,-64.93546
172
190
  components:
173
- country: United States of America
174
- country_code: us
175
- county: St. Thomas Island
176
- library: Enid M Baa Library and Archives
177
- postcode: "00803"
178
- road: Dronningens Gade
179
- state: United States Virgin Islands
180
- town: Charlotte Amalie
191
+ country: United States of America
192
+ country_code: us
193
+ county: St. Thomas Island
194
+ library: Enid M Baa Library and Archives
195
+ postcode: "00803"
196
+ road: Dronningens Gade
197
+ state: United States Virgin Islands
198
+ town: Charlotte Amalie
181
199
  expected: |
182
200
  Enid M Baa Library and Archives
183
201
  Dronningens Gade
@@ -188,19 +206,19 @@ expected: |
188
206
  ---
189
207
  description: state_district
190
208
  components:
191
- country: United States of America
192
- country_code: us
193
- state: New York
194
- state_district: New York
209
+ country: United States of America
210
+ country_code: us
211
+ state: New York
212
+ state_district: New York
195
213
  expected: |
196
214
  New York, New York
197
215
  United States of America
198
216
  ---
199
217
  description: just state
200
218
  components:
201
- country: United States of America
202
- country_code: us
203
- state: New York
219
+ country: United States of America
220
+ country_code: us
221
+ state: New York
204
222
  expected: |
205
223
  New York
206
224
  United States of America
@@ -1,3 +1,3 @@
1
1
  class AddressComposer
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
@@ -178,14 +178,14 @@ class AddressComposer
178
178
  components["postcode"] = components["postcode"].split(",").first
179
179
  end
180
180
 
181
- # Clean values with "", nil or []
182
- self.components = components.reject { |_, v| v.nil? || v.empty? }
183
-
184
181
  # If country is a number use the state as country
185
- if components["country"]&.match?(/[0-9]/)
182
+ if components["state"] && components["country"]&.match?(/^\d+$/)
186
183
  components["country"] = components["state"]
187
184
  end
188
185
 
186
+ # Clean values with "", nil or []
187
+ self.components = components.reject { |_, v| v.nil? || v.empty? }
188
+
189
189
  # Remove components with URL
190
190
  components.delete_if { |_, v| v.match?(URI::DEFAULT_PARSER.make_regexp) }
191
191
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: address_composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Arrufat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-11 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache