locationator 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/lib/locationator/version.rb +1 -1
- data/lib/locationator.rb +28 -7
- data/locationator.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmQwYTJjZGRiZTFjZWYxZjQyZTI4MmM4MjhkNjEyNTI4YjUwOTExNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzBlMDdjZTRjN2NkZTFkYmJhZWI0OWU1ZDBkMDg4Yjc0OTYzZGFlMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2FjNGVjOWNiYWYwYTRhMzhiMGZmNGNjNDNkNWM5ZGQ4YTcxMGFiODZjODE0
|
10
|
+
NDA4NjlhNjc3YmJjM2FlM2MzNzVlODgzOGU3MmFlM2U1NWZhYTZkZDAzOTZl
|
11
|
+
NDMzNzQ4NTNmMDQ5ZWQ4MjMwMzVmM2U3NzQ1ZTkzOTU3NWZkMDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTJlMGNlZWNmZGRiYmZiZjY4MmU2NDk1MmNkOWNiODk0YjljZGJjMjRjYTA5
|
14
|
+
MjQyZTIwZWViZTdmNGRiMjY5YmRkZWRiZGNiNDcwNGY0MmVlYjZlYzNhNTU3
|
15
|
+
N2M0YTUxMGYwNWNkOTU0YWIzNjkxOGZkMmUxMmUxMWQ1YWNiNzI=
|
data/Gemfile.lock
CHANGED
data/lib/locationator/version.rb
CHANGED
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
|
-
|
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
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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{
|
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
|
+
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:
|
41
|
+
description: Lightweight geocoding gem.
|
42
42
|
email:
|
43
43
|
- lawrence@lrdiv.com
|
44
44
|
executables: []
|