zipfips 0.1.0 → 0.1.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: 78872d07c658fb77a42a09ea69ad66bfdd2be7d9
4
- data.tar.gz: cbcad9f5c231f17f3cda28fe1c127ceac4caef1c
3
+ metadata.gz: 59d5ba25d495af3bad83e0bcaadbf2339f4c9020
4
+ data.tar.gz: 0f0e148e36a31e670d27291535f64137b076b115
5
5
  SHA512:
6
- metadata.gz: f73a34e6dead41905ca814b4979f95d3fcc5d25560c39d43516a0494146ca892c0c27db390f7f84499242dac77007717a9d0e137f90fd3c685f78f752fa48b18
7
- data.tar.gz: 63d03c6b8ba550ae5157b3673c2d6196e1ffa80d7f65629b1e03f720736bea34b5201da1ea89f72a8c66920d7267791d6038978ddb2b597eae8c818aabb24e67
6
+ metadata.gz: 32ae61b78e18a6cf2813de3a722544ed9cddd416bd85049c1b623d4051f837ceb0ecda6d8f48c87a89a879abd4adbafb285410a68d55457be97cd6ba94b85539
7
+ data.tar.gz: 556ce818b6d646442ea0d7b8c4ff2a5d01a0fd9f49ecabd9d275b4117d58529eb8d1090ad62c9dc50973f3182425186fc8e524ea605815b32b9655dc3096e24f
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  /html/
4
4
  /pkg/
5
5
  /vendor/cache/*.gem
6
+ .rspec
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.to_zip(12345) #=> 36093
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
@@ -3,23 +3,33 @@ require 'json'
3
3
  module ZipFips
4
4
  class Handler
5
5
  def is_zip?(code)
6
- !!zips_hash[code.to_s] && !is_fips(code)
6
+ !!fips_hash[code.to_s] && !is_fips?(code)
7
7
  end
8
8
 
9
9
  def is_fips?(code)
10
- !!fips_hash[code.to_s] && !is_zip(code)
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
- fips_hash[code.to_s].to_i
18
+ zips_hash[code.to_s].to_i
15
19
  end
16
20
 
17
21
  def to_fips(code)
18
- zips_hash[code.to_s].to_i
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(File.open("#{File.dirname(__FILE__)}/data/data.json", "r").read)
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
@@ -1,3 +1,3 @@
1
1
  module ZipFips
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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.to_zip(12345).should == 36093
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.to_fips(36093).should == 12345
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
@@ -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 = "ZIP to FIPS and FIPS to ZIP"
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.0
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-26 00:00:00.000000000 Z
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: ZIP to FIPS and FIPS to ZIP
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
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- README.md
3
- ChangeLog.md
4
-
5
- LICENSE.txt
@@ -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: