sinatra_ip_to_street_address 0.0.2 → 0.0.3
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 +4 -4
- data/lib/sinatra_ip_to_street_address.rb +11 -12
- data/lib/sinatra_ip_to_street_address/version.rb +1 -1
- metadata +3 -8
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -44
- data/sinatra_ip_to_street_address.gemspec +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ca578e7f8c03e9f430a9502e2f4f502dbdcf46fc
|
|
4
|
+
data.tar.gz: b84f57d8c6a9ec705071d2fba5555d10fd118154
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86be1d1ca61827715b5192858efddcb24dc32cb0fdaad4a5eee8dafbddaaf681a57104e221eec862b7096fea2af8e89812feb25124d3c147af835434a28f492f
|
|
7
|
+
data.tar.gz: e0d342d88aee59986547d779061c22238a6453032cf36e9d30b726097c0c15236a078a0c8502e43a052c0e4e57daf2f350b999a1e45026c4bb4516dc1823a08a
|
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
require "sinatra_ip_to_street_address/0.0.1"
|
|
2
|
-
|
|
3
1
|
require 'open-uri'
|
|
4
2
|
require 'uri'
|
|
5
3
|
require 'net/http'
|
|
4
|
+
require 'json'
|
|
6
5
|
|
|
7
6
|
module SinatraIpToStreetAddress
|
|
8
|
-
def get_ip
|
|
9
|
-
return request.ip
|
|
10
|
-
|
|
7
|
+
def self.get_ip
|
|
8
|
+
# return request.ip
|
|
9
|
+
return "74.122.9.196"
|
|
11
10
|
end
|
|
12
11
|
|
|
13
|
-
def create_freegeoip_query(ip)
|
|
12
|
+
def self.create_freegeoip_query(ip)
|
|
14
13
|
query = 'http://freegeoip.net/json/' + ip
|
|
15
14
|
query
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
def get_freegeoip_json(query)
|
|
17
|
+
def self.get_freegeoip_json(query)
|
|
19
18
|
response = Net::HTTP.get_response(URI.parse(query))
|
|
20
19
|
parsed_response = JSON.parse(response.body)
|
|
21
20
|
parsed_response
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
def get_longitude_latitude_array(parsed_response)
|
|
23
|
+
def self.get_longitude_latitude_array(parsed_response)
|
|
25
24
|
longitude = parsed_response['longitude'].to_s
|
|
26
25
|
latitude = parsed_response['latitude'].to_s
|
|
27
26
|
|
|
28
27
|
return [longitude, latitude]
|
|
29
28
|
end
|
|
30
29
|
|
|
31
|
-
def create_gmaps_query(long_lat_array)
|
|
30
|
+
def self.create_gmaps_query(long_lat_array)
|
|
32
31
|
query = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' + long_lat_array[1].to_s + "," + long_lat_array[0].to_s + '&sensor=true'
|
|
33
32
|
query
|
|
34
33
|
end
|
|
35
34
|
|
|
36
|
-
def get_gmaps_results(query)
|
|
35
|
+
def self.get_gmaps_results(query)
|
|
37
36
|
google_parsed_results = open(query) do |file|
|
|
38
37
|
JSON.parse(file.read)
|
|
39
38
|
end
|
|
40
39
|
google_parsed_results
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
def get_address(gmap_results)
|
|
42
|
+
def self.get_address(gmap_results)
|
|
44
43
|
return gmap_results['results'][0]['formatted_address']
|
|
45
44
|
end
|
|
46
45
|
|
|
47
|
-
def get_closest_address_by_ip
|
|
46
|
+
def self.get_closest_address_by_ip
|
|
48
47
|
ip_address = get_ip
|
|
49
48
|
|
|
50
49
|
free_geo_ip_query = create_freegeoip_query(ip_address)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sinatra_ip_to_street_address
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Junting Lu
|
|
@@ -59,14 +59,9 @@ executables: []
|
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
-
- ".gitignore"
|
|
63
|
-
- Gemfile
|
|
64
|
-
- LICENSE.txt
|
|
65
|
-
- README.md
|
|
66
|
-
- Rakefile
|
|
67
|
-
- lib/sinatra_ip_to_street_address.rb
|
|
68
62
|
- lib/sinatra_ip_to_street_address/version.rb
|
|
69
|
-
- sinatra_ip_to_street_address.
|
|
63
|
+
- lib/sinatra_ip_to_street_address.rb
|
|
64
|
+
- Rakefile
|
|
70
65
|
homepage: https://github.com/gnitnuj/sinatra_ip_to_street_address
|
|
71
66
|
licenses:
|
|
72
67
|
- MIT
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2014 JuLu
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# SinatraIpToStreetAddress
|
|
2
|
-
|
|
3
|
-
This gem was built to get the user's closest street address based on their ip.
|
|
4
|
-
|
|
5
|
-
It is my first gem, and will serve as my initial testing grounds for gem creation.
|
|
6
|
-
|
|
7
|
-
As of 03/05 I am working on writing a full RSpec test suite.
|
|
8
|
-
|
|
9
|
-
Here is a <a href='https://rubygems.org/gems/sinatra_ip_to_street_address'>link</a> to the RubyGems.org gem page.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
Add this line to your application's Gemfile:
|
|
14
|
-
|
|
15
|
-
gem 'sinatra_ip_to_street_address'
|
|
16
|
-
|
|
17
|
-
And then execute:
|
|
18
|
-
|
|
19
|
-
$ bundle
|
|
20
|
-
|
|
21
|
-
Or install it yourself as:
|
|
22
|
-
|
|
23
|
-
$ gem install sinatra_ip_to_street_address
|
|
24
|
-
|
|
25
|
-
## Gem Dependencies
|
|
26
|
-
|
|
27
|
-
json
|
|
28
|
-
open-uri
|
|
29
|
-
uri
|
|
30
|
-
net/http
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
Follow the installation instructions, then call the following method.
|
|
35
|
-
|
|
36
|
-
The method will return a string in the format for US addresses: "Street Address, City, State Zip-Code, Country"
|
|
37
|
-
|
|
38
|
-
## Contributing
|
|
39
|
-
|
|
40
|
-
1. Fork it ( http://github.com/<my-github-username>/sinatra_ip_to_street_address/fork )
|
|
41
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
42
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
43
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
44
|
-
5. Create new Pull Request
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'sinatra_ip_to_street_address/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = "sinatra_ip_to_street_address"
|
|
8
|
-
spec.version = SinatraIpToStreetAddress::VERSION
|
|
9
|
-
spec.authors = ["Junting Lu"]
|
|
10
|
-
spec.email = ["junting.lu@gmail.com"]
|
|
11
|
-
spec.summary = 'IP to Street Address for Sinatra'
|
|
12
|
-
spec.description = 'IP to Street Address for Sinatra using free geoip and gmaps'
|
|
13
|
-
spec.homepage = "https://github.com/gnitnuj/sinatra_ip_to_street_address"
|
|
14
|
-
spec.license = "MIT"
|
|
15
|
-
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
-
spec.require_paths = ["lib"]
|
|
20
|
-
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.5"
|
|
22
|
-
spec.add_development_dependency "rake"
|
|
23
|
-
|
|
24
|
-
spec.add_runtime_dependency 'json'
|
|
25
|
-
|
|
26
|
-
end
|