dc_address_parser 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/dc_address_parser.rb +2 -0
- data/lib/dc_address_parser/address.rb +6 -28
- data/lib/dc_address_parser/constants.rb +24 -0
- data/lib/dc_address_parser/version.rb +1 -1
- data/script/cibuild +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07f0c5a7d4ac58c6defcc2e5e4f9053fe486137c
|
4
|
+
data.tar.gz: 7421f846de941ad02a85fb5f1c42990b41da3484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 918a182fa39f6bf528f582531745a9871fc48587fcedb331e7b674d837a27e2a6b36a6dc20a6d4cc5d91d4b6daff927df99dbd93e50c7e69c8f4724cb113d0d5
|
7
|
+
data.tar.gz: 5b2fcd0689f395b98a0c1fb42d4859f97d89425ae47586334ee1ac7abe1c0e42a46175042742b30a19a490b1e6f44b2ca2c98bd2c98cb96bd789a91c2f1128b4
|
data/.gitignore
CHANGED
data/lib/dc_address_parser.rb
CHANGED
@@ -4,33 +4,11 @@ module DcAddressParser
|
|
4
4
|
|
5
5
|
attr_reader :raw_address
|
6
6
|
|
7
|
-
CITY = "WASHINGTON, DC"
|
8
|
-
STREET_TYPES = {
|
9
|
-
"STREET" => "ST",
|
10
|
-
"AVENUE" => "AVE",
|
11
|
-
"BOULEVARD" => "BLVD",
|
12
|
-
"ROAD" => "RD",
|
13
|
-
"PLACE" => "PL",
|
14
|
-
"DRIVE" => "DR",
|
15
|
-
"CIRCLE" => "CIR",
|
16
|
-
"PALZA" => "PLZ",
|
17
|
-
"COURT" => "CT",
|
18
|
-
"ALLEY" => "AL",
|
19
|
-
"TERRACE" => "TER"
|
20
|
-
}
|
21
|
-
|
22
|
-
DIRECTIONS = {
|
23
|
-
"NORTH" => "N",
|
24
|
-
"SOUTH" => "S",
|
25
|
-
"EAST" => "E",
|
26
|
-
"WEST" => "W"
|
27
|
-
}
|
28
|
-
|
29
7
|
NUMBER_REGEX = /\A(\d+)[A-Z]*/
|
30
8
|
NUMBER_SUFFIX_REGEX = /(\d+\/\d+|rear)/i
|
31
9
|
STREET_NAME_REGEX = /([A-Z0-9' ]+)/
|
32
|
-
STREET_TYPE_REGEX = /\b(#{Regexp.union(STREET_TYPES.keys)})\b/
|
33
|
-
STREET_TYPE_ABV_REGEX = /\b(#{Regexp.union(STREET_TYPES.values)})\b/
|
10
|
+
STREET_TYPE_REGEX = /\b(#{Regexp.union(DcAddressParser::STREET_TYPES.keys)})\b/
|
11
|
+
STREET_TYPE_ABV_REGEX = /\b(#{Regexp.union(DcAddressParser::STREET_TYPES.values)})\b/
|
34
12
|
QUADRANT_REGEX = /([NS][EW])/
|
35
13
|
|
36
14
|
REQUIRED_PARTS = [:number, :street_name, :street_type, :quadrant]
|
@@ -98,7 +76,7 @@ module DcAddressParser
|
|
98
76
|
street_type: street_type,
|
99
77
|
quadrant: quadrant,
|
100
78
|
unit_number: unit_number,
|
101
|
-
city: CITY
|
79
|
+
city: DcAddressParser::CITY
|
102
80
|
}
|
103
81
|
end
|
104
82
|
|
@@ -151,7 +129,7 @@ module DcAddressParser
|
|
151
129
|
end
|
152
130
|
|
153
131
|
def normalize_street_type
|
154
|
-
@address.gsub!(STREET_TYPE_ABV_REGEX, STREET_TYPES.invert)
|
132
|
+
@address.gsub!(STREET_TYPE_ABV_REGEX, DcAddressParser::STREET_TYPES.invert)
|
155
133
|
end
|
156
134
|
|
157
135
|
def normalize_rear
|
@@ -171,8 +149,8 @@ module DcAddressParser
|
|
171
149
|
end
|
172
150
|
|
173
151
|
def normalize_directions
|
174
|
-
regex = /\b(#{Regexp.union DIRECTIONS.values})(?=\s+|\.)/
|
175
|
-
@address.gsub!(regex, DIRECTIONS.invert)
|
152
|
+
regex = /\b(#{Regexp.union DcAddressParser::DIRECTIONS.values})(?=\s+|\.)/
|
153
|
+
@address.gsub!(regex, DcAddressParser::DIRECTIONS.invert)
|
176
154
|
end
|
177
155
|
|
178
156
|
def normalize_mt
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DcAddressParser
|
2
|
+
CITY = "WASHINGTON, DC"
|
3
|
+
|
4
|
+
STREET_TYPES = {
|
5
|
+
"STREET" => "ST",
|
6
|
+
"AVENUE" => "AVE",
|
7
|
+
"BOULEVARD" => "BLVD",
|
8
|
+
"ROAD" => "RD",
|
9
|
+
"PLACE" => "PL",
|
10
|
+
"DRIVE" => "DR",
|
11
|
+
"CIRCLE" => "CIR",
|
12
|
+
"PALZA" => "PLZ",
|
13
|
+
"COURT" => "CT",
|
14
|
+
"ALLEY" => "AL",
|
15
|
+
"TERRACE" => "TER"
|
16
|
+
}
|
17
|
+
|
18
|
+
DIRECTIONS = {
|
19
|
+
"NORTH" => "N",
|
20
|
+
"SOUTH" => "S",
|
21
|
+
"EAST" => "E",
|
22
|
+
"WEST" => "W"
|
23
|
+
}
|
24
|
+
end
|
data/script/cibuild
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dc_address_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- dc_address_parser.gemspec
|
127
127
|
- lib/dc_address_parser.rb
|
128
128
|
- lib/dc_address_parser/address.rb
|
129
|
+
- lib/dc_address_parser/constants.rb
|
129
130
|
- lib/dc_address_parser/version.rb
|
130
131
|
- script/bootstrap
|
131
132
|
- script/cibuild
|