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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/jipcode/version.rb +1 -1
- data/lib/jipcode.rb +18 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8285024e10a4779e8869e3c9326838c96bba8a869b46d0231eadede4ca8e671d
|
4
|
+
data.tar.gz: 5d0aef3e01cba5dc2418b9c62330303a43f50f2cdb5457959d8f440e1d0cf038
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9a5a5d42153e4c812d2a6c6895dc31376f518af7d0799ab3bc156dab2971407d86b832de6eff09dc51e4c1385c73d6a21fb9a2fb98e48b9f0478c935835eb45
|
7
|
+
data.tar.gz: cf17f381687e4d2c0e803b6f8e8fb0a68a8c1ee1b6e1b1321596a778072234b7ecb6e5184ebd43b5f1cc53f132ee6ef33124e807534c38c69b77ef0992a9535e
|
data/Gemfile.lock
CHANGED
data/lib/jipcode/version.rb
CHANGED
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
|
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-
|
11
|
+
date: 2018-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|