locationator 0.0.4 → 0.0.6

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,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2M1NDIyMmNmOGY0N2IyZmU0NGJkMTQyNTA5MDBmYWRlYzIwNDZhNA==
4
+ ZmQwYTJjZGRiZTFjZWYxZjQyZTI4MmM4MjhkNjEyNTI4YjUwOTExNQ==
5
5
  data.tar.gz: !binary |-
6
- ZWNjZTdlNDdlZmU3Mzg3ZjJjZWIyOWUwM2M2YzI5MDVlZjU2NjBkNQ==
6
+ YzBlMDdjZTRjN2NkZTFkYmJhZWI0OWU1ZDBkMDg4Yjc0OTYzZGFlMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDU4MDU1ZDFjMTBjNzgyZjc4ZGY4MTkyNjIyZmRiNzg4NGFhMGUwMzk5OTlm
10
- ZWExMDRiNGU1ZGU3ZGQzOWYyMzJiOWMxMTg1N2NmNGYxNzE5ZDkwOTA5NmM1
11
- N2QzZDczOWUyOTI0MDNjZjVlNWQzMzdkN2E5Y2RkZGM1OTdhY2E=
9
+ Y2FjNGVjOWNiYWYwYTRhMzhiMGZmNGNjNDNkNWM5ZGQ4YTcxMGFiODZjODE0
10
+ NDA4NjlhNjc3YmJjM2FlM2MzNzVlODgzOGU3MmFlM2U1NWZhYTZkZDAzOTZl
11
+ NDMzNzQ4NTNmMDQ5ZWQ4MjMwMzVmM2U3NzQ1ZTkzOTU3NWZkMDQ=
12
12
  data.tar.gz: !binary |-
13
- MzQwYTE5NDc1NjI3MDhlMzkxNzcxOGZkMzAyZTk2NzljMGJhMzc4MDJmNzcx
14
- OTM4ODkxNmFkNTA3NmQ2MjRjZGY2NGMxNmJlNDAxYWIzMDg4M2E5ZTVjYThl
15
- MDA2ZmE2Zjc0OGIxOTc2ZTdkYjc1Zjg5NTgyNDBkMmMyNDFlNmQ=
13
+ NTJlMGNlZWNmZGRiYmZiZjY4MmU2NDk1MmNkOWNiODk0YjljZGJjMjRjYTA5
14
+ MjQyZTIwZWViZTdmNGRiMjY5YmRkZWRiZGNiNDcwNGY0MmVlYjZlYzNhNTU3
15
+ N2M0YTUxMGYwNWNkOTU0YWIzNjkxOGZkMmUxMmUxMWQ1YWNiNzI=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locationator (0.0.4)
4
+ locationator (0.0.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module Locationator
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/locationator.rb CHANGED
@@ -8,13 +8,21 @@ module Locationator
8
8
  # Returns the latitude
9
9
  def self.lat(address)
10
10
  geocodeResponse = get_data(address)
11
- lat = geocodeResponse["results"][0]["geometry"]["location"]["lat"]
11
+ if geocodeResponse["status"] == "ZERO_RESULTS"
12
+ lat = "Address not found."
13
+ else
14
+ lat = geocodeResponse["results"][0]["geometry"]["location"]["lat"]
15
+ end
12
16
  end
13
17
 
14
18
  # Returns the longitude
15
19
  def self.lng(address)
16
20
  geocodeResponse = get_data(address)
17
- lng = geocodeResponse["results"][0]["geometry"]["location"]["lng"]
21
+ if geocodeResponse["status"] == "ZERO_RESULTS"
22
+ lng = "Address not found."
23
+ else
24
+ lng = geocodeResponse["results"][0]["geometry"]["location"]["lng"]
25
+ end
18
26
  end
19
27
 
20
28
  # Builds an array of the latitude and longitude
@@ -22,21 +30,34 @@ module Locationator
22
30
  lat_lng_array = []
23
31
  lat_lng_array.push(self.lat(address))
24
32
  lat_lng_array.push(self.lng(address))
33
+ if lat_lng_array == ["Address not found.", "Address not found."]
34
+ lat_lng_array = "Address not found."
35
+ else
36
+ lat_lng_array
37
+ end
25
38
  end
26
39
 
27
40
  # Returns the zip code for an address
28
41
  def self.zip(address)
29
42
  geocodeResponse = get_data(address)
30
- components = geocodeResponse["results"][0]["address_components"]
31
- # The postal code is always the last address component returned
32
- # TODO: Find a cleaner method of finding the postal code in the JSON
33
- zip = components[components.length - 1]["long_name"]
43
+ if geocodeResponse["status"] == "ZERO_RESULTS"
44
+ zip = "Address not found."
45
+ else
46
+ components = geocodeResponse["results"][0]["address_components"]
47
+ # The postal code is always the last address component returned
48
+ # TODO: Find a cleaner method of finding the postal code in the JSON
49
+ zip = components[components.length - 1]["long_name"]
50
+ end
34
51
  end
35
52
 
36
53
  # Returns a properly formatted address
37
54
  def self.format(address)
38
55
  geocodeResponse = get_data(address)
39
- formatted = geocodeResponse["results"][0]["formatted_address"]
56
+ if geocodeResponse["status"] == "ZERO_RESULTS"
57
+ formatted = "Address not found."
58
+ else
59
+ formatted = geocodeResponse["results"][0]["formatted_address"]
60
+ end
40
61
  end
41
62
 
42
63
  private
data/locationator.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Locationator::VERSION
9
9
  spec.authors = ["Lawrence Davis"]
10
10
  spec.email = ["lawrence@lrdiv.com"]
11
- spec.description = %q{Get location information.}
11
+ spec.description = %q{Lightweight geocoding gem.}
12
12
  spec.summary = %q{Use Google's geocoding services to get information about any address.}
13
13
  spec.homepage = "https://github.com/lawrencedavis/locationator"
14
14
  spec.license = "MIT"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locationator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawrence Davis
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Get location information.
41
+ description: Lightweight geocoding gem.
42
42
  email:
43
43
  - lawrence@lrdiv.com
44
44
  executables: []