zipcoder 0.7.4 → 0.8.0
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/README.md +3 -0
- data/Rakefile +6 -4
- data/lib/data/zip_data.yml +133384 -30771
- data/lib/data/zipcode.csv +81832 -42523
- data/lib/zipcoder/cacher/base.rb +23 -17
- data/lib/zipcoder/version.rb +1 -1
- data/spec/zipcoder_spec.rb +30 -6
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf957bd4626db1ebe9a43b99295f34943097a527
|
4
|
+
data.tar.gz: e94e650a6d81852ff2b759036fe73866e7c0b932
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 289ee870b6d3c3eed976d9b5123a479dbdde315c66dc97d77d22e9eeafe93ae9258edcefd4af2dc34fbda2ceaa37bc5b36e8dd9469462266cc8c095ee25c4412
|
7
|
+
data.tar.gz: d4290d8be7b8790935509e2f164ac8769f0f7a1a60424c60aacd6c3c7ae931dd4cce916f653a4ee6f990a93ec1573325344e929e10c66cf9dea201d70c6356ba
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,9 @@ Gem for performing zip code lookup operations
|
|
7
7
|
|
8
8
|
## Revision History
|
9
9
|
|
10
|
+
- v0.8.0:
|
11
|
+
- added support for acceptable cities as well. The "zip_code" lookup will return
|
12
|
+
the primary but the "city, state" lookup will support the acceptable cities
|
10
13
|
- v0.7.4:
|
11
14
|
- updates "zip_cities" to return valid zip_codes (and not just what you enter)
|
12
15
|
- also added "specified_zip" to the city object when entering zip codes. This
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ namespace :zipcoder do
|
|
14
14
|
task :update do
|
15
15
|
|
16
16
|
# Fetch the latest database file
|
17
|
-
uri = URI("http://federalgovernmentzipcodes.us/free-zipcode-database
|
17
|
+
uri = URI("http://federalgovernmentzipcodes.us/free-zipcode-database.csv")
|
18
18
|
puts "Downloading newest zip codes from '#{uri.to_s}'"
|
19
19
|
doc = Net::HTTP.get(uri)
|
20
20
|
|
@@ -34,20 +34,22 @@ namespace :zipcoder do
|
|
34
34
|
|
35
35
|
# Import the CSV file and build the data structure
|
36
36
|
zip_lookup_data = {}
|
37
|
-
city_lookup_data = {}
|
38
37
|
csv = CSV.parse(csv_text, :headers => true)
|
39
38
|
puts "Importing data from '#{filename}'"
|
40
39
|
csv.each do |row|
|
41
|
-
next if row["ZipCodeType"] != "STANDARD"
|
40
|
+
next if row["ZipCodeType"] != "STANDARD" or not (["PRIMARY", "ACCEPTABLE"].include? row["LocationType"])
|
42
41
|
|
43
42
|
zip_code = row["Zipcode"]
|
43
|
+
primary = row["LocationType"] == "PRIMARY"
|
44
44
|
city = row["City"]
|
45
45
|
state = row["State"]
|
46
46
|
lat = row["Lat"].to_f
|
47
47
|
long = row["Long"].to_f
|
48
48
|
|
49
49
|
# Write the zip_lookup_data
|
50
|
-
zip_lookup_data[zip_code]
|
50
|
+
areas = zip_lookup_data[zip_code] || []
|
51
|
+
areas << { zip: zip_code, city: city, state: state, lat: lat, long: long, primary: primary }
|
52
|
+
zip_lookup_data[zip_code] = areas
|
51
53
|
end
|
52
54
|
|
53
55
|
# Write the data to the yaml file
|