map_monkey 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/map_monkey.rb +23 -44
- metadata +7 -9
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjVlYTJjOGI1NzhmMDFlZGFhYTRiNzQ5MDU5OGQ1Y2ZkZTg5ZmJjNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDdlY2EwOTc3NjVhYjIyYmYyM2NmZDRiOGY3MTRlZGU1NGMwMTQ3NA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NGNhMmZjODMzOTIzYWU1MDVhZGZjNDAzZGU4OWJlYzM3ODU2MzQ3OTNjNzA2
|
10
|
+
Y2Y0MGIzZjNjMzczMGFkMjAyMzk0NjAxMWFhYThlY2ZhZWFkOTlkODA2MzI2
|
11
|
+
YjY3ODU4MTRlMmRmMjIwNjhjM2UzMTlkMmRhZWU3NzJiNmI4MGU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGRhYWEzMWM5YzliODEwYWY4NmZkYTIyYjYxNmJmNWU1OTExYjRhOTE3MDcz
|
14
|
+
MTZhMjdkMjU4ZGU1NzM2ODZjNmMxMTMzYmI1MjczZmIyMzEzN2E5OGY4MzUw
|
15
|
+
OWZmM2M3NmViNGExY2I3NmI3ZGE1NmUzMTkzOTA0NjI0ZjkxNTA=
|
data/lib/map_monkey.rb
CHANGED
@@ -2,71 +2,50 @@ require 'net/http'
|
|
2
2
|
require 'rexml/document'
|
3
3
|
|
4
4
|
class Position
|
5
|
-
def lat(strCity, strStreet, strZip)
|
6
5
|
|
7
|
-
|
8
|
-
city = URI.encode(strCity)
|
9
|
-
street = URI.encode(strStreet)
|
10
|
-
zip = URI.encode(strZip)
|
6
|
+
attr_accessor :city, :street, :zip
|
11
7
|
|
12
|
-
|
13
|
-
|
8
|
+
def city(city)
|
9
|
+
self.city
|
10
|
+
end
|
14
11
|
|
15
|
-
|
12
|
+
def street(street)
|
13
|
+
self.street
|
14
|
+
end
|
15
|
+
|
16
|
+
def zip(zip)
|
17
|
+
self.zip
|
18
|
+
end
|
16
19
|
|
17
|
-
|
20
|
+
def lat
|
21
|
+
url = "http://maps.googleapis.com/maps/api/geocode/xml?address="+self.street+self.zip+self.city+"&sensor=false"
|
22
|
+
xml_data = Net::HTTP.get_response(URI.parse(url)).body
|
18
23
|
doc = REXML::Document.new(xml_data)
|
19
|
-
|
20
|
-
lat = ""
|
21
24
|
|
22
25
|
doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
|
23
|
-
lat = ele.text
|
26
|
+
self.lat = ele.text
|
24
27
|
end
|
25
28
|
|
26
|
-
|
29
|
+
lat
|
27
30
|
end
|
28
31
|
|
29
|
-
def lng
|
30
|
-
|
31
|
-
# Clean up the string
|
32
|
-
city = URI.encode(strCity)
|
33
|
-
street = URI.encode(strStreet)
|
34
|
-
zip = URI.encode(strZip)
|
35
|
-
|
36
|
-
# URL setup
|
37
|
-
url = "http://maps.googleapis.com/maps/api/geocode/xml?address=#{ street }#{ zip }#{ city }&sensor=false"
|
38
|
-
|
32
|
+
def lng
|
33
|
+
url = "http://maps.googleapis.com/maps/api/geocode/xml?address="+self.street+self.zip+self.city+"&sensor=false"
|
39
34
|
xml_data = Net::HTTP.get_response(URI.parse(url)).body
|
40
|
-
|
41
|
-
# xml-response
|
42
35
|
doc = REXML::Document.new(xml_data)
|
43
36
|
|
44
|
-
lng = ""
|
45
|
-
|
46
37
|
doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
|
47
38
|
lng = ele.text
|
48
39
|
end
|
49
40
|
|
50
|
-
|
41
|
+
lng
|
51
42
|
end
|
52
43
|
|
53
|
-
def lat_lng
|
54
|
-
|
55
|
-
city = URI.encode(strCity)
|
56
|
-
street = URI.encode(strStreet)
|
57
|
-
zip = URI.encode(strZip)
|
58
|
-
|
59
|
-
# URL setup
|
60
|
-
url = "http://maps.googleapis.com/maps/api/geocode/xml?address=#{ street }#{ zip }#{ city }&sensor=false"
|
61
|
-
|
44
|
+
def lat_lng
|
45
|
+
url = "http://maps.googleapis.com/maps/api/geocode/xml?address="+self.street+self.zip+self.city+"&sensor=false"
|
62
46
|
xml_data = Net::HTTP.get_response(URI.parse(url)).body
|
63
|
-
|
64
|
-
# xml-response
|
65
47
|
doc = REXML::Document.new(xml_data)
|
66
48
|
|
67
|
-
lat = ""
|
68
|
-
lng = ""
|
69
|
-
|
70
49
|
doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
|
71
50
|
lat = ele.text
|
72
51
|
end
|
@@ -77,6 +56,6 @@ class Position
|
|
77
56
|
|
78
57
|
lat_lng = [lat, lng]
|
79
58
|
|
80
|
-
|
59
|
+
lat_lng
|
81
60
|
end
|
82
|
-
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: map_monkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Eric Khoury
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
13
|
+
description: Reutrn Google Maps coordinates.
|
15
14
|
email:
|
16
15
|
- ericintheloft@gmail.com
|
17
16
|
executables: []
|
@@ -21,26 +20,25 @@ files:
|
|
21
20
|
- lib/map_monkey.rb
|
22
21
|
homepage: https://github.com/eric-khoury/map_monkey
|
23
22
|
licenses: []
|
23
|
+
metadata: {}
|
24
24
|
post_install_message:
|
25
25
|
rdoc_options: []
|
26
26
|
require_paths:
|
27
27
|
- lib
|
28
28
|
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
-
none: false
|
30
29
|
requirements:
|
31
30
|
- - ! '>='
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: '0'
|
34
33
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
34
|
requirements:
|
37
35
|
- - ! '>='
|
38
36
|
- !ruby/object:Gem::Version
|
39
37
|
version: '0'
|
40
38
|
requirements: []
|
41
39
|
rubyforge_project:
|
42
|
-
rubygems_version:
|
40
|
+
rubygems_version: 2.0.2
|
43
41
|
signing_key:
|
44
|
-
specification_version:
|
45
|
-
summary: Google maps
|
42
|
+
specification_version: 4
|
43
|
+
summary: Google maps API helper.
|
46
44
|
test_files: []
|