geolookup 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +1 -0
- data/CHANGELOG.rdoc +3 -0
- data/README.md +13 -0
- data/lib/geolookup/usa/county.rb +17 -8
- data/lib/geolookup/usa/state.rb +1 -1
- data/lib/geolookup/version.rb +1 -1
- data/spec/lib/state_spec.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OWM2MzYzOWNmOWQzMWMzMjZhZGI1OGZlY2YyYTcyMmJhMTRjNGI2Mw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 580a97b4c3ccf09e13597b09ff662a7667ba4721
|
4
|
+
data.tar.gz: a9130c7074c9d1c4c2ef1d8fdfaec33dcd55967d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YTc5MDUwMTIwOTNlMWNkMTY2NTdiOTRiYTgyODhjN2NmMzZmNjkwNzVkODIy
|
11
|
-
N2E3ZTM2NGFiMmY4MjNkNzVkYzAzNTI4ZjA4NzU3YmI2OWExM2E=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NmZmMTQ4YWY4ZTIxNTczMjEyM2U0MGZjM2I1YmUzOWZkNzI2YmQ1OGRlOTM5
|
14
|
-
MTQ0NjYyZTk3M2I2ZWRlOTc0ZGYyZGMzZDc3MjY3ZDYwZWJkYjJiN2JkOTQ4
|
15
|
-
MmFmYjRiZmZjOTg4NTk1ODMzMjQwMzVjYTI4OWVkYTZkY2ViYTM=
|
6
|
+
metadata.gz: ec3cbe285dd37dd4634f81fef802b6d99ccd2613e255f636cb80d0857d545a811ace2a2cadf4e9d0b184587d85159e8c83e02ee983e4fe4dbdf0b0e03475c344
|
7
|
+
data.tar.gz: 0d5d8da8942e24bd3726f2ce2ea9ffde147eacb606d7e34e37a4227d342650276fb3deb71895e84c9cbc1118d0f8b2add82f8f921bb7822c7fc6eb61ed8fc9b5
|
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Geolookup [![Build Status](https://travis-ci.org/Spokeo/geolookup.png?branch=master)](https://travis-ci.org/Spokeo/geolookup)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/Spokeo/geolookup.png)](https://codeclimate.com/github/Spokeo/geolookup)
|
2
3
|
|
3
4
|
This gem wraps very common Geo lookups to either FIPS data or the collection of international data lookups. All codes on the app are FIPS codes.
|
4
5
|
|
@@ -52,6 +53,18 @@ Geolookup::USA::State.abbreviation_to_lat_long("AL")
|
|
52
53
|
Geolookup::USA::State.code_to_lat_long(1)
|
53
54
|
# => [ 32318231, -86602298]
|
54
55
|
|
56
|
+
# US State Names
|
57
|
+
Geolookup::USA::State.names
|
58
|
+
# => ["Alabama", "Alaska", ...]
|
59
|
+
|
60
|
+
# US State Abbreviations
|
61
|
+
Geolookup::USA::State.abbreviations
|
62
|
+
# => ["AL", "AK", "AZ", ...]
|
63
|
+
|
64
|
+
# US State Codes
|
65
|
+
Geolookup::USA::State.codes
|
66
|
+
# => [1, 2, 4, ...]
|
67
|
+
|
55
68
|
# US County Examples:
|
56
69
|
|
57
70
|
# Given a state code and county code return the county name
|
data/lib/geolookup/usa/county.rb
CHANGED
@@ -19,9 +19,7 @@ module Geolookup
|
|
19
19
|
# EX: code_to_name(1, 1) => "AUTAUGA"
|
20
20
|
def self.code_to_name(state_code, county_code)
|
21
21
|
@county_code_to_name ||= Geolookup.load_hash_from_file(COUNTY_CODE_TO_NAME_FILE)
|
22
|
-
|
23
|
-
|
24
|
-
@county_code_to_name[state_code.to_s.to_i][county_code.to_s.to_i]
|
22
|
+
get_value_from_hash(@county_code_to_name, state_code.to_s.to_i, county_code.to_s.to_i)
|
25
23
|
end
|
26
24
|
|
27
25
|
|
@@ -34,9 +32,7 @@ module Geolookup
|
|
34
32
|
# EX: name_to_code(1, 'baldwin') => {1 => {"AUTAUGA" => 1, "BALDWIN" => 3, ....}}
|
35
33
|
def self.name_to_code(state_code, county_name)
|
36
34
|
@county_name_to_code ||= Geolookup.load_hash_from_file(COUNTY_NAME_TO_CODE_FILE)
|
37
|
-
|
38
|
-
|
39
|
-
@county_name_to_code[state_code.to_s.to_i][county_name.to_s.upcase]
|
35
|
+
get_value_from_hash(@county_name_to_code, state_code.to_s.to_i, county_name.to_s.upcase)
|
40
36
|
end
|
41
37
|
|
42
38
|
|
@@ -47,10 +43,23 @@ module Geolookup
|
|
47
43
|
#
|
48
44
|
def self.code_to_lat_long(state_code, county_code)
|
49
45
|
@county_lat_long ||= Geolookup.load_hash_from_file(COUNTY_LAT_LONG_FILE)
|
50
|
-
|
46
|
+
get_value_from_hash(@county_lat_long, state_code.to_s.to_i, county_code.to_s.to_i)
|
47
|
+
end
|
51
48
|
|
52
|
-
|
49
|
+
###################################################################
|
50
|
+
# self.get_value_from_hash
|
51
|
+
#
|
52
|
+
# Helper function to reduce code repetition
|
53
|
+
# Given a hash and 2 keys returns the value at that hash
|
54
|
+
# Return nil if the either key is not in the hash
|
55
|
+
#
|
56
|
+
# EX: get_value(@county_code_to_name, 1, 1) => "AUTAUGA"
|
57
|
+
def self.get_value_from_hash(hash, key1, key2)
|
58
|
+
return nil unless hash[key1]
|
59
|
+
hash[key1][key2]
|
53
60
|
end
|
61
|
+
|
62
|
+
private_class_method :get_value_from_hash
|
54
63
|
end
|
55
64
|
end
|
56
65
|
end
|
data/lib/geolookup/usa/state.rb
CHANGED
@@ -40,7 +40,7 @@ module Geolookup
|
|
40
40
|
# a state full name
|
41
41
|
#
|
42
42
|
def self.name_to_abbreviation(state_abbrev)
|
43
|
-
|
43
|
+
code_to_abbreviation(abbreviation_to_code(state_abbrev))
|
44
44
|
end
|
45
45
|
|
46
46
|
###################################################################
|
data/lib/geolookup/version.rb
CHANGED
data/spec/lib/state_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe "Geolookup::USA::State" do
|
|
12
12
|
|
13
13
|
describe "#name_to_abbreviation" do
|
14
14
|
it "should return name to state abbreviation" do
|
15
|
-
expect(Geolookup::USA::State.name_to_abbreviation('
|
15
|
+
expect(Geolookup::USA::State.name_to_abbreviation('California')).to eql("CA")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return nil if no state abbreviation" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geolookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Fonacier
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -29,14 +29,14 @@ dependencies:
|
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
@@ -102,17 +102,17 @@ require_paths:
|
|
102
102
|
- lib
|
103
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- -
|
105
|
+
- - '>='
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - '>='
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.0.3
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Common geo lookups
|