google_geocoding 0.2.0 → 0.2.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.
- data/VERSION +1 -1
- data/google_geocoding.gemspec +4 -4
- data/lib/google_geocoding/result.rb +8 -2
- data/spec/classes/request_spec.rb +1 -1
- data/spec/classes/result_spec.rb +14 -0
- metadata +17 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/google_geocoding.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{google_geocoding}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rodrigo Kochenburger"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-08}
|
13
13
|
s.description = %q{GoogleGeocoding is a small library for performing geocoding using the Google's HTTP geocoding API}
|
14
14
|
s.email = %q{divoxx@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
|
|
41
41
|
s.homepage = %q{http://github.com/divoxx/google_geocoding}
|
42
42
|
s.rdoc_options = ["--charset=UTF-8"]
|
43
43
|
s.require_paths = ["lib"]
|
44
|
-
s.rubygems_version = %q{1.3.
|
44
|
+
s.rubygems_version = %q{1.3.7}
|
45
45
|
s.summary = %q{Google's geocoding library}
|
46
46
|
s.test_files = [
|
47
47
|
"spec/classes/request_spec.rb",
|
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
|
|
55
55
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
56
|
s.specification_version = 3
|
57
57
|
|
58
|
-
if Gem::Version.new(Gem::
|
58
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
59
|
s.add_runtime_dependency(%q<json>, [">= 1.2.0"])
|
60
60
|
s.add_runtime_dependency(%q<patron>, [">= 0.4.5"])
|
61
61
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
@@ -6,11 +6,17 @@ module GoogleGeocoding
|
|
6
6
|
|
7
7
|
def initialize(args = {})
|
8
8
|
process_args(args)
|
9
|
-
@components = []
|
9
|
+
@components = Hash.new { |h,k| h[k] = [] }
|
10
10
|
end
|
11
11
|
|
12
12
|
def <<(component)
|
13
|
-
|
13
|
+
component.types.each do |type|
|
14
|
+
@components[type.to_sym] << component
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(type)
|
19
|
+
@components[type.to_sym]
|
14
20
|
end
|
15
21
|
|
16
22
|
def each(&block)
|
@@ -20,7 +20,7 @@ describe Request do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should return the query string" do
|
23
|
-
@request.query_string.should == "address
|
23
|
+
CGI.parse(@request.query_string).should == {"address" => ["2 Townsend St, San Francisco, CA"], "sensor" => ["false"]}
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/spec/classes/result_spec.rb
CHANGED
@@ -16,6 +16,20 @@ describe Result do
|
|
16
16
|
result.precision.should == :rooftop
|
17
17
|
end
|
18
18
|
|
19
|
+
it "should index address components by type" do
|
20
|
+
result = Result.new(
|
21
|
+
:types => ["street_address"],
|
22
|
+
:address => "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
|
23
|
+
:coordinates => [37.4219720, -122.0841430],
|
24
|
+
:precision => "ROOFTOP"
|
25
|
+
)
|
26
|
+
result << num = AddressComponent.new(:long_name => "1600", :short_name => "1600", :types => ["street_number"])
|
27
|
+
result << route = AddressComponent.new(:long_name => "Amphitheatre Pkwy", :short_name => "Amphitheatre Pkwy", :types => ["route"])
|
28
|
+
result << city = AddressComponent.new(:long_name => "Mountain View", :short_name => "Mountain View", :types => ["political", "locality"])
|
29
|
+
result << state = AddressComponent.new(:long_name => "California", :short_name => "CA", :types => ["political", "administrative_area_level_1"])
|
30
|
+
result.get(:political).should == [city, state]
|
31
|
+
end
|
32
|
+
|
19
33
|
%w(types address coordinates precision).each do |missing_attr|
|
20
34
|
it "should raise an error when #{missing_attr} is missing" do
|
21
35
|
attrs = {
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_geocoding
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Rodrigo Kochenburger
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-09-08 00:00:00 -03:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: json
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 31
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 2
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: patron
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 5
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
- 4
|
@@ -49,9 +54,11 @@ dependencies:
|
|
49
54
|
name: rspec
|
50
55
|
prerelease: false
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - ">="
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 13
|
55
62
|
segments:
|
56
63
|
- 1
|
57
64
|
- 2
|
@@ -63,9 +70,11 @@ dependencies:
|
|
63
70
|
name: yard
|
64
71
|
prerelease: false
|
65
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - ">="
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 13
|
69
78
|
segments:
|
70
79
|
- 0
|
71
80
|
- 5
|
@@ -113,23 +122,27 @@ rdoc_options:
|
|
113
122
|
require_paths:
|
114
123
|
- lib
|
115
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
116
126
|
requirements:
|
117
127
|
- - ">="
|
118
128
|
- !ruby/object:Gem::Version
|
129
|
+
hash: 3
|
119
130
|
segments:
|
120
131
|
- 0
|
121
132
|
version: "0"
|
122
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
123
135
|
requirements:
|
124
136
|
- - ">="
|
125
137
|
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
126
139
|
segments:
|
127
140
|
- 0
|
128
141
|
version: "0"
|
129
142
|
requirements: []
|
130
143
|
|
131
144
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.3.
|
145
|
+
rubygems_version: 1.3.7
|
133
146
|
signing_key:
|
134
147
|
specification_version: 3
|
135
148
|
summary: Google's geocoding library
|