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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a8c448625e1f29e651486fe183f07fa0b5b5b4d
4
- data.tar.gz: 9234087086d3e048d8ca50eae52f2bf2f5b21e4a
3
+ metadata.gz: cf957bd4626db1ebe9a43b99295f34943097a527
4
+ data.tar.gz: e94e650a6d81852ff2b759036fe73866e7c0b932
5
5
  SHA512:
6
- metadata.gz: 02a075c911f38c1f14035b0dd52f0fee5417c900d19f23b4a1cf9c26a08c32f3015ef421c30bf4a8405c913c3dba4492cc09b65221d4f31694a05c91ffd8f337
7
- data.tar.gz: 6d2c2eb7f9b5af8c28f73390fef20152c9cb2f60dcd7c55c469305073e5f5fab2fe887704052503e5859ac1cb89d362f7a457d32ab8f2f228bb794dfc20bd75b
6
+ metadata.gz: 289ee870b6d3c3eed976d9b5123a479dbdde315c66dc97d77d22e9eeafe93ae9258edcefd4af2dc34fbda2ceaa37bc5b36e8dd9469462266cc8c095ee25c4412
7
+ data.tar.gz: d4290d8be7b8790935509e2f164ac8769f0f7a1a60424c60aacd6c3c7ae931dd4cce916f653a4ee6f990a93ec1573325344e929e10c66cf9dea201d70c6356ba
data/.gitignore CHANGED
@@ -14,3 +14,4 @@
14
14
  .idea
15
15
  *.tmp
16
16
  .DS_Store
17
+ *.swp
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-Primary.csv")
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] = { zip: zip_code, city: city, state: state, lat: lat, long: long }
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