locationator 0.1.0 → 0.1.1

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
- NjBkZDI0Nzc2NTk2ZTgxNmU4MWIxNmY4MmFmYzljMmY4ODEwOGE2ZA==
4
+ ZTMzZjZmYmVmODA1ZmUxNjZkZTBlN2Y4ZTNlZmRhMGEzYjM2ZDNiMA==
5
5
  data.tar.gz: !binary |-
6
- ZGNiZTk2ODhiODVjZWU1OTRlNDE5YzFkMjU2MjJiY2U1N2MwNmNhNQ==
6
+ MmFlZjA4NzU2N2Y2NGQzYmI2Y2ViM2YyYjFiMjU3NmQ4ZGY3NDIzOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NThkYThiMDNmZDllMjViMGZjZTZmZDk4YjFmZDBkZDFmMDI2NzRiNzViZWM4
10
- ZDNiZDA3ZDdiNWRkNDk1NWVkMDQyYjVjZWE5ODA4OTFhNWVjOWVhNmU3MWVj
11
- ZjlhMWY5YzYzZDYyZjMxMjYyNDEwMTNkYmU2NTYwNGFhMDMzYTg=
9
+ Zjg2NWFmYjMwYmJjMGIzZjQxNTVmN2EzMmE3NDg1MjUzOTA1Yjg3ZGMwZDQw
10
+ ODY2MjBmOGU5NTg3N2RlOTRkZGE4YTA0NTlhMTNiY2FmMTNiNGE1NGRlODg2
11
+ ZTMxOWMzZjg3YThlNTYyNWU2YjQ5MmU2NjMwZGVjYzg5Zjg2NjM=
12
12
  data.tar.gz: !binary |-
13
- NDQyYzZhMzQ4NGJhNzNmMjg0YjVmNWRlNTlhMzgyZTk3Nzk2ZjZhNzIyYWRl
14
- ZTI4YzM2YTdiNTlmYjRhZWM4NjBmNmJlYmM1MzlkZGU0ZjEyZjdjY2NiZTYy
15
- OGMzNmM0NWExMTE2NTk2NDg0NDM3NWFiMDIxMjAzYmY2YTY1ZDI=
13
+ MWZkMWU4YTdlZDgxOWYyMTA2YmRjZDA2YjQzMDdhNTQ3MmMzOGZkNzc2YTNj
14
+ NGRjNjU2NTFiMWQ4M2E5MzZlZDg0ZjM5ZmY3M2M2OTYyMWRmYjU4MTAzOWU4
15
+ MGM0Nzk0MjUyZDViNTUzOWIxZTQ2OWRlOWU4NzkzMDk2Mjc5MDM=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locationator (0.1.0)
4
+ locationator (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -43,6 +43,10 @@ Return the properly formatted version of an address
43
43
  $ Locationator.format("800 W. Huron St Chicago, IL")
44
44
  => "800 West Huron Street, Chicago, IL 60642, USA"
45
45
 
46
+ ## TODOs
47
+ 1. Find a better way of locating the postal code in Google Maps' JSON response.
48
+ 2. Find a better way of validating the array generated by the lat_lng method.
49
+
46
50
  ## Contributing
47
51
 
48
52
  1. Fork it
data/lib/locationator.rb CHANGED
@@ -44,6 +44,26 @@ module Locationator
44
44
  result = geocodeResponse["status"] == "ZERO_RESULTS" ? "Address not found." : geocodeResponse["results"][0]["formatted_address"]
45
45
  end
46
46
 
47
+ # Returns the latitude based on the current user's IP address
48
+ def self.ip_lat
49
+ geocodeResponse = get_ip_data
50
+ result = geocodeResponse["latitude"]
51
+ end
52
+
53
+ # Returns the longitude based on the current user's IP address
54
+ def self.ip_lng
55
+ geocodeResponse = get_ip_data
56
+ result = geocodeResponse["longitude"]
57
+ end
58
+
59
+ # Returns an array of the latitude and longitude based on the current user's IP address
60
+ def self.ip_lat_lng
61
+ myArray = []
62
+ myArray.push(self.ip_lat)
63
+ myArray.push(self.ip_lng)
64
+ result = myArray
65
+ end
66
+
47
67
  private
48
68
 
49
69
  # Builds the URL that we need to get our JSON response from Google
@@ -56,4 +76,10 @@ module Locationator
56
76
  data = JSON.parse(response.body)
57
77
  end
58
78
 
79
+ def self.get_ip_data
80
+ geocodePrimary = "http://freegeoip.net/json/"
81
+ response = Net::HTTP.get_response(URI.parse(geocodePrimary))
82
+ data = JSON.parse(response.body)
83
+ end
84
+
59
85
  end
@@ -1,3 +1,3 @@
1
1
  module Locationator
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawrence Davis