fips-county-codes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ module NistCodes
2
+ fips = {}
3
+ state_county = {}
4
+
5
+ File.open('lib/national.txt') do |f|
6
+ f.readline # skip the first line with headers
7
+
8
+ until f.eof
9
+ row = f.readline.chomp.split(',')
10
+ state, state_code, county_code, county, class_code_ignored = row
11
+
12
+ fips[state] = {} if not fips.member?(state)
13
+
14
+ fips_code = (state_code + county_code).to_i
15
+ fips[state][county] = fips_code
16
+
17
+ county2 = county.gsub(' County', '')
18
+ fips[state][county2] = fips_code if county != county2
19
+
20
+ state_county[fips_code] = [state, county]
21
+ end
22
+ end
23
+
24
+ FIPS = fips
25
+ STATE_COUNTY = state_county
26
+ end
27
+
@@ -0,0 +1,14 @@
1
+ require_relative 'helper'
2
+
3
+ describe 'Mapping (State, County) between (NISTCodes Code)' do
4
+ it 'looks up a fips for a state and county' do
5
+
6
+ NistCodes::FIPS['CA']['Los Angeles'].should == 6037
7
+ NistCodes::FIPS['CA']['Los Angeles County'].should == 6037
8
+
9
+ end
10
+
11
+ it 'looks up a state and county' do
12
+ NistCodes::STATE_COUNTY[6037].should == ['CA', 'Los Angeles County']
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ require 'nist_codes'
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fips-county-codes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ray Pereda
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ description:
63
+ email: ray@nationbuilder.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files:
67
+ - LICENSE.txt
68
+ - README.rdoc
69
+ files:
70
+ - .document
71
+ - .rvmrc
72
+ - Gemfile
73
+ - Gemfile.lock
74
+ - LICENSE.txt
75
+ - README.rdoc
76
+ - Rakefile
77
+ - VERSION
78
+ - fips-county-codes.gemspec
79
+ - lib/national.txt
80
+ - lib/nist_codes.rb
81
+ - test/fips_lookups_spec.rb
82
+ - test/helper.rb
83
+ homepage: http://github.com/raypereda/fips-county-codes
84
+ licenses:
85
+ - MIT
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ segments:
97
+ - 0
98
+ hash: 1431569481171012525
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 1.8.24
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: data structures for querying FIPS codes
111
+ test_files: []