google_maps_geocoder 0.1.1 → 0.2.0

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 CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{google_maps_geocoder}
8
- s.version = "0.1.1"
7
+ s.name = "google_maps_geocoder"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Roderick Monje}]
12
- s.date = %q{2011-09-06}
13
- s.description = %q{Geocode a location without worrying about parsing Google Maps' response. GoogleMapsGeocoder wraps it in a plain-old Ruby object.}
14
- s.email = %q{rod@seologic.com}
11
+ s.authors = ["Roderick Monje"]
12
+ s.date = "2012-09-19"
13
+ s.description = "Geocode a location without worrying about parsing Google Maps' response. GoogleMapsGeocoder wraps it in a plain-old Ruby object."
14
+ s.email = "rod@seologic.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -28,11 +28,11 @@ Gem::Specification.new do |s|
28
28
  "spec/lib/google_maps_geocoder_spec.rb",
29
29
  "spec/spec_helper.rb"
30
30
  ]
31
- s.homepage = %q{http://github.com/ivanoblomov/google_maps_geocoder}
32
- s.licenses = [%q{MIT}]
33
- s.require_paths = [%q{lib}]
34
- s.rubygems_version = %q{1.8.5}
35
- s.summary = %q{A simple PORO wrapper for geocoding with Google Maps.}
31
+ s.homepage = "http://github.com/ivanoblomov/google_maps_geocoder"
32
+ s.licenses = ["MIT"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = "1.8.11"
35
+ s.summary = "A simple PORO wrapper for geocoding with Google Maps."
36
36
 
37
37
  if s.respond_to? :specification_version then
38
38
  s.specification_version = 3
@@ -24,10 +24,15 @@ class GoogleMapsGeocoder
24
24
  # white_house = GoogleMapsGeocoder.new('1600 Pennsylvania Washington')
25
25
  # white_house.formatted_address
26
26
  # => "1600 Pennsylvania Ave NW, Washington D.C., DC 20500, USA"
27
- def initialize(address)
28
- response = Net::HTTP.get_response(URI.parse("http://maps.googleapis.com/maps/api/geocode/json?address=#{Rack::Utils.escape(address)}&sensor=false"))
29
- @json = ActiveSupport::JSON.decode(response.body)
30
- raise "Geocoding \"#{address}\" exceeded query limit! Google returned...\n#{@json.inspect}" if @json.blank? || @json['status'] != 'OK'
27
+ def initialize data
28
+ if data.is_a? String
29
+ response = Net::HTTP.get_response(URI.parse("http://maps.googleapis.com/maps/api/geocode/json?address=#{Rack::Utils.escape(data)}&sensor=false"))
30
+ @json = ActiveSupport::JSON.decode(response.body)
31
+ raise "Geocoding \"#{address}\" exceeded query limit! Google returned...\n#{@json.inspect}" if @json.blank? || @json['status'] != 'OK'
32
+ else
33
+ @json = data
34
+ address = data['formatted_address']
35
+ end
31
36
 
32
37
  logger = Logger.new(STDERR)
33
38
  logger.info('GoogleMapsGeocoder') { "Geocoded \"#{address}\" and Google returned...\n#{@json.inspect}" }
@@ -27,10 +27,10 @@ describe GoogleMapsGeocoder do
27
27
  specify { subject.county.should == 'Kings' }
28
28
  specify { subject.state_long_name.should == 'New York' }
29
29
  specify { subject.state_short_name.should == 'NY' }
30
- specify { subject.postal_code.should == '11215' }
30
+ specify { subject.postal_code.should =~ /1121[0-9]/ }
31
31
  specify { subject.country_short_name.should == 'US' }
32
32
  specify { subject.country_long_name.should == 'United States' }
33
- specify { subject.formatted_address.should == '837 Union St, Brooklyn, NY 11215, USA' }
33
+ specify { subject.formatted_address.should =~ /837 Union St, Brooklyn, NY 1121[0-9], USA/ }
34
34
  end
35
35
 
36
36
  context 'coordinates' do
@@ -48,10 +48,10 @@ describe GoogleMapsGeocoder do
48
48
  specify { subject.city.should == 'Washington' }
49
49
  specify { subject.state_long_name.should == 'District of Columbia' }
50
50
  specify { subject.state_short_name.should == 'DC' }
51
- specify { subject.postal_code.should == '20500' }
51
+ specify { subject.postal_code.should =~ /2050[0-9]/ }
52
52
  specify { subject.country_short_name.should == 'US' }
53
53
  specify { subject.country_long_name.should == 'United States' }
54
- specify { subject.formatted_address.should == '1600 Pennsylvania Ave NW, Washington, DC 20500, USA' }
54
+ specify { subject.formatted_address.should =~ /1600 Pennsylvania Ave NW, Washington, DC 2050[0-9], USA/ }
55
55
  end
56
56
 
57
57
  context 'coordinates' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_geocoder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roderick Monje
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-06 00:00:00 Z
18
+ date: 2012-09-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport
@@ -136,9 +136,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements: []
137
137
 
138
138
  rubyforge_project:
139
- rubygems_version: 1.8.5
139
+ rubygems_version: 1.8.11
140
140
  signing_key:
141
141
  specification_version: 3
142
142
  summary: A simple PORO wrapper for geocoding with Google Maps.
143
143
  test_files: []
144
144
 
145
+ has_rdoc: