sixarm_ruby_geocode_address 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/LICENSE.txt +12 -0
- data/README.rdoc +11 -0
- data/lib/sixarm_ruby_geocode_address.rb +69 -0
- metadata +86 -0
- metadata.gz.sig +1 -0
data.tar.gz.sig
ADDED
Binary file
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
You may choose any of these licenses:
|
4
|
+
|
5
|
+
- CreativeCommons License, Non-commercial Share Alike
|
6
|
+
- LGPL, GNU Lesser General Public License
|
7
|
+
- MIT License
|
8
|
+
- Ruby License
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
11
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
12
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
= SixArm Ruby Gem
|
3
|
+
|
4
|
+
Author:: Joel Parker Henderson, joel@joelparkerhenderson.com
|
5
|
+
Copyright:: Copyright (c) 2010-2011 Joel Parker Henderson
|
6
|
+
License:: CreativeCommons License, Non-commercial Share Alike
|
7
|
+
License:: LGPL, GNU Lesser General Public License
|
8
|
+
License:: MIT License
|
9
|
+
License:: Ruby License
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
=begin rdoc
|
3
|
+
|
4
|
+
= SixArm Ruby Gem » GeocodeAddress
|
5
|
+
|
6
|
+
Author:: Joel Parker Henderson, joel@sixarm.com
|
7
|
+
Copyright:: Copyright (c) 2011 Joel Parker Henderson
|
8
|
+
License:: Your choice of BSD, MIT, LGPL, or CreativeCommons Non-commercial Share Alike
|
9
|
+
|
10
|
+
GeocodeAddress uses the Google Maps API to geocode an address string to a JSON result.
|
11
|
+
|
12
|
+
This caches the result of the Google Maps API.
|
13
|
+
|
14
|
+
Requires:
|
15
|
+
cgi
|
16
|
+
net/http
|
17
|
+
json
|
18
|
+
|
19
|
+
@example
|
20
|
+
address = GeocodeAddress.new("1 Main St, San Francisco, CA 94111")
|
21
|
+
address.href => "http://maps.googleapis.com/maps/api/geocode/json?address=1+Main+St,San+Francisco,+CA+94111&sensor=false"
|
22
|
+
address.get => ...calls the Google Maps API via Net::HTTP and returns a JSON-formatted string of results
|
23
|
+
address.json => ...calls the Google Maps API via Net::HTTP and returns a JSON parse of results
|
24
|
+
address.location => {"lat" => 37.7931108, "lng" => -122.3964898}
|
25
|
+
address.lat => 37.7931108
|
26
|
+
address.lng => -122.3964898
|
27
|
+
|
28
|
+
=end
|
29
|
+
|
30
|
+
require 'cgi'
|
31
|
+
require 'net/http'
|
32
|
+
require 'json'
|
33
|
+
|
34
|
+
|
35
|
+
class GeocodeAddress
|
36
|
+
|
37
|
+
def initialize(s)
|
38
|
+
@s=s
|
39
|
+
end
|
40
|
+
|
41
|
+
def href
|
42
|
+
@href ||= 'http://maps.googleapis.com/maps/api/geocode/json?address=' + CGI.escape(@s) + '&sensor=false'
|
43
|
+
end
|
44
|
+
|
45
|
+
def uri
|
46
|
+
@uri ||= URI.parse(href)
|
47
|
+
end
|
48
|
+
|
49
|
+
def get
|
50
|
+
@get ||= Net::HTTP.get uri
|
51
|
+
end
|
52
|
+
|
53
|
+
def json
|
54
|
+
@json ||= JSON.parse(get)
|
55
|
+
end
|
56
|
+
|
57
|
+
def location
|
58
|
+
@location ||= json['results'][0]['geometry']['location']
|
59
|
+
end
|
60
|
+
|
61
|
+
def lat
|
62
|
+
location['lat']
|
63
|
+
end
|
64
|
+
|
65
|
+
def lng
|
66
|
+
location['lng']
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sixarm_ruby_geocode_address
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- SixArm
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain:
|
16
|
+
- |
|
17
|
+
-----BEGIN CERTIFICATE-----
|
18
|
+
MIIDBDCCAm2gAwIBAgIJAKPwEETU5bHoMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
|
19
|
+
BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNp
|
20
|
+
c2NvMQ8wDQYDVQQKEwZTaXhBcm0xEzARBgNVBAMTCnNpeGFybS5jb20wHhcNMTAx
|
21
|
+
MjEzMjMyNzEzWhcNMTMwOTA4MjMyNzEzWjBgMQswCQYDVQQGEwJVUzETMBEGA1UE
|
22
|
+
CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEPMA0GA1UEChMG
|
23
|
+
U2l4QXJtMRMwEQYDVQQDEwpzaXhhcm0uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GN
|
24
|
+
ADCBiQKBgQC94mD9JDwBsunsOI0VR3CXXbOWg9cWaWciwFyJNFiM7A9I8KPLfXUw
|
25
|
+
QC4czUe5ZuG4WHvinrWhkrCK+1dWBqoEClxdF/FoKO5a+tonGCjjmfy81JmFjjyx
|
26
|
+
eTsjsHyvw+Qik9kpf9aj6+pnkNrVswgNHVea2o9yabbEiS6VSeJWoQIDAQABo4HF
|
27
|
+
MIHCMB0GA1UdDgQWBBQzPJtqmSgc53eDN7aSzDQwr9TALDCBkgYDVR0jBIGKMIGH
|
28
|
+
gBQzPJtqmSgc53eDN7aSzDQwr9TALKFkpGIwYDELMAkGA1UEBhMCVVMxEzARBgNV
|
29
|
+
BAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xDzANBgNVBAoT
|
30
|
+
BlNpeEFybTETMBEGA1UEAxMKc2l4YXJtLmNvbYIJAKPwEETU5bHoMAwGA1UdEwQF
|
31
|
+
MAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAooEexP/oPam1TP71SyuhxMb+uTrZbSQe
|
32
|
+
jVB+ExRwWadGwaNPUA56d39qwavwP+iu+3JpeonNMVvbWXF5naCX/dNFIeREHzER
|
33
|
+
ZDRQYMqru9TEMna6HD9zpcstF7vwThGovlOQ+3Y6plQ4nMzipXcZ9THqs65PIL0q
|
34
|
+
eabwpCbAopo=
|
35
|
+
-----END CERTIFICATE-----
|
36
|
+
|
37
|
+
date: 2011-01-24 00:00:00 -08:00
|
38
|
+
default_executable:
|
39
|
+
dependencies: []
|
40
|
+
|
41
|
+
description:
|
42
|
+
email: sixarm@sixarm.com
|
43
|
+
executables: []
|
44
|
+
|
45
|
+
extensions: []
|
46
|
+
|
47
|
+
extra_rdoc_files: []
|
48
|
+
|
49
|
+
files:
|
50
|
+
- README.rdoc
|
51
|
+
- LICENSE.txt
|
52
|
+
- lib/sixarm_ruby_geocode_address.rb
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://sixarm.com
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: "SixArm Ruby Gem: sixarm_ruby_geocode_address"
|
85
|
+
test_files: []
|
86
|
+
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
6�����X��xW��B�
|