locationator 0.0.3 → 0.0.4

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
- ODU4NTAyYjIzMmY5MDIxMmFiYWY3MDBjZGJiOWQwMTMyYmYyYjRmNQ==
4
+ Y2M1NDIyMmNmOGY0N2IyZmU0NGJkMTQyNTA5MDBmYWRlYzIwNDZhNA==
5
5
  data.tar.gz: !binary |-
6
- NzE0NGQ0ZjhmNzE0ZTEyYWQyNDA4YmQ2ZWE1ZjFhMDZhZTljODI4MA==
6
+ ZWNjZTdlNDdlZmU3Mzg3ZjJjZWIyOWUwM2M2YzI5MDVlZjU2NjBkNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NGU1ODBlODVmOGRlNTYyNzAxYWY3YWQyYmJjMjNhZjU2MmYwYTI2ZmM1Yjcy
10
- NzhhNTMxYjgxMGI2ODgwMGFiYzU1ZWQ3NDk4MWRlM2QxNDM2ZGM1MGI3ZmZk
11
- ZDg5MjUxM2RhMTZhODMyZmNhZWY1NDE3MzlmMWE1YjYxMGIwNDc=
9
+ MDU4MDU1ZDFjMTBjNzgyZjc4ZGY4MTkyNjIyZmRiNzg4NGFhMGUwMzk5OTlm
10
+ ZWExMDRiNGU1ZGU3ZGQzOWYyMzJiOWMxMTg1N2NmNGYxNzE5ZDkwOTA5NmM1
11
+ N2QzZDczOWUyOTI0MDNjZjVlNWQzMzdkN2E5Y2RkZGM1OTdhY2E=
12
12
  data.tar.gz: !binary |-
