zipfips 0.1.0 → 0.1.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 +4 -4
- data/.gitignore +1 -0
- data/README.md +3 -1
- data/lib/zipfips/handler.rb +15 -5
- data/lib/zipfips/version.rb +1 -1
- data/spec/zipfips_spec.rb +7 -2
- data/zipfips.gemspec +1 -1
- metadata +3 -5
- data/.document +0 -5
- data/.rdoc_options +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59d5ba25d495af3bad83e0bcaadbf2339f4c9020
|
4
|
+
data.tar.gz: 0f0e148e36a31e670d27291535f64137b076b115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32ae61b78e18a6cf2813de3a722544ed9cddd416bd85049c1b623d4051f837ceb0ecda6d8f48c87a89a879abd4adbafb285410a68d55457be97cd6ba94b85539
|
7
|
+
data.tar.gz: 556ce818b6d646442ea0d7b8c4ff2a5d01a0fd9f49ecabd9d275b4117d58529eb8d1090ad62c9dc50973f3182425186fc8e524ea605815b32b9655dc3096e24f
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -13,9 +13,11 @@ Easily convert between ZIP codes and FIPS codes
|
|
13
13
|
|
14
14
|
ZF ||= ZipFips::Handler.new
|
15
15
|
|
16
|
-
ZF.
|
16
|
+
ZF.to_fips(12345) #=> 36093
|
17
17
|
ZF.to_zip(36093) #=> 12345
|
18
18
|
|
19
|
+
ZF.convert(36093) #=> 12345
|
20
|
+
|
19
21
|
## Install
|
20
22
|
|
21
23
|
$ gem install zipfips
|
data/lib/zipfips/handler.rb
CHANGED
@@ -3,23 +3,33 @@ require 'json'
|
|
3
3
|
module ZipFips
|
4
4
|
class Handler
|
5
5
|
def is_zip?(code)
|
6
|
-
!!
|
6
|
+
!!fips_hash[code.to_s] && !is_fips?(code)
|
7
7
|
end
|
8
8
|
|
9
9
|
def is_fips?(code)
|
10
|
-
!!
|
10
|
+
!!zips_hash[code.to_s]
|
11
|
+
end
|
12
|
+
|
13
|
+
def convert(code)
|
14
|
+
is_zip?(code) ? to_fips(code) : to_zip(code)
|
11
15
|
end
|
12
16
|
|
13
17
|
def to_zip(code)
|
14
|
-
|
18
|
+
zips_hash[code.to_s].to_i
|
15
19
|
end
|
16
20
|
|
17
21
|
def to_fips(code)
|
18
|
-
|
22
|
+
fips_hash[code.to_s].to_i
|
19
23
|
end
|
20
24
|
|
25
|
+
private
|
26
|
+
|
21
27
|
def fips_hash
|
22
|
-
@fips_hash ||= JSON.parse(
|
28
|
+
@fips_hash ||= JSON.parse(fips_file.read)
|
29
|
+
end
|
30
|
+
|
31
|
+
def fips_file
|
32
|
+
File.open("#{File.dirname(__FILE__)}/data/data.json", "r")
|
23
33
|
end
|
24
34
|
|
25
35
|
def zips_hash
|
data/lib/zipfips/version.rb
CHANGED
data/spec/zipfips_spec.rb
CHANGED
@@ -6,10 +6,15 @@ describe ZipFips do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should return the proper FIPS code for a ZIP code" do
|
9
|
-
ZF.
|
9
|
+
expect(ZF.to_fips(12345)).to eq(36093)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should return the proper ZIP code for a FIPS code" do
|
13
|
-
ZF.
|
13
|
+
expect(ZF.to_zip(36093)).to eq(12345)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should automatically convert between the two" do
|
17
|
+
expect(ZF.convert(36093)).to eq(12345)
|
18
|
+
expect(ZF.convert(12345)).to eq(36093)
|
14
19
|
end
|
15
20
|
end
|
data/zipfips.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.name = "zipfips"
|
9
9
|
gem.version = ZipFips::VERSION
|
10
10
|
gem.summary = "Easily convert between ZIP codes and FIPS codes"
|
11
|
-
gem.description = "
|
11
|
+
gem.description = "FIPS to ZIP and ZIP to FIPS"
|
12
12
|
gem.license = "MIT"
|
13
13
|
gem.authors = ["Bryce Dorn"]
|
14
14
|
gem.email = "brycedorn@gmail.com"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zipfips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce Dorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,15 +80,13 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.2'
|
83
|
-
description:
|
83
|
+
description: FIPS to ZIP and ZIP to FIPS
|
84
84
|
email: brycedorn@gmail.com
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
-
- ".document"
|
90
89
|
- ".gitignore"
|
91
|
-
- ".rdoc_options"
|
92
90
|
- ".rspec"
|
93
91
|
- Gemfile
|
94
92
|
- LICENSE.txt
|
data/.document
DELETED
data/.rdoc_options
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
--- !ruby/object:RDoc::Options
|
2
|
-
encoding: UTF-8
|
3
|
-
static_path: []
|
4
|
-
rdoc_include:
|
5
|
-
- .
|
6
|
-
charset: UTF-8
|
7
|
-
exclude:
|
8
|
-
hyperlink_all: false
|
9
|
-
line_numbers: false
|
10
|
-
main_page: README.md
|
11
|
-
markup: markdown
|
12
|
-
show_hash: false
|
13
|
-
tab_width: 8
|
14
|
-
title: zipfips Documentation
|
15
|
-
visibility: :protected
|
16
|
-
webcvs:
|