geolookup 0.5.0 → 0.5.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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MjIxNGIxYjI0Yzc0M2IxYmU2ZjJmM2EwNjczZDhkYjFhYjQ1MDMzMQ==
5
- data.tar.gz: !binary |-
6
- ZWMzM2M0NWU3M2ZiZGYzNmYwNmVkM2M2ZDJhZjM4ZmVkZWRiNzQ5YQ==
2
+ SHA1:
3
+ metadata.gz: 691d2b670b1c6d09b1845bd327b4be42dd88b65f
4
+ data.tar.gz: 87885cde8f1eb5925e8b623f21e89ac357fceb76
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NGI0ZDFhMzE3NzQ3MDI1Y2ZlZGU2NWVlMTNmYWI2YjE3Y2U0N2E2NjJhMmMz
10
- YTQ1MDQ2MTBhZmEzZTc2NTRkNjkxNjA1MDQ1NDEyNDIzMzAzNTkwNWU1YWJh
11
- YWRmYmY0YmQ0YmEyNmZmNmEwODlmYWE3NjRhMTYwYjI5NWI3NzY=
12
- data.tar.gz: !binary |-
13
- NTdiYzRmM2E5MDQ5MWJiNDdjMDQ5MDhjM2E4MGMxNTVkNjQyNWVkMWVlYzRj
14
- MzY2ZDUwODdjNjAxNTM2ZmUyM2FhY2QyNjNmY2NlMzk1MzVkYTMwMTg4YzVk
15
- NjY4YWU1NzMwZGFkNWMyZDczNzA5YmI3ZTFmMThkOTY2NjkxZTI=
6
+ metadata.gz: d38fd668d0751eb8a3ed093f6f62d364d001336cb1ff16bae982f4ac503931c9c2358597b9eeb27f0114953afefb068bde5c87c49f284ea614a8a0cfec8f08a1
7
+ data.tar.gz: 806a5a53586bceb7667c89e269344b9f79a63f158424109e8e79920c0116bd7e7ab5a2055629d6c3bffbfa6020e922e2e65be83fb0c356934519aea40599c27b
@@ -1,3 +1,6 @@
1
+ === 0.5.1
2
+ - Adding a function on state to go from state name to abbreviation #name_to_abbreviation
3
+
1
4
  === 0.5.0
2
5
  - Fixing the specs
3
6
  - API changes for country and county
@@ -9,7 +9,7 @@ module Geolookup
9
9
  # Given a state and county code output the county name
10
10
  # Else return nil
11
11
  #
12
- # EX: code_to_name(1, 1) => {1 => {1 => "AUTAUGA", 3 => "BALDWIN", ....}}
12
+ # EX: code_to_name(1, 1) => "AUTAUGA"
13
13
  def self.code_to_name(state_code, county_code)
14
14
  return nil unless CODE_TO_COUNTY_NAME[state_code.to_s.to_i]
15
15
 
@@ -20,6 +20,16 @@ module Geolookup
20
20
  CODE_TO_STATE[state_code.to_s.to_i]
21
21
  end
22
22
 
23
+ ###################################################################
24
+ # self.name_to_abbreviation
25
+ #
26
+ # Given a state name OR abbreviation return a code. It takes both an abbreviation and
27
+ # a state full name
28
+ #
29
+ def self.name_to_abbreviation(state_abbrev)
30
+ code_to_name(abbreviation_to_code(state_abbrev))
31
+ end
32
+
23
33
  ###################################################################
24
34
  # self.state_name_to_code
25
35
  #
@@ -1,3 +1,3 @@
1
1
  module Geolookup
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -11,6 +11,16 @@ describe "Geolookup::USA::State" do
11
11
  end
12
12
  end
13
13
 
14
+ describe "#name_to_abbreviation" do
15
+ it "should return name to state abbreviation" do
16
+ expect(Geolookup::USA::State.name_to_abbreviation('CA')).to eql("California")
17
+ end
18
+
19
+ it "should return nil if no state abbreviation" do
20
+ expect(Geolookup::USA::State.name_to_abbreviation('asdf')).to be_nil
21
+ end
22
+ end
23
+
14
24
  describe "#code_to_abbreviation" do
15
25
  it 'should return a state abbreviation gien a state code' do
16
26
  expect(Geolookup::USA::State.code_to_abbreviation(1)).to eql("AL")
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.0
4
+ version: 0.5.1
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-02-04 00:00:00.000000000 Z
12
+ date: 2014-02-06 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
@@ -89,17 +89,17 @@ require_paths:
89
89
  - lib
90
90
  required_ruby_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ! '>='
92
+ - - '>='
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ! '>='
97
+ - - '>='
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.2.1
102
+ rubygems_version: 2.0.3
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Common geo lookups