13
- YTYxOTBkNDEyMDc4OGVkMzlmYWQ2Mzk3MWEwYzEzNmUxNTk1YjhkMjZlODdj
14
- NDU4NjYyOGRiOTg3NTNlMTA3MWVhZDM0YWE3NGE5MDNkNGUyYjdkNGQwMGFj
15
- MmM3OTI3OTU2MDk0YjIxNzM3NDAwZjAwNDM1YjU1OTBjNTBjOTk=
13
+ MzQwYTE5NDc1NjI3MDhlMzkxNzcxOGZkMzAyZTk2NzljMGJhMzc4MDJmNzcx
14
+ OTM4ODkxNmFkNTA3NmQ2MjRjZGY2NGMxNmJlNDAxYWIzMDg4M2E5ZTVjYThl
15
+ MDA2ZmE2Zjc0OGIxOTc2ZTdkYjc1Zjg5NTgyNDBkMmMyNDFlNmQ=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locationator (0.0.3)
4
+ locationator (0.0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- A lightweight geocoder gem that returns an array of the latitude and longitude for an address.
1
+ A lightweight geocoder gem that uses Google Maps' geocoder service to return basic information about an address including latitude, longitude, zip code, and formatted Address
2
2
 
3
3
  ## Installation
4
4
 
@@ -16,19 +16,32 @@ Or install it yourself as:
16
16
 
17
17
  ## Usage
18
18
 
19
- There are 3 methods in this gem:
19
+ There are 5 methods in this gem:
20
20
 
21
- Location.lat("800 W. Huron St Chicago, IL")
21
+ Return the latitude of an address:
22
22
 
23
- will return the latitude.
23
+ $ Locationator.lat("800 W. Huron St Chicago, IL")
24
+ => 41.895347
24
25
 
25
- Location.lng("800 W. Huron St Chicago, IL")
26
+ Return the longitude of an address:
26
27
 
27
- will return the longitude
28
+ $ Locationator.lng("800 W. Huron St Chicago, IL")
29
+ => -87.648072
28
30
 
29
- Location.lat_lng("800 W. Huron St Chicago, IL")
31
+ Return an array of the latitude and longitude of an address:
30
32
 
31
- will return an array of the latitude and longitude.
33
+ $ Locationator.lat_lng("800 W. Huron St Chicago, IL")
34
+ => [41.895347, -87.648072]
35
+
36
+ Return the postal (zip) code of an address:
37
+
38
+ $ Locationator.zip("800 W. Huron St Chicago, IL")
39
+ => "60642"
40
+
41
+ Return the properly formatted version of an address
42
+
43
+ $ Locationator.zip("800 W. Huron St Chicago, IL")
44
+ => "800 West Huron Street, Chicago, IL 60642, USA"
32
45
 
33
46
  ## Contributing
34
47
 
@@ -36,4 +49,4 @@ will return an array of the latitude and longitude.
36
49
  2. Create your feature branch (`git checkout -b my-new-feature`)
37
50
  3. Commit your changes (`git commit -am 'Add some feature'`)
38
51
  4. Push to the branch (`git push origin my-new-feature`)
39
- 5. Create new Pull Request
52
+ 5. Create new Pull Request
@@ -1,3 +1,3 @@
1
1
  module Locationator
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/locationator.rb CHANGED
@@ -7,15 +7,13 @@ module Locationator
7
7
 
8
8
  # Returns the latitude
9
9
  def self.lat(address)
10
- geocodeURL = get_url(address)
11
- geocodeResponse = get_data(geocodeURL)
10
+ geocodeResponse = get_data(address)
12
11
  lat = geocodeResponse["results"][0]["geometry"]["location"]["lat"]
13
12
  end
14
13
 
15
14
  # Returns the longitude
16
15
  def self.lng(address)
17
- geocodeURL = get_url(address)
18
- geocodeResponse = get_data(geocodeURL)
16
+ geocodeResponse = get_data(address)
19
17
  lng = geocodeResponse["results"][0]["geometry"]["location"]["lng"]
20
18
  end
21
19
 
@@ -28,8 +26,7 @@ module Locationator
28
26
 
29
27
  # Returns the zip code for an address
30
28
  def self.zip(address)
31
- geocodeURL = get_url(address)
32
- geocodeResponse = get_data(geocodeURL)
29
+ geocodeResponse = get_data(address)
33
30
  components = geocodeResponse["results"][0]["address_components"]
34
31
  # The postal code is always the last address component returned
35
32
  # TODO: Find a cleaner method of finding the postal code in the JSON
@@ -38,24 +35,19 @@ module Locationator
38
35
 
39
36
  # Returns a properly formatted address
40
37
  def self.format(address)
41
- geocodeURL = get_url(address)
42
- geocodeResponse = get_data(geocodeURL)
38
+ geocodeResponse = get_data(address)
43
39
  formatted = geocodeResponse["results"][0]["formatted_address"]
44
40
  end
45
41
 
46
42
  private
47
43
 
48
44
  # Builds the URL that we need to get our JSON response from Google
49
- def self.get_url(address)
45
+ def self.get_data(address)
50
46
  geocodePrimary = "http://maps.googleapis.com/maps/api/geocode/json?address="
51
47
  geocodeAddress = URI::encode(address)
52
48
  geocodeSensor = "&sensor=false"
53
49
  geocodeURL = geocodePrimary + geocodeAddress + geocodeSensor
54
- end
55
-
56
- # Sends the URL to Google and parses the response
57
- def self.get_data(url)
58
- response = Net::HTTP.get_response(URI.parse(url))
50
+ response = Net::HTTP.get_response(URI.parse(geocodeURL))
59
51
  data = JSON.parse(response.body)
60
52
  end
61
53
 
data/locationator.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["lawrence@lrdiv.com"]
11
11
  spec.description = %q{Get location information.}
12
12
  spec.summary = %q{Use Google's geocoding services to get information about any address.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/lawrencedavis/locationator"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawrence Davis
@@ -54,7 +54,7 @@ files:
54
54
  - lib/locationator.rb
55
55
  - lib/locationator/version.rb
56
56
  - locationator.gemspec
57
- homepage: ''
57
+ homepage: https://github.com/lawrencedavis/locationator
58
58
  licenses:
59
59
  - MIT
60
60
  metadata: {}