geolookup 0.3.0
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +4 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +6 -0
- data/geolookup.gemspec +24 -0
- data/lib/geolookup.rb +8 -0
- data/lib/geolookup/country.rb +814 -0
- data/lib/geolookup/fips.rb +10508 -0
- data/lib/geolookup/version.rb +3 -0
- data/spec/lib/country_spec.rb +15 -0
- data/spec/lib/fips_spec.rb +53 -0
- data/spec/spec_helper.rb +2 -0
- metadata +107 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
describe "Geolookup::Country" do
|
2
|
+
describe "#name_to_code" do
|
3
|
+
it "returns a country name if country code matches" do
|
4
|
+
expect(Geolookup::Country.code_to_name("AL")).to eql("Albania")
|
5
|
+
end
|
6
|
+
|
7
|
+
it "returns a country code if country name matches" do
|
8
|
+
expect(Geolookup::Country.name_to_code("Hong Kong")).to eql("HK")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns a lat/long array if country name matches" do
|
12
|
+
expect(Geolookup::Country.lat_long("United States")).to eql([38000000, -97000000])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
describe "Geolookup::FIPS" do
|
2
|
+
describe "#code_to_full_name" do
|
3
|
+
it "should return a state name if state code matches" do
|
4
|
+
expect(Geolookup::FIPS.code_to_full_name(1)).to eql("Alabama")
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should return nil if code doesn't match" do
|
8
|
+
expect(Geolookup::FIPS.code_to_full_name(-1)).to be_nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#code_to_state_abbreviation" do
|
13
|
+
it 'should return a state abbreviation gien a state code' do
|
14
|
+
expect(Geolookup::FIPS.code_to_state_abbreviation(1)).to eql("AL")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return nil if code doesn't match" do
|
18
|
+
expect(Geolookup::FIPS.code_to_state_abbreviation(-1)).to be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#state_name_to_code" do
|
23
|
+
it "given a state abbrev return the state code" do
|
24
|
+
expect(Geolookup::FIPS.state_name_to_code('ca')).to eql(6)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "given a state name return the state code" do
|
28
|
+
expect(Geolookup::FIPS.state_name_to_code('california')).to eql(6)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "given a non state name return nil" do
|
32
|
+
expect(Geolookup::FIPS.state_name_to_code('foo')).to be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should gracefully handle nil input" do
|
36
|
+
expect(Geolookup::FIPS.state_name_to_code(nil)).to be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#state_abbreviation_to_full_name" do
|
41
|
+
it "given a state abbrev return the state name" do
|
42
|
+
expect(Geolookup::FIPS.state_abbreviation_to_full_name("CA")).to eql("California")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should gracefully handle nil input" do
|
46
|
+
expect(Geolookup::FIPS.state_abbreviation_to_full_name(nil)).to be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "given a non state abbrev, return nil" do
|
50
|
+
expect(Geolookup::FIPS.state_abbreviation_to_full_name("CAD")).to be_nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geolookup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Austin Fonacier
|
8
|
+
- David Butler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.5'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.5'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 3.0.0.beta1
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 3.0.0.beta1
|
56
|
+
description: Common geo lookups
|
57
|
+
email:
|
58
|
+
- austin@spokeo.com
|
59
|
+
- dwbutler@ucla.edu
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- geolookup.gemspec
|
72
|
+
- lib/geolookup.rb
|
73
|
+
- lib/geolookup/country.rb
|
74
|
+
- lib/geolookup/fips.rb
|
75
|
+
- lib/geolookup/version.rb
|
76
|
+
- spec/lib/country_spec.rb
|
77
|
+
- spec/lib/fips_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
homepage: https://github.com/spokeo/geolookup
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.2.1
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Common geo lookups
|
103
|
+
test_files:
|
104
|
+
- spec/lib/country_spec.rb
|
105
|
+
- spec/lib/fips_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
has_rdoc:
|