jipcode 1.0.1 → 1.1.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
  SHA256:
3
- metadata.gz: 3e5620b236c93df3186c2cb16360abc4814ac465e11b2dce95107a0acbdaca6c
4
- data.tar.gz: 393ee74249d4806e6fe77dc71834d62bc78010c6e7129492d2e5ac93ed644288
3
+ metadata.gz: 8285024e10a4779e8869e3c9326838c96bba8a869b46d0231eadede4ca8e671d
4
+ data.tar.gz: 5d0aef3e01cba5dc2418b9c62330303a43f50f2cdb5457959d8f440e1d0cf038
5
5
  SHA512:
6
- metadata.gz: fd75c97c82f63baa067a92a91169b636775c50cfc2fcf97ff4719dcdb2a3c0891bffc6623c5a4eea8cff1c1c01bf133c3c35a34f3dda18d904c64bd47cb1a130
7
- data.tar.gz: 0a1cf5c1391da5090a59fb3218df99e1d0a8351422a9ba2a2cf5a42034407c91b7e43074ddb722dfd88b5fcb3e3b79dffb93e2ddc3e670a0d5caf4a0f305ce87
6
+ metadata.gz: d9a5a5d42153e4c812d2a6c6895dc31376f518af7d0799ab3bc156dab2971407d86b832de6eff09dc51e4c1385c73d6a21fb9a2fb98e48b9f0478c935835eb45
7
+ data.tar.gz: cf17f381687e4d2c0e803b6f8e8fb0a68a8c1ee1b6e1b1321596a778072234b7ecb6e5184ebd43b5f1cc53f132ee6ef33124e807534c38c69b77ef0992a9535e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jipcode (1.0.1)
4
+ jipcode (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module Jipcode
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
data/lib/jipcode.rb CHANGED
@@ -4,12 +4,29 @@ require 'csv'
4
4
  module Jipcode
5
5
  ZIPCODE_PATH = "#{File.dirname(__FILE__)}/../zipcode/latest".freeze
6
6
 
7
+ def locate(zipcode)
8
+ path = "#{ZIPCODE_PATH}/#{zipcode[0..2]}.csv"
9
+ return [] unless File.exist?(path)
10
+
11
+ addresses_csv = open(path) { |f| f.read }
12
+ addresses_array = CSV.parse(addresses_csv).select { |address| address[0] == zipcode }
13
+ addresses_array.map do |address_param|
14
+ {
15
+ zipcode: address_param[0],
16
+ prefecture: address_param[1],
17
+ city: address_param[2],
18
+ town: address_param[3]
19
+ }
20
+ end
21
+ end
22
+
7
23
  def search(zipcode)
24
+ warn '[DEPRECATION] `search` is deprecated. Please use `locate` instead.'
8
25
  path = "#{ZIPCODE_PATH}/#{zipcode[0..2]}.csv"
9
26
  return [] unless File.exist?(path)
10
27
  addresses = open(path) { |f| f.read }
11
28
  CSV.parse(addresses).select { |address| address[0] == zipcode }
12
29
  end
13
30
 
14
- module_function :search
31
+ module_function :locate, :search
15
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jipcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rinkei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-26 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler