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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2YwNTRkYzNiNGY3NTEzMGNmNzIyNjVmNmFkMWI4ZWY4MjkzN2I2OQ==
4
+ YjQ3MmMwYmZlNmJhYjM2ZjhmMWY1YjFjNTIzNmI1NTc1MjdhNjk4NQ==
5
5
  data.tar.gz: !binary |-
6
- MTU3ZWU4YmE3NzY3YzBkZTlmZTg3ZjgwMGU0MDhmZWRjZmNjZWI1ZA==
6
+ OWM2MzYzOWNmOWQzMWMzMjZhZGI1OGZlY2YyYTcyMmJhMTRjNGI2Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzMwNTNkYjFlOWE0OTMyOGMzNDRmNDEzYTNjZmIwMzVmODhjZWZhYWVlMWEy
10
- ZjMyMjY0OTcyNTIzOTFkOTlmODQ0MjZjMTQ2ZGY2MTMwZTVhODE0MmE0OTZh
11
- ZWMyZGQzNTE2Mzg0OGY4YTcxMTBlOGVmMjllNmY5MDQxNGEwZjY=
9
+ NzhiMTM1YzM5OWE2ZTY4ZTRiMzA0NmIwOTk4MzQ5Yjg0ODU4YmFiZjIxYzIx
10
+ YTc5MDUwMTIwOTNlMWNkMTY2NTdiOTRiYTgyODhjN2NmMzZmNjkwNzVkODIy
11
+ N2E3ZTM2NGFiMmY4MjNkNzVkYzAzNTI4ZjA4NzU3YmI2OWExM2E=
12
12
  data.tar.gz: !binary |-
13
- M2NiMTY1NWJiNTZhZGU3M2NlNjczOWVlODAxMDMzYmE0YjA5YTlhZjRkMTgz
14
- NzQ5ZmU0YWE2NTVhNDlmYTlhM2Q5NTg5MjdmZGZlMzdmNjI2MmNkZDY1YjFk
15
- YWU4NzIwOTY4M2ZjZTI3NGNiOTk3YTk1M2ViMmUyOGJkYjNkNDk=
13
+ NmZmMTQ4YWY4ZTIxNTczMjEyM2U0MGZjM2I1YmUzOWZkNzI2YmQ1OGRlOTM5
14
+ MTQ0NjYyZTk3M2I2ZWRlOTc0ZGYyZGMzZDc3MjY3ZDYwZWJkYjJiN2JkOTQ4
15
+ MmFmYjRiZmZjOTg4NTk1ODMzMjQwMzVjYTI4OWVkYTZkY2ViYTM=
@@ -1,3 +1,6 @@
1
+ === 0.5.5
2
+ - Fixes to the data from files
3
+
1
4
  === 0.5.4
2
5
  - Loading data from files thanks @ekuecks!
3
6
 
@@ -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(file)
13
- fileName = File.open(file, "r")
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
@@ -10,16 +10,16 @@ require 'yaml'
10
10
  module Geolookup
11
11
 
12
12
  module Country
13
- COUNTRY_NAME_TO_CODE_FILE = "./lib/data/COUNTRY_NAME_TO_CODE.yml"
14
- COUNTRY_CODE_TO_NAME_FILE = "./lib/data/COUNTRY_CODE_TO_NAME.yml"
15
- COUNTRY_LAT_LONG_FILE = "./lib/data/COUNTRY_LAT_LONG.yml"
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
@@ -2,14 +2,14 @@
2
2
  module Geolookup
3
3
  module USA
4
4
  module County
5
- COUNTY_CODE_TO_NAME_FILE = './lib/data/COUNTY_CODE_TO_NAME.yml'
6
- COUNTY_NAME_TO_CODE_FILE = './lib/data/COUNTY_NAME_TO_CODE.yml'
7
- COUNTY_LAT_LONG_FILE = './lib/data/COUNTY_LAT_LONG.yml'
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
 
@@ -2,11 +2,11 @@
2
2
  module Geolookup
3
3
  module USA
4
4
  module State
5
- STATE_CODE_TO_FULL_FILE = './lib/data/STATE_CODE_TO_FULL.yml'
6
- STATE_CODE_TO_ABBREVIATION_FILE = './lib/data/STATE_CODE_TO_STATE.yml'
7
- STATE_NAME_TO_CODE_FILE = './lib/data/STATE_NAME_TO_CODE.yml'
8
- STATE_ABBREVIATION_TO_NAME_FILE = './lib/data/STATE_FULL_STATE_NAMES.yml'
9
- STATE_LAT_LONG_FILE = './lib/data/STATE_LAT_LONG.yml'
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
@@ -1,3 +1,3 @@
1
1
  module Geolookup
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
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
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Fonacier