zipcoder 0.6.0 → 0.6.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
  SHA1:
3
- metadata.gz: cb1e8913fb697af3a6480f88c203a2185bc04314
4
- data.tar.gz: ad5b873b490e4e31f9d1dc692baa4d457bdd9b43
3
+ metadata.gz: 8571e134b662516144e40b8573db85c7b2b0c43b
4
+ data.tar.gz: 2070c049408fd4fe282fe99a091967667ce8bb14
5
5
  SHA512:
6
- metadata.gz: b3431d07be11bb3338bf0c73a3cacc0a3b9ca1b54fecea557a8a070acb6e1213f8d15e8efd3fffa6097ad06447b62710362b58a0ba94205d2ddd74f641febeed
7
- data.tar.gz: 8b466c4f9d1e334bae0d2726574d5ba1ca73bec5eeb6a7adcb446b54e0410823875a3b7fe4dba30efa6db4abb779682f835ec69a369a8e3d30477784b6d10aec
6
+ metadata.gz: 9bbaa6d9b65ee480e634b3f03ad4628098bf245426fdefce2e7ba4d219007c6d594c2e500cb091a6c762e2acd3ad246e04529e9dafd843763c9f57b777e989a5
7
+ data.tar.gz: ca0550798ed00b6af3cf8d0f09469288a269bba19a3ce8d6fec9632ca9733dc9b154dba2f0b25e9c52ab66e0a08b17e80bac6b135191e0a7d5461d3a8dc0b7af
data/README.md CHANGED
@@ -7,6 +7,8 @@ Gem for performing zip code lookup operations
7
7
 
8
8
  ## Revision History
9
9
 
10
+ - v0.6.1:
11
+ - bug fix for the "grouped" option in the "zip_cities" method
10
12
  - v0.6.0:
11
13
  - added "grouped" option to "zip_cities"
12
14
  - v0.5.0:
@@ -1,3 +1,3 @@
1
1
  module Zipcoder
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/lib/zipcoder.rb CHANGED
@@ -58,14 +58,20 @@ module Zipcoder
58
58
 
59
59
  cities = {}
60
60
  last_key = nil
61
+ last_zip = nil
61
62
  self._parse_zip_string(zip_string).each do |zip|
62
63
  info = zip.zip_info
63
64
  if info == nil
64
- key = last_key
65
+ if last_zip != nil and zip.to_i == last_zip.to_i + 1
66
+ key = last_key
67
+ else
68
+ key = nil
69
+ end
65
70
  else
66
71
  key = "#{info[:city]}, #{info[:state]}"
67
72
  end
68
73
  last_key = key
74
+ last_zip = zip
69
75
 
70
76
  if key == nil
71
77
  next
@@ -193,10 +193,10 @@ describe Zipcoder do
193
193
 
194
194
  context "#grouped" do
195
195
  it "returns the cities grouped" do
196
- zip_cities = "78751,13601,78613,78702-78750".zip_cities grouped: true
197
- expect(zip_cities.keys.sort).to eq(["13601", "78613", "78702-78751"])
196
+ zip_cities = "78751,13601,78613,78700-78750".zip_cities grouped: true
197
+ expect(zip_cities.keys.sort).to eq(["13601", "78613", "78701-78751"])
198
198
 
199
- zip_info = zip_cities["78702-78751"]
199
+ zip_info = zip_cities["78701-78751"]
200
200
  expect(zip_info[:city]).to eq("Austin")
201
201
  expect(zip_info[:state]).to eq("TX")
202
202
  expect(zip_info[:zip].start_with?("78701")).to eq(true)
@@ -219,9 +219,9 @@ describe Zipcoder do
219
219
  end
220
220
 
221
221
  it "returns just names of cities grouped" do
222
- zip_cities = "78751,13601,78613,78702-78750".zip_cities grouped: true, names_only: true
223
- expect(zip_cities.keys.sort).to eq(["13601", "78613", "78702-78751"])
224
- expect(zip_cities).to eq({"78702-78751" => "Austin, TX", "78613" => "Cedar Park, TX", "13601" => "Watertown, NY"})
222
+ zip_cities = "78751,13601,78613,78700-78750".zip_cities grouped: true, names_only: true
223
+ expect(zip_cities.keys.sort).to eq(["13601", "78613", "78701-78751"])
224
+ expect(zip_cities).to eq({"78701-78751" => "Austin, TX", "78613" => "Cedar Park, TX", "13601" => "Watertown, NY"})
225
225
  end
226
226
  end
227
227
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipcoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapman