google_maps 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +20 -0
- data/README.md +28 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/geocode.gemspec +65 -0
- data/google_maps.gemspec +66 -0
- data/lib/google_maps.rb +4 -0
- data/lib/google_maps/geocoder.rb +36 -0
- data/lib/google_maps/geocoder/location.rb +31 -0
- data/lib/google_maps/geocoder/result.rb +33 -0
- data/test/google_maps/geocoder_test.rb +70 -0
- data/test/test_helper.rb +28 -0
- metadata +153 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'rest-client'
|
4
|
+
gem 'activesupport'
|
5
|
+
# Add dependencies required to use your gem here.
|
6
|
+
# Example:
|
7
|
+
# gem "activesupport", ">= 2.3.5"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "bundler", "~> 1.0.0"
|
13
|
+
gem "jeweler", "~> 1.8.3"
|
14
|
+
gem 'mocha'
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.2)
|
5
|
+
i18n (~> 0.6)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
git (1.2.5)
|
8
|
+
i18n (0.6.0)
|
9
|
+
jeweler (1.8.3)
|
10
|
+
bundler (~> 1.0)
|
11
|
+
git (>= 1.2.5)
|
12
|
+
rake
|
13
|
+
rdoc
|
14
|
+
json (1.7.1)
|
15
|
+
metaclass (0.0.1)
|
16
|
+
mime-types (1.18)
|
17
|
+
mocha (0.10.0)
|
18
|
+
metaclass (~> 0.0.1)
|
19
|
+
multi_json (1.3.4)
|
20
|
+
rake (0.9.2.2)
|
21
|
+
rdoc (3.12)
|
22
|
+
json (~> 1.4)
|
23
|
+
rest-client (1.6.7)
|
24
|
+
mime-types (>= 1.16)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
activesupport
|
31
|
+
bundler (~> 1.0.0)
|
32
|
+
jeweler (~> 1.8.3)
|
33
|
+
mocha
|
34
|
+
rest-client
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 AppFolio, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# geocode
|
2
|
+
|
3
|
+
Geocode addresses using Google's Geocode v3 API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Using bundler
|
8
|
+
gem 'geocode'
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
result = Geocode::Google.locate! "50 Castilian Drive"
|
13
|
+
|
14
|
+
|
15
|
+
## Contributing to geocode
|
16
|
+
|
17
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
18
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
19
|
+
* Fork the project.
|
20
|
+
* Start a feature/bugfix branch.
|
21
|
+
* Commit and push until you are happy with your contribution.
|
22
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
23
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2012 AppFolio, Inc. See LICENSE.txt for further details.
|
28
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "google_maps"
|
18
|
+
gem.homepage = "http://github.com/appfolio/geocode"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Gem to interact with Google Maps v3 API}
|
21
|
+
gem.description = %Q{General Purpose Library to interact with Google Maps v3 api. Geocoder. }
|
22
|
+
gem.email = "tusharranka@gmail.com"
|
23
|
+
gem.authors = ["Tushar Ranka"]
|
24
|
+
end
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/*_test.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :test
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/geocode.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "geocode"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tushar Ranka"]
|
12
|
+
s.date = "2012-05-11"
|
13
|
+
s.description = "Geocode addresses using google geocode v3 API"
|
14
|
+
s.email = "tusharranka@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"geocode.gemspec",
|
28
|
+
"lib/geocode.rb",
|
29
|
+
"lib/geocode/google.rb",
|
30
|
+
"lib/geocode/location.rb",
|
31
|
+
"lib/geocode/result.rb",
|
32
|
+
"test/geocode/google_test.rb",
|
33
|
+
"test/test_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = "http://github.com/appfolio/geocode"
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = "1.8.12"
|
39
|
+
s.summary = "Geocode addresses using google geocode v3 API"
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
49
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
52
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
53
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
55
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
59
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
60
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
61
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
62
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/google_maps.gemspec
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "google_maps"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tushar Ranka"]
|
12
|
+
s.date = "2012-05-11"
|
13
|
+
s.description = "General Purpose Library to interact with Google Maps v3 api. Geocoder. "
|
14
|
+
s.email = "tusharranka@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"geocode.gemspec",
|
28
|
+
"google_maps.gemspec",
|
29
|
+
"lib/google_maps.rb",
|
30
|
+
"lib/google_maps/geocoder.rb",
|
31
|
+
"lib/google_maps/geocoder/location.rb",
|
32
|
+
"lib/google_maps/geocoder/result.rb",
|
33
|
+
"test/google_maps/geocoder_test.rb",
|
34
|
+
"test/test_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = "http://github.com/appfolio/geocode"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = "1.8.12"
|
40
|
+
s.summary = "Gem to interact with Google Maps v3 API"
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
50
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
53
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
54
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
55
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
56
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
60
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
61
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
63
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
data/lib/google_maps.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'google_maps/geocoder/result'
|
2
|
+
require 'google_maps/geocoder/location'
|
3
|
+
|
4
|
+
module GoogleMaps
|
5
|
+
module Geocoder
|
6
|
+
|
7
|
+
URI_BASE = "maps.googleapis.com/maps/api/geocode/json"
|
8
|
+
|
9
|
+
def self.locate!(address, options = { })
|
10
|
+
options = {
|
11
|
+
:ssl => false,
|
12
|
+
:address => address,
|
13
|
+
:sensor => false
|
14
|
+
}.merge(options)
|
15
|
+
|
16
|
+
json = ActiveSupport::JSON.decode RestClient.get(url(options))
|
17
|
+
|
18
|
+
Geocoder::Result.new(json)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.url(options)
|
22
|
+
ssl = options.delete(:ssl)
|
23
|
+
parameters = []
|
24
|
+
options.each do |key, value|
|
25
|
+
parameters << "#{key}=#{CGI.escape(value.to_s)}"
|
26
|
+
end
|
27
|
+
"#{uri_base_path(:ssl => ssl)}?#{parameters.join('&')}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.uri_base_path(options = { })
|
31
|
+
protocol = options[:ssl] ? "https" : "http"
|
32
|
+
"#{protocol}://#{URI_BASE}"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GoogleMaps
|
2
|
+
module Geocoder
|
3
|
+
class Location
|
4
|
+
|
5
|
+
LOCATION_TYPES = [ "ROOFTOP", "RANGE_INTERPOLATED", "GEOMETRIC_CENTER", "APPROXIMATE"]
|
6
|
+
ACCURATE_TYPES = [ "street_address", "premise", "subpremise" ]
|
7
|
+
|
8
|
+
attr_accessor :formatted_address, :location_type, :latitude, :longitude, :types
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
self.formatted_address = json['formatted_address']
|
12
|
+
if geometry_json = json['geometry']
|
13
|
+
self.location_type = ActiveSupport::StringInquirer.new(geometry_json['location_type'].downcase)
|
14
|
+
|
15
|
+
if geometry_json['location']
|
16
|
+
self.latitude = BigDecimal(geometry_json['location']['lat'].to_s)
|
17
|
+
self.longitude = BigDecimal(geometry_json['location']['lng'].to_s)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
self.types = json['types']
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def street_address?
|
26
|
+
(ACCURATE_TYPES & self.types).present?
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module GoogleMaps
|
2
|
+
module Geocoder
|
3
|
+
class Result
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
attr_accessor :status
|
7
|
+
|
8
|
+
STATUS_CODES = [ "OK", "ZERO_RESULTS", "OVER_QUERY_LIMIT", "REQUEST_DENIED", "INVALID_REQUEST" ]
|
9
|
+
|
10
|
+
def initialize(json = {})
|
11
|
+
self.status = ActiveSupport::StringInquirer.new(json['status'].downcase)
|
12
|
+
@locations = (json['results'] || []).map { |result| Location.new(result) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def all
|
16
|
+
@locations
|
17
|
+
end
|
18
|
+
|
19
|
+
def each(&block)
|
20
|
+
all.each &block
|
21
|
+
end
|
22
|
+
|
23
|
+
def [](index)
|
24
|
+
all[index]
|
25
|
+
end
|
26
|
+
|
27
|
+
def last
|
28
|
+
all.last
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'mocha'
|
3
|
+
|
4
|
+
class GoogleMaps::GeocoderTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_locate__castilian
|
7
|
+
RestClient.expects(:get).with(expected_url("address=50+Castilian+Drive%2C+Goleta%2C+CA&sensor=false")).returns(castilian_json)
|
8
|
+
result = GoogleMaps::Geocoder.locate!("50 Castilian Drive, Goleta, CA")
|
9
|
+
|
10
|
+
assert result.status.ok?
|
11
|
+
|
12
|
+
assert_equal 1, result.count
|
13
|
+
location = result.first
|
14
|
+
assert_equal "50 Castilian Dr, Goleta, CA 93117, USA", location.formatted_address
|
15
|
+
assert_equal BigDecimal.new("34.4344759"), location.latitude
|
16
|
+
assert_equal BigDecimal.new("-119.863908"), location.longitude
|
17
|
+
assert location.street_address?
|
18
|
+
assert location.location_type.rooftop?
|
19
|
+
assert_equal ['street_address'], location.types
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_locate__new_york
|
23
|
+
RestClient.expects(:get).with(expected_url("address=New+York&sensor=false")).returns(new_york_json)
|
24
|
+
result = GoogleMaps::Geocoder.locate!("New York")
|
25
|
+
assert result.status.ok?
|
26
|
+
|
27
|
+
assert_equal 2, result.count
|
28
|
+
|
29
|
+
ny_ny = result.first
|
30
|
+
assert_equal "New York, NY, USA", ny_ny.formatted_address
|
31
|
+
assert_equal BigDecimal.new("40.7143528"), ny_ny.latitude
|
32
|
+
assert_equal BigDecimal.new("-74.0059731"), ny_ny.longitude
|
33
|
+
assert !ny_ny.street_address?
|
34
|
+
assert ny_ny.location_type.approximate?
|
35
|
+
assert_equal ["locality", "political"], ny_ny.types
|
36
|
+
|
37
|
+
manhattan_ny = result.last
|
38
|
+
assert_equal "Manhattan, New York, NY, USA", manhattan_ny.formatted_address
|
39
|
+
assert_equal BigDecimal.new("40.7834345"), manhattan_ny.latitude
|
40
|
+
assert_equal BigDecimal.new("-73.9662495"), manhattan_ny.longitude
|
41
|
+
assert !manhattan_ny.street_address?
|
42
|
+
assert !manhattan_ny.location_type.rooftop?
|
43
|
+
assert manhattan_ny.location_type.approximate?
|
44
|
+
assert_equal ["sublocality", "political"], manhattan_ny.types
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_url_base_path
|
49
|
+
assert_equal "http://#{GoogleMaps::Geocoder::URI_BASE}", GoogleMaps::Geocoder.uri_base_path
|
50
|
+
assert_equal "http://#{GoogleMaps::Geocoder::URI_BASE}", GoogleMaps::Geocoder.uri_base_path(:ssl => false)
|
51
|
+
assert_equal "https://#{GoogleMaps::Geocoder::URI_BASE}", GoogleMaps::Geocoder.uri_base_path(:ssl => true)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_url
|
55
|
+
assert_equal expected_url("address=50+Castilian+Drive%2C+Goleta%2C+CA&sensor=true"), GoogleMaps::Geocoder.url(ordered_hash(:sensor => true, :ssl => false, :address => "50 Castilian Drive, Goleta, CA"))
|
56
|
+
assert_equal expected_url("address=50+Castilian+Drive%2C+Goleta%2C+CA&sensor=false", true), GoogleMaps::Geocoder.url(ordered_hash(:sensor => false, :ssl => true, :address => "50 Castilian Drive, Goleta, CA"))
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def expected_url(parameters, ssl = false)
|
62
|
+
"http#{'s' if ssl}://#{GoogleMaps::Geocoder::URI_BASE}?#{parameters}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def ordered_hash(hash)
|
66
|
+
oh = ActiveSupport::OrderedHash.new
|
67
|
+
oh.merge!(hash)
|
68
|
+
oh
|
69
|
+
end
|
70
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'active_support/all'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
require 'test/unit'
|
14
|
+
|
15
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
16
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
17
|
+
require 'google_maps'
|
18
|
+
|
19
|
+
class Test::Unit::TestCase
|
20
|
+
def castilian_json
|
21
|
+
"{\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"50\",\n \"short_name\" : \"50\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Castilian Dr\",\n \"short_name\" : \"Castilian Dr\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Goleta\",\n \"short_name\" : \"Goleta\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Santa Barbara\",\n \"short_name\" : \"Santa Barbara\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"California\",\n \"short_name\" : \"CA\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"United States\",\n \"short_name\" : \"US\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"93117\",\n \"short_name\" : \"93117\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"50 Castilian Dr, Goleta, CA 93117, USA\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 34.43447590,\n \"lng\" : -119.8639080\n },\n \"location_type\" : \"ROOFTOP\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 34.43582488029149,\n \"lng\" : -119.8625590197085\n },\n \"southwest\" : {\n \"lat\" : 34.43312691970849,\n \"lng\" : -119.8652569802915\n }\n }\n },\n \"types\" : [ \"street_address\" ]\n }\n ],\n \"status\" : \"OK\"\n}\n"
|
22
|
+
end
|
23
|
+
|
24
|
+
def new_york_json
|
25
|
+
"{\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"New York\",\n \"short_name\" : \"New York\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"New York\",\n \"short_name\" : \"New York\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"New York\",\n \"short_name\" : \"NY\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"United States\",\n \"short_name\" : \"US\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"formatted_address\" : \"New York, NY, USA\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 40.91524130,\n \"lng\" : -73.7002720\n },\n \"southwest\" : {\n \"lat\" : 40.4959080,\n \"lng\" : -74.25908790\n }\n },\n \"location\" : {\n \"lat\" : 40.71435280,\n \"lng\" : -74.00597309999999\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 40.84953420,\n \"lng\" : -73.74985430\n },\n \"southwest\" : {\n \"lat\" : 40.57889640,\n \"lng\" : -74.26209190\n }\n }\n },\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"Manhattan\",\n \"short_name\" : \"Manhattan\",\n \"types\" : [ \"sublocality\", \"political\" ]\n },\n {\n \"long_name\" : \"New York\",\n \"short_name\" : \"New York\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"New York\",\n \"short_name\" : \"New York\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"New York\",\n \"short_name\" : \"NY\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"United States\",\n \"short_name\" : \"US\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"formatted_address\" : \"Manhattan, New York, NY, USA\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 40.8822140,\n \"lng\" : -73.9070\n },\n \"southwest\" : {\n \"lat\" : 40.67954790,\n \"lng\" : -74.0472850\n }\n },\n \"location\" : {\n \"lat\" : 40.78343450,\n \"lng\" : -73.96624950\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 40.8200450,\n \"lng\" : -73.90331300000001\n },\n \"southwest\" : {\n \"lat\" : 40.6980780,\n \"lng\" : -74.03514899999999\n }\n }\n },\n \"types\" : [ \"sublocality\", \"political\" ]\n }\n ],\n \"status\" : \"OK\"\n}\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google_maps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Tushar Ranka
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-05-11 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
type: :runtime
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
version_requirements: *id001
|
32
|
+
name: rest-client
|
33
|
+
prerelease: false
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
type: :runtime
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 3
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
version_requirements: *id002
|
46
|
+
name: activesupport
|
47
|
+
prerelease: false
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
type: :development
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 23
|
56
|
+
segments:
|
57
|
+
- 1
|
58
|
+
- 0
|
59
|
+
- 0
|
60
|
+
version: 1.0.0
|
61
|
+
version_requirements: *id003
|
62
|
+
name: bundler
|
63
|
+
prerelease: false
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
type: :development
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 49
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 8
|
75
|
+
- 3
|
76
|
+
version: 1.8.3
|
77
|
+
version_requirements: *id004
|
78
|
+
name: jeweler
|
79
|
+
prerelease: false
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
type: :development
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
version_requirements: *id005
|
92
|
+
name: mocha
|
93
|
+
prerelease: false
|
94
|
+
description: "General Purpose Library to interact with Google Maps v3 api. Geocoder. "
|
95
|
+
email: tusharranka@gmail.com
|
96
|
+
executables: []
|
97
|
+
|
98
|
+
extensions: []
|
99
|
+
|
100
|
+
extra_rdoc_files:
|
101
|
+
- LICENSE.txt
|
102
|
+
- README.md
|
103
|
+
files:
|
104
|
+
- .document
|
105
|
+
- Gemfile
|
106
|
+
- Gemfile.lock
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- VERSION
|
111
|
+
- geocode.gemspec
|
112
|
+
- google_maps.gemspec
|
113
|
+
- lib/google_maps.rb
|
114
|
+
- lib/google_maps/geocoder.rb
|
115
|
+
- lib/google_maps/geocoder/location.rb
|
116
|
+
- lib/google_maps/geocoder/result.rb
|
117
|
+
- test/google_maps/geocoder_test.rb
|
118
|
+
- test/test_helper.rb
|
119
|
+
homepage: http://github.com/appfolio/geocode
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 3
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
version: "0"
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
145
|
+
requirements: []
|
146
|
+
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 1.8.12
|
149
|
+
signing_key:
|
150
|
+
specification_version: 3
|
151
|
+
summary: Gem to interact with Google Maps v3 API
|
152
|
+
test_files: []
|
153
|
+
|