address_composer 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.gitmodules +1 -0
- data/.rubocop.yml +4 -20
- data/Gemfile.lock +57 -32
- data/README.md +26 -0
- data/address-formatting/.github/workflows/ci.yml +25 -0
- data/address-formatting/README.md +19 -13
- data/address-formatting/bin/coverage.pl +8 -2
- data/address-formatting/bin/run_tests.t +36 -10
- data/address-formatting/conf/abbreviations/ca.yaml +18 -1
- data/address-formatting/conf/abbreviations/cs.yaml +0 -3
- data/address-formatting/conf/abbreviations/da.yaml +1 -1
- data/address-formatting/conf/abbreviations/en.yaml +7 -1
- data/address-formatting/conf/abbreviations/es.yaml +21 -3
- data/address-formatting/conf/abbreviations/et.yaml +0 -3
- data/address-formatting/conf/abbreviations/eu.yaml +0 -1
- data/address-formatting/conf/abbreviations/fi.yaml +0 -3
- data/address-formatting/conf/abbreviations/fr.yaml +1 -1
- data/address-formatting/conf/abbreviations/gl.yaml +14 -0
- data/address-formatting/conf/abbreviations/it.yaml +1 -1
- data/address-formatting/conf/abbreviations/nl.yaml +17 -0
- data/address-formatting/conf/abbreviations/no.yaml +0 -4
- data/address-formatting/conf/abbreviations/pl.yaml +2 -2
- data/address-formatting/conf/abbreviations/pt.yaml +18 -0
- data/address-formatting/conf/abbreviations/ro.yaml +8 -2
- data/address-formatting/conf/abbreviations/sl.yaml +24 -0
- data/address-formatting/conf/abbreviations/{se.yaml → sv.yaml} +1 -5
- data/address-formatting/conf/abbreviations/tr.yaml +0 -4
- data/address-formatting/conf/abbreviations/{vn.yaml → vi.yaml} +1 -3
- data/address-formatting/conf/components.yaml +15 -4
- data/address-formatting/conf/countries/worldwide.yaml +401 -272
- data/address-formatting/conf/country2lang.yaml +33 -32
- data/address-formatting/conf/country_codes.yaml +216 -214
- data/address-formatting/conf/county_codes.yaml +19 -9
- data/address-formatting/conf/state_codes.yaml +91 -49
- data/address-formatting/cpanfile +10 -0
- data/address-formatting/testcases/abbreviations/de.yaml +27 -0
- data/address-formatting/testcases/abbreviations/en.yaml +15 -0
- data/address-formatting/testcases/abbreviations/fr.yaml +12 -0
- data/address-formatting/testcases/countries/al.yaml +17 -3
- data/address-formatting/testcases/countries/au.yaml +29 -3
- data/address-formatting/testcases/countries/be.yaml +17 -2
- data/address-formatting/testcases/countries/bg.yaml +1 -1
- data/address-formatting/testcases/countries/br.yaml +36 -2
- data/address-formatting/testcases/countries/ca.yaml +60 -18
- data/address-formatting/testcases/countries/cl.yaml +3 -2
- data/address-formatting/testcases/countries/cn.yaml +21 -8
- data/address-formatting/testcases/countries/co.yaml +19 -0
- data/address-formatting/testcases/countries/cu.yaml +24 -10
- data/address-formatting/testcases/countries/de.yaml +70 -13
- data/address-formatting/testcases/countries/eg.yaml +6 -6
- data/address-formatting/testcases/countries/eh.yaml +2 -2
- data/address-formatting/testcases/countries/es.yaml +12 -0
- data/address-formatting/testcases/countries/fr.yaml +30 -13
- data/address-formatting/testcases/countries/gb.yaml +63 -4
- data/address-formatting/testcases/countries/hu.yaml +3 -4
- data/address-formatting/testcases/countries/ie.yaml +43 -1
- data/address-formatting/testcases/countries/in.yaml +14 -1
- data/address-formatting/testcases/countries/ir.yaml +19 -8
- data/address-formatting/testcases/countries/it.yaml +30 -2
- data/address-formatting/testcases/countries/kg.yaml +1 -1
- data/address-formatting/testcases/countries/kr.yaml +13 -5
- data/address-formatting/testcases/countries/ml.yaml +9 -9
- data/address-formatting/testcases/countries/mu.yaml +17 -1
- data/address-formatting/testcases/countries/nz.yaml +11 -0
- data/address-formatting/testcases/countries/pa.yaml +17 -0
- data/address-formatting/testcases/countries/ph.yaml +64 -3
- data/address-formatting/testcases/countries/pt.yaml +17 -0
- data/address-formatting/testcases/countries/py.yaml +1 -1
- data/address-formatting/testcases/countries/ru.yaml +3 -3
- data/address-formatting/testcases/countries/sg.yaml +16 -0
- data/address-formatting/testcases/countries/sj.yaml +1 -1
- data/address-formatting/testcases/countries/sk.yaml +20 -2
- data/address-formatting/testcases/countries/sn.yaml +16 -0
- data/address-formatting/testcases/countries/tc.yaml +12 -0
- data/address-formatting/testcases/countries/th.yaml +1 -1
- data/address-formatting/testcases/countries/tk.yaml +1 -1
- data/address-formatting/testcases/countries/tw.yaml +7 -7
- data/address-formatting/testcases/countries/tz.yaml +1 -7
- data/address-formatting/testcases/countries/us.yaml +3 -5
- data/address-formatting/testcases/countries/uy.yaml +1 -1
- data/address-formatting/testcases/countries/vn.yaml +2 -1
- data/address-formatting/testcases/countries/xc.yaml +14 -0
- data/address-formatting/testcases/countries/xk.yaml +20 -0
- data/address_composer.gemspec +11 -9
- data/lib/address_composer/version.rb +1 -1
- data/lib/address_composer.rb +92 -14
- metadata +83 -34
- data/.travis.yml +0 -7
- data/address-formatting/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e248820d945fb5dcea60dc9ac1f25252345709c80f3d7dfcde6874573f522473
|
4
|
+
data.tar.gz: ccebf64be28ed5bd201c321f8e875385e950a510fa9aa4f55f438bb1e95c52be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5533a2a9390874594328d74bac15793dae3be01a419e2cbd9bf6ce6e4ee83e39f2dce405efd6dd29d2b19e25cfc8795f751c675d55457cc354cd9f577a8941
|
7
|
+
data.tar.gz: e851627c55c2b11ce9ff0dc2d8adb8a95d1a2101b2b2030e4ad911aeb1f74d72b354b385df1d790874c063d623b71233f8d89427cda124713b5124e8951ed8a9
|
data/.github/workflows/main.yml
CHANGED
data/.gitmodules
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,21 +1,9 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.6
|
3
3
|
Exclude:
|
4
4
|
- "vendor/**/*"
|
5
5
|
- "db/schema.rb"
|
6
6
|
UseCache: false
|
7
|
-
Rails:
|
8
|
-
Enabled: false
|
9
|
-
Rails/UnknownEnv:
|
10
|
-
Environments:
|
11
|
-
- beta
|
12
|
-
- development
|
13
|
-
- ephemeral
|
14
|
-
- production
|
15
|
-
- qa
|
16
|
-
- sandbox
|
17
|
-
- simulator
|
18
|
-
- test
|
19
7
|
Style/DateTime:
|
20
8
|
Enabled: true
|
21
9
|
Style/AsciiComments:
|
@@ -71,11 +59,11 @@ Naming/PredicateName:
|
|
71
59
|
- is_
|
72
60
|
- has_
|
73
61
|
- have_
|
74
|
-
|
62
|
+
ForbiddenPrefixes:
|
75
63
|
- is_
|
76
64
|
Exclude:
|
77
65
|
- spec/**/*
|
78
|
-
Naming/
|
66
|
+
Naming/MethodParameterName:
|
79
67
|
# Parameter names may be equal to or greater than this value
|
80
68
|
MinNameLength: 3
|
81
69
|
AllowNamesEndingInNumbers: true
|
@@ -256,7 +244,7 @@ Style/WhenThen:
|
|
256
244
|
Lint/EachWithObjectArgument:
|
257
245
|
Description: Check for immutable argument given to each_with_object.
|
258
246
|
Enabled: true
|
259
|
-
Lint/
|
247
|
+
Lint/SuppressedException:
|
260
248
|
Description: Don't suppress exception.
|
261
249
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
262
250
|
Enabled: false
|
@@ -270,10 +258,6 @@ Style/Lambda:
|
|
270
258
|
Description: Use the new lambda literal syntax for single-line blocks.
|
271
259
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#lambda-multi-line
|
272
260
|
Enabled: false
|
273
|
-
Rails/HttpPositionalArguments:
|
274
|
-
Enabled: false
|
275
|
-
Rails/SkipsModelValidations:
|
276
|
-
Enabled: false
|
277
261
|
Lint/AmbiguousBlockAssociation:
|
278
262
|
Enabled: false
|
279
263
|
Style/ClassAndModuleChildren:
|
data/Gemfile.lock
CHANGED
@@ -1,49 +1,74 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
address_composer (
|
5
|
-
mustache
|
4
|
+
address_composer (2.0.0)
|
5
|
+
mustache
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.1)
|
12
|
+
fiddle (1.1.6)
|
13
|
+
io-console (0.8.0)
|
14
|
+
irb (1.6.3)
|
15
|
+
reline (>= 0.3.0)
|
16
|
+
json (2.7.6)
|
14
17
|
mustache (1.1.1)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
ostruct (0.6.1)
|
19
|
+
parallel (1.24.0)
|
20
|
+
parser (3.3.7.0)
|
21
|
+
ast (~> 2.4.1)
|
22
|
+
racc
|
23
|
+
racc (1.8.1)
|
24
|
+
rainbow (3.1.1)
|
25
|
+
rake (13.2.1)
|
26
|
+
regexp_parser (2.10.0)
|
27
|
+
reline (0.6.0)
|
28
|
+
io-console (~> 0.5)
|
29
|
+
rexml (3.4.0)
|
30
|
+
rspec (3.13.0)
|
31
|
+
rspec-core (~> 3.13.0)
|
32
|
+
rspec-expectations (~> 3.13.0)
|
33
|
+
rspec-mocks (~> 3.13.0)
|
34
|
+
rspec-core (3.13.2)
|
35
|
+
rspec-support (~> 3.13.0)
|
36
|
+
rspec-expectations (3.13.3)
|
29
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.
|
31
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.13.0)
|
39
|
+
rspec-mocks (3.13.2)
|
32
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.
|
34
|
-
rspec-support (3.
|
41
|
+
rspec-support (~> 3.13.0)
|
42
|
+
rspec-support (3.13.2)
|
43
|
+
rubocop (1.50.2)
|
44
|
+
json (~> 2.3)
|
45
|
+
parallel (~> 1.10)
|
46
|
+
parser (>= 3.2.0.0)
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
49
|
+
rexml (>= 3.2.5, < 4.0)
|
50
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
51
|
+
ruby-progressbar (~> 1.7)
|
52
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
53
|
+
rubocop-ast (1.30.0)
|
54
|
+
parser (>= 3.2.1.0)
|
55
|
+
ruby-progressbar (1.13.0)
|
56
|
+
unicode-display_width (2.6.0)
|
35
57
|
|
36
58
|
PLATFORMS
|
37
|
-
|
38
|
-
x86_64-
|
59
|
+
x86_64-darwin-24
|
60
|
+
x86_64-linux
|
39
61
|
|
40
62
|
DEPENDENCIES
|
41
63
|
address_composer!
|
42
|
-
bundler
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
64
|
+
bundler
|
65
|
+
fiddle
|
66
|
+
irb
|
67
|
+
ostruct
|
68
|
+
rake
|
69
|
+
reline
|
70
|
+
rspec
|
71
|
+
rubocop
|
47
72
|
|
48
73
|
BUNDLED WITH
|
49
|
-
2.
|
74
|
+
2.4.22
|
data/README.md
CHANGED
@@ -46,6 +46,32 @@ Palo Alto, CA 94303
|
|
46
46
|
United States of America
|
47
47
|
```
|
48
48
|
|
49
|
+
You can also control whether the output should be abbreviated or not by passing `should_abbreviate`:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
require "address_composer"
|
53
|
+
|
54
|
+
address_components = {
|
55
|
+
"house_number" => 301,
|
56
|
+
"road" => "Hamilton Avenue",
|
57
|
+
"neighbourhood" => "Crescent Park",
|
58
|
+
"city" => "Palo Alto",
|
59
|
+
"postcode" => 94303,
|
60
|
+
"county" => "Santa Clara County",
|
61
|
+
"state" => "California",
|
62
|
+
"country" => "United States of America",
|
63
|
+
"country_code" => "US",
|
64
|
+
"should_abbreviate" => true
|
65
|
+
}
|
66
|
+
|
67
|
+
puts AddressComposer.compose(address_components)
|
68
|
+
|
69
|
+
301 Hamilton Ave
|
70
|
+
Palo Alto, CA 94303
|
71
|
+
United States of America
|
72
|
+
|
73
|
+
```
|
74
|
+
|
49
75
|
## Development
|
50
76
|
|
51
77
|
After checking out the repo, run `git submodule init` and `git submodule update` to fetch all the data from the submodule project and check out the mapped commit.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: CI Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
schedule:
|
7
|
+
- cron: '11 22 2 * *'
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
name: Address-Formatting
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
|
18
|
+
- name: Set up perl
|
19
|
+
uses: shogo82148/actions-setup-perl@v1
|
20
|
+
with:
|
21
|
+
perl-version: '5.38'
|
22
|
+
install-modules-with: cpanm
|
23
|
+
|
24
|
+
- name: Tests
|
25
|
+
run: bin/run_tests.t
|
@@ -6,8 +6,7 @@ This project contains templates and test cases for address formats used in terri
|
|
6
6
|
|
7
7
|
### Build Status
|
8
8
|
|
9
|
-
[![Build Status](https://
|
10
|
-
[![Twitter Follow](https://img.shields.io/twitter/follow/OpenCage?label=Follow%20OpenCage&style=social)](https://twitter.com/opencage)
|
9
|
+
[![Build Status](https://github.com/OpenCageData/address-formatting/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenCageData/address-formatting/actions/workflows/ci.yml)
|
11
10
|
|
12
11
|
### An example:
|
13
12
|
|
@@ -32,7 +31,7 @@ we want to write logic to compile an address in the format consumers expect
|
|
32
31
|
|
33
32
|
### Why would you want to do this?
|
34
33
|
|
35
|
-
The intended use case is database or geocoding systems (forward, reverse, autocomplete) where we know both the country of the address and the language of the user/reader. The address is displayed to a consumer (for example in an app) and not used to print on an envelope for actual postal delivery. We use it to format output from the [OpenCage
|
34
|
+
The intended use case is database or geocoding systems (forward, reverse, autocomplete) where we know both the country of the address and the language of the user/reader. The address is displayed to a consumer (for example in an app) and not used to print on an envelope for actual postal delivery. We use it to format output from the [OpenCage Geocoding API](https://opencagedata.com/api).
|
36
35
|
|
37
36
|
### Which addresses are we talking about?
|
38
37
|
|
@@ -53,15 +52,17 @@ Our goal with this repository is a series of (programming) language independent
|
|
53
52
|
|
54
53
|
There are open-source implementations in
|
55
54
|
|
55
|
+
* [Android library](https://github.com/woheller69/AndroidAddressFormatter)
|
56
56
|
* [Elixir](https://github.com/dkuku/ex_address_formatting)
|
57
57
|
* [Go](https://github.com/timonmasberg/address-formatter)
|
58
58
|
* [Java](https://github.com/placemarkt/address-formatter-java)
|
59
59
|
* [Javascript](https://github.com/fragaria/address-formatter)
|
60
|
+
* [Kotlin](https://github.com/bettermile/address-formatter-kotlin)
|
60
61
|
* [Perl](https://metacpan.org/release/Geo-Address-Formatter)
|
61
62
|
* [PHP](https://github.com/predicthq/address-formatter-php)
|
62
|
-
* [Python](https://github.com/
|
63
|
+
* [Python](https://github.com/pudo/addressformatting/tree/master)
|
63
64
|
* [Ruby](https://github.com/mirubiri/address_composer)
|
64
|
-
* [Rust](https://github.com/
|
65
|
+
* [Rust (No Longer Maintained)](https://github.com/antoine-de/address-formatter-rs)
|
65
66
|
* [Scala](https://github.com/ben-willis/address-formatter)
|
66
67
|
|
67
68
|
We would love more language implementations. The more people who use the templates, the more likely bugs will be reported.
|
@@ -69,11 +70,11 @@ If you write a processor, please submit a pull request adding it to the list. Th
|
|
69
70
|
|
70
71
|
### International coverage
|
71
72
|
|
72
|
-
As of
|
73
|
+
As of March 2024 coverage is:
|
73
74
|
|
74
|
-
We are aware of
|
75
|
-
We have
|
76
|
-
We have rules for
|
75
|
+
We are aware of 251 territories
|
76
|
+
We have at least one test for 251 (100%) territories
|
77
|
+
We have rules for 251 (100%) territories
|
77
78
|
0 (0%) territories have neither rules nor tests
|
78
79
|
|
79
80
|
This output is generated by `bin/coverage.pl`
|
@@ -95,8 +96,7 @@ The files are in [YAML](http://yaml.org/) format. The templates are written in [
|
|
95
96
|
* find an addressed location (house, business, etc) in your
|
96
97
|
target territory in OpenStreetMap
|
97
98
|
* get the coordinates (lat, long) of the location
|
98
|
-
* put the coordinates into the [OpenCage
|
99
|
-
page](https://opencagedata.com/demo)
|
99
|
+
* put the coordinates into the [OpenCage Geocoding API demo page](https://opencagedata.com/demo)
|
100
100
|
* look at the resulting JSON in the *Raw Response* tab
|
101
101
|
|
102
102
|
2. edit `conf/countries/worldwide.yaml`
|
@@ -137,6 +137,10 @@ We welcome your pull requests. Together we can address the world!
|
|
137
137
|
|
138
138
|
This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details
|
139
139
|
|
140
|
+
### Additional resources
|
141
|
+
|
142
|
+
If you are working with addresses you may need [lists of random addresses/postcodes/coordinates](https://opencagedata.com/tools/address-lists) (either in general or for specific countries) for testing.
|
143
|
+
|
140
144
|
### Further reading on the challenge of address
|
141
145
|
|
142
146
|
Here's [our blog post anouncing this project](https://blog.opencagedata.com/post/99059889253/good-looking-addresses-solving-the-berlin-berlin) and the motivations behind it.
|
@@ -153,8 +157,10 @@ If all this convinces you that address are evil, please check out [what3words](h
|
|
153
157
|
|
154
158
|
<a href="https://opencagedata.com"><img src="opencage_logo_300_150.png"></a>
|
155
159
|
|
156
|
-
We run
|
160
|
+
We run a worldwide [geocoding API](https://opencagedata.com/api) and [geosearch](https://opencagedata.com/geosearch) service based on open data.
|
161
|
+
Learn more [about us](https://opencagedata.com/about).
|
162
|
+
|
163
|
+
We also organize [Geomob](https://thegeomob.com), a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy [the Geomob podcast](https://thegeomob.com/podcast/).
|
157
164
|
|
158
|
-
We also run [Geomob](https://thegeomob.com), a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy [the Geomob podcast](https://thegeomob.com/podcast/).
|
159
165
|
|
160
166
|
|
@@ -24,7 +24,7 @@ if ($help) {
|
|
24
24
|
exit(0);
|
25
25
|
}
|
26
26
|
|
27
|
-
# get the list of countries
|
27
|
+
# get the list of countries (ISO codes)
|
28
28
|
my %countries;
|
29
29
|
my $country_file = dirname(__FILE__) . "/../conf/country_codes.yaml";
|
30
30
|
open my $FH, "<:encoding(UTF-8)", $country_file or die "unable to open $country_file $!";
|
@@ -33,6 +33,9 @@ while (my $line = <$FH>){
|
|
33
33
|
if ($line =~ m/^(\w\w): \# (.*)$/){
|
34
34
|
$countries{$1} = $2;
|
35
35
|
}
|
36
|
+
elsif ($line =~ m/^"(\w\w)": \# (.*)$/){ # deal with "NO" quoting in yaml
|
37
|
+
$countries{$1} = $2;
|
38
|
+
}
|
36
39
|
}
|
37
40
|
close $FH;
|
38
41
|
my $total_countries = scalar(keys %countries);
|
@@ -50,10 +53,13 @@ foreach my $f (sort @files){
|
|
50
53
|
$f =~ s/\.yaml//;
|
51
54
|
$f = uc($f);
|
52
55
|
$test_countries{$f} = 1;
|
56
|
+
if (!defined($countries{$f})){
|
57
|
+
print STDERR "have a test for $f but it is not a known territory\n";
|
58
|
+
}
|
53
59
|
}
|
54
60
|
my $test_countries = scalar(keys %test_countries);
|
55
61
|
my $test_perc = int(100 * $test_countries / $total_countries );
|
56
|
-
print "We have
|
62
|
+
print "We have at least one test for " . $test_countries . ' ('
|
57
63
|
. $test_perc . '%) territories' . "\n";
|
58
64
|
if ($details){
|
59
65
|
print "We need tests for:\n";
|
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env perl
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# and runs in travis-CI (see .travis.yml)
|
2
|
+
#
|
3
|
+
# run by Github Actions, see .github/workflows/ci.yml
|
4
|
+
#
|
6
5
|
|
7
6
|
use strict;
|
8
7
|
use lib 'perl/lib/perl5';
|
@@ -21,6 +20,20 @@ binmode $builder->output, ":utf8";
|
|
21
20
|
binmode $builder->failure_output, ":utf8";
|
22
21
|
binmode $builder->todo_output, ":utf8";
|
23
22
|
|
23
|
+
{
|
24
|
+
# Some YAML parsers croak on duplicate keys. By default the Perl parser
|
25
|
+
# doesn't. Here we make sure we didn't overlook any duplicate keys.
|
26
|
+
$YAML::XS::ForbidDuplicateKeys = 1;
|
27
|
+
|
28
|
+
my @a_conf_files = File::Find::Rule->file()
|
29
|
+
->name( '*.yaml' )
|
30
|
+
->in( dirname(__FILE__) . '/../conf/' );
|
31
|
+
|
32
|
+
foreach my $conf_file (@a_conf_files) {
|
33
|
+
lives_ok { LoadFile($conf_file) } "parsing file $conf_file";
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
24
37
|
|
25
38
|
my $path = dirname(__FILE__) . '/../testcases';
|
26
39
|
|
@@ -35,16 +48,29 @@ my $conf_path = dirname(__FILE__) . '/../conf';
|
|
35
48
|
my $GAF = $CLASS->new( conf_path => $conf_path );
|
36
49
|
|
37
50
|
sub _one_testcase {
|
38
|
-
my $country
|
39
|
-
my $
|
51
|
+
my $country = shift;
|
52
|
+
my $rh_test = shift;
|
53
|
+
my $abbrv = shift || 0;
|
54
|
+
|
55
|
+
my $formatted;
|
56
|
+
if ($abbrv){
|
57
|
+
$formatted = $GAF->format_address($rh_test->{components}, {abbreviate => 1});
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
$formatted = $GAF->format_address($rh_test->{components});
|
61
|
+
}
|
40
62
|
is(
|
41
|
-
$
|
42
|
-
$
|
43
|
-
$country . ' - ' . $
|
63
|
+
$formatted,
|
64
|
+
$rh_test->{expected},
|
65
|
+
$country . ' - ' . $rh_test->{description}
|
44
66
|
);
|
45
67
|
}
|
46
68
|
|
47
69
|
foreach my $filename (@files){
|
70
|
+
my $abbrv = 0;
|
71
|
+
if ($filename =~ m/abbreviations/){
|
72
|
+
$abbrv = 1;
|
73
|
+
}
|
48
74
|
my $country = basename($filename);
|
49
75
|
$country =~ s/\.\w+$//; # us.yaml => us
|
50
76
|
|
@@ -54,7 +80,7 @@ foreach my $filename (@files){
|
|
54
80
|
} "parsing file $filename";
|
55
81
|
|
56
82
|
foreach my $rh_testcase (@a_testcases){
|
57
|
-
_one_testcase($country, $rh_testcase);
|
83
|
+
_one_testcase($country, $rh_testcase, $abbrv);
|
58
84
|
}
|
59
85
|
}
|
60
86
|
|
@@ -1,4 +1,21 @@
|
|
1
1
|
road:
|
2
|
+
Autopista: Auto
|
3
|
+
Avinguda: Av
|
4
|
+
Baixada: Bda
|
5
|
+
Baixos: Bxs
|
6
|
+
Carretera: Ctra
|
2
7
|
Carrer de: C
|
8
|
+
Monestir: Mtir
|
9
|
+
Parada: Par
|
10
|
+
Passatge: Ptge
|
11
|
+
Passeig: Pg
|
12
|
+
Plaça: Pl
|
13
|
+
Porta: Pta
|
3
14
|
Rambla: Rbla
|
4
|
-
|
15
|
+
Sagrada: Sgda
|
16
|
+
Sagrat: Sgt
|
17
|
+
Sant: St
|
18
|
+
Santa: Sta
|
19
|
+
Travessera: Trav
|
20
|
+
Travessia: Trv
|
21
|
+
via: v
|
@@ -1,4 +1,8 @@
|
|
1
1
|
country:
|
2
|
+
Central African Republic: CAR
|
3
|
+
Democratic Republic of Congo: DRC
|
4
|
+
New Zealand: NZ
|
5
|
+
United Arab Emitrates: UAE
|
2
6
|
United Kingdom: UK
|
3
7
|
United States of America: USA
|
4
8
|
United States Virgin Islands: USVI
|
@@ -18,7 +22,9 @@ road:
|
|
18
22
|
Freeway: Fwy
|
19
23
|
Grove: Gr
|
20
24
|
Highway: HWY
|
21
|
-
|
25
|
+
Junior: Jr
|
26
|
+
Lane: Ln
|
27
|
+
Mountain: Mtn
|
22
28
|
Northeast: NE
|
23
29
|
Northwest: NW
|
24
30
|
Place: Pl
|
@@ -1,25 +1,43 @@
|
|
1
1
|
road:
|
2
|
+
Alameda: Alam
|
3
|
+
Arboleda: Arb
|
4
|
+
Arroyo: Arry
|
2
5
|
Avenida: Avda
|
6
|
+
Bloque: Blq
|
3
7
|
Calle de: C
|
8
|
+
Camino: Cno
|
4
9
|
Carrera: Cra
|
5
10
|
Carrero: Cro
|
11
|
+
Cinturón: Cint
|
6
12
|
Colonia: Col
|
13
|
+
Diagonal: Diag
|
14
|
+
Doctor: Dr
|
15
|
+
Doctora: Dra
|
7
16
|
Estación: Estcn
|
8
17
|
Gran Vía: GV
|
18
|
+
Jardín: Jdín
|
19
|
+
Malecón: Malec
|
9
20
|
Mercado: Merc
|
10
|
-
|
21
|
+
Mirador: Mrdor
|
22
|
+
Nuestra Señora: Ntra Sra
|
23
|
+
Palacio: Pala
|
11
24
|
Parque: Pque
|
25
|
+
Pasadizo: Pzo
|
12
26
|
Pasaje: Psje
|
13
27
|
Paseo: Po
|
28
|
+
Plaza: Pl
|
14
29
|
Pueblo: Pblo
|
15
30
|
Puente: Pnte
|
16
31
|
Puerta: Pta
|
17
|
-
Puerto: Pto
|
32
|
+
Puerto: Pto
|
18
33
|
Rambla: Rbla
|
19
34
|
Ronda: Rda
|
20
35
|
Rotonda: Rtda
|
21
36
|
San: S
|
22
|
-
Sector: Sect
|
23
37
|
Santa: Sta
|
38
|
+
Santo: Sto
|
39
|
+
Santas: Stas
|
40
|
+
Santos: Stos
|
41
|
+
Sector: Sect
|
24
42
|
Viaducto: Vcto
|
25
43
|
|
@@ -1,19 +1,31 @@
|
|
1
1
|
road:
|
2
|
+
Broeder: Br
|
2
3
|
Burgemeester: Burg
|
4
|
+
Commandant: Cmdt
|
3
5
|
Docter: Dr
|
4
6
|
Dokter: Dr
|
5
7
|
Gebroeders: Gebr
|
6
8
|
Generaal: Gen
|
7
9
|
Gracht: Gr
|
10
|
+
Ingenieur: Ir
|
11
|
+
Jonkheer: Jhr
|
8
12
|
Kardinaal: Kard
|
9
13
|
Kolonel: Kol
|
14
|
+
Koning: Kon
|
15
|
+
Koningin: Kon
|
10
16
|
Kort: K
|
11
17
|
Korte: Kte
|
12
18
|
Laan: ln
|
13
19
|
Lange: L
|
20
|
+
Luitenant: Luit
|
14
21
|
Markt: mkt
|
22
|
+
Mejuffrouw: Mej
|
23
|
+
Mevrouw: Mevr
|
15
24
|
Minister: Min
|
16
25
|
Monseigneur: Mgr
|
26
|
+
Noordzijde: NZ
|
27
|
+
Onze-Lieve-Vrouw: OLV
|
28
|
+
Oostzijde: OZ
|
17
29
|
Pastoor: Past
|
18
30
|
Prins: Pr
|
19
31
|
Prinses: Pr
|
@@ -21,6 +33,11 @@ road:
|
|
21
33
|
Sint: St
|
22
34
|
Straat: str
|
23
35
|
Van: v
|
36
|
+
Van der: vd
|
37
|
+
Van den: vd
|
38
|
+
Verlengde: Verl
|
24
39
|
Vrouwe: Vr
|
25
40
|
Weg: wg
|
41
|
+
Westzijde: WZ
|
42
|
+
Zuidzijde: ZZ
|
26
43
|
Zuster: Zr
|