zipcoder 0.8.0 → 0.8.1

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: cf957bd4626db1ebe9a43b99295f34943097a527
4
- data.tar.gz: e94e650a6d81852ff2b759036fe73866e7c0b932
3
+ metadata.gz: d5ea79e54e07f65092ff72021e80e076cba9e348
4
+ data.tar.gz: d5193fdcbcb13cb7fa7badf543c02b23027c21e2
5
5
  SHA512:
6
- metadata.gz: 289ee870b6d3c3eed976d9b5123a479dbdde315c66dc97d77d22e9eeafe93ae9258edcefd4af2dc34fbda2ceaa37bc5b36e8dd9469462266cc8c095ee25c4412
7
- data.tar.gz: d4290d8be7b8790935509e2f164ac8769f0f7a1a60424c60aacd6c3c7ae931dd4cce916f653a4ee6f990a93ec1573325344e929e10c66cf9dea201d70c6356ba
6
+ metadata.gz: b87a6b2a6fcaa9f2312a933341fb77bdd2c05656a074eb3546b283efd13a9850ab2871d2461dc604df7a8a5289838c10417c730ebdfbcdd590553cb37fedb1d3
7
+ data.tar.gz: c68067f063772d7a9e0bb2c3d4752da71f3656cb302a8fafe8b2887dc09a2778a617a9b255b9c21138897c405546c2ef8706247ff3070d927c7687918d90f83b
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.8.1:
11
+ - added "filter" argument to "city_info" to filter the zip codes
10
12
  - v0.8.0:
11
13
  - added support for acceptable cities as well. The "zip_code" lookup will return
12
14
  the primary but the "city, state" lookup will support the acceptable cities
@@ -225,6 +227,7 @@ Zipcoder.city_info("Atlanta, GA", **args)
225
227
 
226
228
  - keys [Array] - array of keys to include (filters out the others)
227
229
  - zips_only [Bool] - set to "true" if you want an array of just the zip codes for the city
230
+ - filter [String] - zip code string (i.e. "78701-78704,78748") that will filter the zip codes (ignored if "zip_code")
228
231
 
229
232
  **notes:**
230
233
 
@@ -244,6 +247,9 @@ puts "Austin, TX".city_info
244
247
 
245
248
  puts "Austin, TX".city_info(zips_only: true)
246
249
  # > ["78701", "78702", "78703", ...]
250
+
251
+ puts "Austin, TX".city_info(filter: "78701-78704,78748")
252
+ # > {:zip=>"78701-78705,78710,78712,78717,...", :specified_zip=> "78701-78704,78748", :city=>"AUSTIN", :state=>"TX", :lat=>30.26, :long=>-97.74}
247
253
  ```
248
254
 
249
255
  #### Method: Zipcoder.state_cities(state, **args)
@@ -1,3 +1,3 @@
1
1
  module Zipcoder
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
data/lib/zipcoder.rb CHANGED
@@ -113,6 +113,13 @@ module Zipcoder
113
113
  cache_key = self._cache_key(city_state)
114
114
  cached_value = self.cacher.read_city_cache(cache_key)
115
115
 
116
+ # If filter specified, create "specified_zip"
117
+ if kwargs[:filter]
118
+ normal_zips = cached_value[:zip].breakout_zips
119
+ filter_zips = kwargs[:filter].breakout_zips
120
+ cached_value[:specified_zip] = (normal_zips & filter_zips).combine_zips
121
+ end
122
+
116
123
  # Return it
117
124
  if cached_value == nil
118
125
  nil
@@ -299,6 +299,16 @@ describe Zipcoder do
299
299
  expect(zip_codes[-1]).to eq('78799')
300
300
  end
301
301
 
302
+ it "returns the specified zip codes in the filter" do
303
+ city_info = "Austin, TX".city_info filter: "78701-78704,78748,13601"
304
+ expect(city_info[:city]).to eq("Austin")
305
+ expect(city_info[:state]).to eq("TX")
306
+ expect(city_info[:specified_zip]).to eq("78701-78704,78748")
307
+ expect(city_info[:zip].start_with?("78701")).to eq(true)
308
+ expect(city_info[:lat]).to eq(30.315)
309
+ expect(city_info[:long]).to eq(-97.71)
310
+ end
311
+
302
312
  it "returns an nil when the city state is non-existent" do
303
313
  zip_codes = ", ".city_info
304
314
  expect(zip_codes).to be_nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipcoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-20 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler