geolookup 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +3 -0
- data/lib/geolookup.rb +2 -5
- data/lib/geolookup/country.rb +6 -6
- data/lib/geolookup/usa/county.rb +6 -6
- data/lib/geolookup/usa/state.rb +5 -5
- data/lib/geolookup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjQ3MmMwYmZlNmJhYjM2ZjhmMWY1YjFjNTIzNmI1NTc1MjdhNjk4NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWM2MzYzOWNmOWQzMWMzMjZhZGI1OGZlY2YyYTcyMmJhMTRjNGI2Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzhiMTM1YzM5OWE2ZTY4ZTRiMzA0NmIwOTk4MzQ5Yjg0ODU4YmFiZjIxYzIx
|
10
|
+
YTc5MDUwMTIwOTNlMWNkMTY2NTdiOTRiYTgyODhjN2NmMzZmNjkwNzVkODIy
|
11
|
+
N2E3ZTM2NGFiMmY4MjNkNzVkYzAzNTI4ZjA4NzU3YmI2OWExM2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmZmMTQ4YWY4ZTIxNTczMjEyM2U0MGZjM2I1YmUzOWZkNzI2YmQ1OGRlOTM5
|
14
|
+
MTQ0NjYyZTk3M2I2ZWRlOTc0ZGYyZGMzZDc3MjY3ZDYwZWJkYjJiN2JkOTQ4
|
15
|
+
MmFmYjRiZmZjOTg4NTk1ODMzMjQwMzVjYTI4OWVkYTZkY2ViYTM=
|
data/CHANGELOG.rdoc
CHANGED
data/lib/geolookup.rb
CHANGED
@@ -9,10 +9,7 @@ module Geolookup
|
|
9
9
|
#
|
10
10
|
# Loads a given .yml file that contains a hash and returns the hash
|
11
11
|
#
|
12
|
-
def self.load_hash_from_file(
|
13
|
-
|
14
|
-
hash = YAML.load(fileName)
|
15
|
-
fileName.close
|
16
|
-
hash
|
12
|
+
def self.load_hash_from_file(file_name)
|
13
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "data/", file_name))
|
17
14
|
end
|
18
15
|
end
|
data/lib/geolookup/country.rb
CHANGED
@@ -10,16 +10,16 @@ require 'yaml'
|
|
10
10
|
module Geolookup
|
11
11
|
|
12
12
|
module Country
|
13
|
-
COUNTRY_NAME_TO_CODE_FILE = "
|
14
|
-
COUNTRY_CODE_TO_NAME_FILE = "
|
15
|
-
COUNTRY_LAT_LONG_FILE = "
|
13
|
+
COUNTRY_NAME_TO_CODE_FILE = "COUNTRY_NAME_TO_CODE.yml"
|
14
|
+
COUNTRY_CODE_TO_NAME_FILE = "COUNTRY_CODE_TO_NAME.yml"
|
15
|
+
COUNTRY_LAT_LONG_FILE = "COUNTRY_LAT_LONG.yml"
|
16
16
|
|
17
17
|
@country_name_to_code
|
18
18
|
@country_code_to_name
|
19
19
|
@country_lat_long
|
20
|
-
|
20
|
+
|
21
21
|
def self.name_to_code(country_name)
|
22
|
-
@country_name_to_code ||= Geolookup.load_hash_from_file(COUNTRY_NAME_TO_CODE_FILE)
|
22
|
+
@country_name_to_code ||= Geolookup.load_hash_from_file(COUNTRY_NAME_TO_CODE_FILE)
|
23
23
|
@country_name_to_code[country_name.to_s.upcase]
|
24
24
|
end
|
25
25
|
|
@@ -32,7 +32,7 @@ module Geolookup
|
|
32
32
|
# LAT_LONG[country_code.to_s.upcase]
|
33
33
|
#end
|
34
34
|
|
35
|
-
def self.name_to_lat_long(country_name)
|
35
|
+
def self.name_to_lat_long(country_name)
|
36
36
|
@country_lat_long ||= Geolookup.load_hash_from_file(COUNTRY_LAT_LONG_FILE)
|
37
37
|
@country_lat_long[country_name.to_s.upcase]
|
38
38
|
end
|
data/lib/geolookup/usa/county.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
module Geolookup
|
3
3
|
module USA
|
4
4
|
module County
|
5
|
-
COUNTY_CODE_TO_NAME_FILE = '
|
6
|
-
COUNTY_NAME_TO_CODE_FILE = '
|
7
|
-
COUNTY_LAT_LONG_FILE = '
|
5
|
+
COUNTY_CODE_TO_NAME_FILE = 'COUNTY_CODE_TO_NAME.yml'
|
6
|
+
COUNTY_NAME_TO_CODE_FILE = 'COUNTY_NAME_TO_CODE.yml'
|
7
|
+
COUNTY_LAT_LONG_FILE = 'COUNTY_LAT_LONG.yml'
|
8
8
|
|
9
9
|
@county_code_to_name
|
10
10
|
@county_name_to_code
|
11
11
|
@county_lat_long
|
12
|
-
|
12
|
+
|
13
13
|
###################################################################
|
14
14
|
# self.code_to_name
|
15
15
|
#
|
@@ -17,10 +17,10 @@ module Geolookup
|
|
17
17
|
# Else return nil
|
18
18
|
#
|
19
19
|
# EX: code_to_name(1, 1) => "AUTAUGA"
|
20
|
-
def self.code_to_name(state_code, county_code)
|
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
22
|
return nil unless @county_code_to_name[state_code.to_s.to_i]
|
23
|
-
|
23
|
+
|
24
24
|
@county_code_to_name[state_code.to_s.to_i][county_code.to_s.to_i]
|
25
25
|
end
|
26
26
|
|
data/lib/geolookup/usa/state.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
module Geolookup
|
3
3
|
module USA
|
4
4
|
module State
|
5
|
-
STATE_CODE_TO_FULL_FILE = '
|
6
|
-
STATE_CODE_TO_ABBREVIATION_FILE = '
|
7
|
-
STATE_NAME_TO_CODE_FILE = '
|
8
|
-
STATE_ABBREVIATION_TO_NAME_FILE = '
|
9
|
-
STATE_LAT_LONG_FILE = '
|
5
|
+
STATE_CODE_TO_FULL_FILE = 'STATE_CODE_TO_FULL.yml'
|
6
|
+
STATE_CODE_TO_ABBREVIATION_FILE = 'STATE_CODE_TO_STATE.yml'
|
7
|
+
STATE_NAME_TO_CODE_FILE = 'STATE_NAME_TO_CODE.yml'
|
8
|
+
STATE_ABBREVIATION_TO_NAME_FILE = 'STATE_FULL_STATE_NAMES.yml'
|
9
|
+
STATE_LAT_LONG_FILE = 'STATE_LAT_LONG.yml'
|
10
10
|
|
11
11
|
@state_code_to_full
|
12
12
|
@state_code_to_abbreviation
|
data/lib/geolookup/version.rb
CHANGED