google_places 0.0.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/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
6
+ .rspec
7
+ spec/api_key.rb
8
+ .yardoc/
9
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in google_places.gemspec
4
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,55 @@
1
+ = Google Places
2
+
3
+ This gem provides a Ruby wrapper around the Google Places API, using HTTParty. At this moment the gem does
4
+ not support OAuth authentication and will only work with an API key.
5
+
6
+
7
+ == Obtaining an API key
8
+
9
+ To be able to use this gem, you'll need a Google Places API key. To request an API key, point your browser to
10
+ https://code.google.com/apis/console and follow the instructions there. You'll find your API key on the
11
+ *API Access* tab under *Simple API Access*.
12
+
13
+
14
+ == Installing the gem
15
+
16
+ To use this gem, install it with <tt>gem install google_places</tt> or add it to your Gemfile:
17
+
18
+ gem 'google_places'
19
+
20
+ And install it with <tt>bundle install</tt>
21
+
22
+
23
+ == Usage
24
+
25
+ === The spot
26
+
27
+ Each of the API methods below returns a <tt>GooglePlaces::Spot</tt> or a collection of those. Each of these
28
+ objects has these attributes:
29
+
30
+ * *reference*: a token to query the Google Places API for more details about the spot
31
+ * *vicinity*: the street or neighborhood of the spot
32
+ * *lat*: the latitude of the spot
33
+ * *lng*: the longitude of the spot
34
+ * *name*: the name of the spot
35
+ * *icon*: a URL to the icon of this spot
36
+
37
+ === Retrieving a list of spots
38
+
39
+ First register a new Client:
40
+
41
+ @client = GooglePlaces::Client.new(API_KEY)
42
+
43
+ Then retrieve a list of spots:
44
+
45
+ @client.spots(-33.8670522, 151.1957362)
46
+
47
+ === Retrieving a single spot
48
+
49
+ First register a new Client:
50
+
51
+ @client = GooglePlaces::Client.new(API_KEY)
52
+
53
+ Then retrieve the spot:
54
+
55
+ @client.spot('CmRYAAA...upoTH3g')
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "google_places"
6
+ s.version = '0.0.1'
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Marcel de Graaf"]
9
+ s.email = ["mail@marceldegraaf.net"]
10
+ s.homepage = "http://marceldegraaf.net"
11
+ s.summary = %q{A Ruby wrapper around the Google Places API.}
12
+ s.description = %q{This gem provides a Ruby wrapper around the Google Places API for use in your own project. Please note that this gem does not provide OAuth authentication.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency 'httparty'
20
+ s.add_development_dependency 'rspec'
21
+ s.add_development_dependency 'fakeweb'
22
+ s.add_development_dependency 'vcr'
23
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+
5
+ %w(client location request spot).each do |file|
6
+ require File.join(File.dirname(__FILE__), 'google_places', file)
7
+ end
@@ -0,0 +1,17 @@
1
+ module GooglePlaces
2
+ class Client
3
+ attr_reader :api_key
4
+
5
+ def initialize(api_key)
6
+ @api_key = api_key
7
+ end
8
+
9
+ def spots(lat, lng, options = {})
10
+ Spot.list(lat, lng, @api_key, options)
11
+ end
12
+
13
+ def spot(reference, options = {})
14
+ Spot.find(reference, @api_key, options)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module GooglePlaces
2
+ class Location
3
+ def initialize(lat, lng)
4
+ @lat = lat
5
+ @lng = lng
6
+ end
7
+
8
+ def format
9
+ [ @lat, @lng ].join(',')
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ module GooglePlaces
2
+ class Request
3
+ attr_accessor :response
4
+
5
+ include ::HTTParty
6
+ format :json
7
+
8
+ SPOTS_LIST_URL = 'https://maps.googleapis.com/maps/api/place/search/json'
9
+ SPOT_URL = 'https://maps.googleapis.com/maps/api/place/details/json'
10
+
11
+ def self.spots(options = {})
12
+ request = new(SPOTS_LIST_URL, options)
13
+ request.parsed_response
14
+ end
15
+
16
+ def self.spot(options = {})
17
+ request = new(SPOT_URL, options)
18
+ request.parsed_response
19
+ end
20
+
21
+ def initialize(url, options)
22
+ @response = self.class.get(url, :query => options)
23
+ end
24
+
25
+ def parsed_response
26
+ @response.parsed_response
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,44 @@
1
+ module GooglePlaces
2
+ class Spot
3
+ attr_accessor :lat, :lng, :name, :icon, :reference, :vicinity
4
+
5
+ def self.list(lat, lng, api_key, options = {})
6
+ radius = options.delete(:radius) || 200
7
+ sensor = options.delete(:sensor) || false
8
+ location = Location.new(lat, lng)
9
+
10
+ response = Request.spots(
11
+ :location => location.format,
12
+ :radius => radius,
13
+ :sensor => sensor,
14
+ :key => api_key
15
+ )
16
+
17
+ response['results'].map do |result|
18
+ self.new(result)
19
+ end
20
+ end
21
+
22
+ def self.find(reference, api_key, options = {})
23
+ sensor = options.delete(:sensor) || false
24
+
25
+ response = Request.spot(
26
+ :reference => reference,
27
+ :sensor => sensor,
28
+ :key => api_key
29
+ )
30
+
31
+ self.new(response['result'])
32
+ end
33
+
34
+ def initialize(json_result_object)
35
+ @reference = json_result_object['reference'],
36
+ @vicinity = json_result_object['vicinity'],
37
+ @lat = json_result_object['geometry']['location']['lat'],
38
+ @lng = json_result_object['geometry']['location']['lng'],
39
+ @name = json_result_object['name'],
40
+ @icon = json_result_object['icon']
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1 @@
1
+ RSPEC_API_KEY = 'abc123'
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe GooglePlaces::Client do
4
+
5
+ it 'should not initialize without an api_key' do
6
+ lambda { GooglePlaces::Client.new }.should raise_error
7
+ end
8
+
9
+ it 'should initialize with an api_key' do
10
+ @client = GooglePlaces::Client.new(api_key)
11
+ @client.api_key.should == api_key
12
+ end
13
+
14
+ it 'should request spots' do
15
+ lat, lng = '-33.8670522', '151.1957362'
16
+ @client = GooglePlaces::Client.new(api_key)
17
+ GooglePlaces::Spot.should_receive(:list).with(lat, lng, api_key, {})
18
+
19
+ @client.spots(lat, lng)
20
+ end
21
+
22
+ it 'should request a single spot' do
23
+ reference = "CoQBeAAAAO-prCRp9Atcj_rvavsLyv-DnxbGkw8QyRZb6Srm6QHOcww6lqFhIs2c7Ie6fMg3PZ4PhicfJL7ZWlaHaLDTqmRisoTQQUn61WTcSXAAiCOzcm0JDBnafqrskSpFtNUgzGAOx29WGnWSP44jmjtioIsJN9ik8yjK7UxP4buAmMPVEhBXPiCfHXk1CQ6XRuQhpztsGhQU4U6-tWjTHcLSVzjbNxoiuihbaA"
24
+ @client = GooglePlaces::Client.new(api_key)
25
+ GooglePlaces::Spot.should_receive(:find).with(reference, api_key, {})
26
+
27
+ @client.spot(reference)
28
+ end
29
+
30
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe GooglePlaces::Location do
4
+
5
+ it 'should return a location based on a lat and lng' do
6
+ GooglePlaces::Location.new('123', '456').format.should == '123,456'
7
+ end
8
+
9
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe GooglePlaces::Request do
4
+
5
+ before :each do
6
+ @location = GooglePlaces::Location.new('-33.8670522', '151.1957362').format
7
+ @radius = 200
8
+ @sensor = false
9
+ @reference = "CoQBeAAAAO-prCRp9Atcj_rvavsLyv-DnxbGkw8QyRZb6Srm6QHOcww6lqFhIs2c7Ie6fMg3PZ4PhicfJL7ZWlaHaLDTqmRisoTQQUn61WTcSXAAiCOzcm0JDBnafqrskSpFtNUgzGAOx29WGnWSP44jmjtioIsJN9ik8yjK7UxP4buAmMPVEhBXPiCfHXk1CQ6XRuQhpztsGhQU4U6-tWjTHcLSVzjbNxoiuihbaA"
10
+ end
11
+
12
+ context 'Listing spots' do
13
+ use_vcr_cassette 'list_spots'
14
+
15
+ it 'should retrieve a list of spots' do
16
+ response = GooglePlaces::Request.spots(
17
+ :location => @location,
18
+ :radius => @radius,
19
+ :sensor => @sensor,
20
+ :key => api_key
21
+ )
22
+
23
+ response['results'].should_not be_empty
24
+ end
25
+ end
26
+
27
+ context 'Spot details' do
28
+ use_vcr_cassette 'single_spot'
29
+
30
+ it 'should retrieve a single spot' do
31
+ response = GooglePlaces::Request.spots(
32
+ :reference => @reference,
33
+ :sensor => @sensor,
34
+ :key => api_key
35
+ )
36
+
37
+ response['result'].should_not be_empty
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe GooglePlaces::Spot do
4
+
5
+ before :each do
6
+ @lat = '-33.8670522'
7
+ @lng = '151.1957362'
8
+ @radius = 200
9
+ @sensor = false
10
+ @reference = "CoQBeAAAAO-prCRp9Atcj_rvavsLyv-DnxbGkw8QyRZb6Srm6QHOcww6lqFhIs2c7Ie6fMg3PZ4PhicfJL7ZWlaHaLDTqmRisoTQQUn61WTcSXAAiCOzcm0JDBnafqrskSpFtNUgzGAOx29WGnWSP44jmjtioIsJN9ik8yjK7UxP4buAmMPVEhBXPiCfHXk1CQ6XRuQhpztsGhQU4U6-tWjTHcLSVzjbNxoiuihbaA"
11
+ end
12
+
13
+ context 'List spots' do
14
+ use_vcr_cassette 'list_spots'
15
+
16
+ before :each do
17
+ @collection = GooglePlaces::Spot.list(@lat, @lng, api_key, :radius => @radius, :sensor => @sensor)
18
+ end
19
+
20
+ it 'should be a collection of Spots' do
21
+ @collection.map(&:class).uniq.should == [GooglePlaces::Spot]
22
+ end
23
+ end
24
+
25
+ context 'Find a single spot' do
26
+ use_vcr_cassette 'single_spot'
27
+
28
+ before :each do
29
+ @spot = GooglePlaces::Spot.find(@reference, api_key, :sensor => @sensor)
30
+ end
31
+
32
+ it 'should be a Spot' do
33
+ @spot.class.should == GooglePlaces::Spot
34
+ end
35
+
36
+ %w(reference vicinity lat lng name icon).each do |attribute|
37
+ it "should have the attribute: #{attribute}" do
38
+ @spot.send(attribute).to_s.should_not be_empty
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'vcr_setup'
4
+ require 'api_key'
5
+ require 'google_places'
6
+
7
+ def api_key
8
+ RSPEC_API_KEY
9
+ end
10
+
11
+ RSpec.configure do |config|
12
+ config.extend VCR::RSpec::Macros
13
+ end
@@ -0,0 +1,326 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://maps.googleapis.com:443/maps/api/place/search/json?radius=200&sensor=false&key=AIzaSyATGBjcfrRXQtNEMMyt8Fw7tSGEY8PQwv0&location=-33.8670522%2C151.1957362
6
+ body:
7
+ headers:
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 200
11
+ message: OK
12
+ headers:
13
+ content-type:
14
+ - application/json; charset=UTF-8
15
+ x-xss-protection:
16
+ - 1; mode=block
17
+ server:
18
+ - mafe
19
+ date:
20
+ - Mon, 16 May 2011 20:56:23 GMT
21
+ cache-control:
22
+ - private
23
+ vary:
24
+ - Accept-Language
25
+ body: |
26
+ {
27
+ "status": "OK",
28
+ "results": [ {
29
+ "name": "Pyrmont",
30
+ "types": [ "locality", "political" ],
31
+ "geometry": {
32
+ "location": {
33
+ "lat": -33.8695456,
34
+ "lng": 151.1945404
35
+ },
36
+ "viewport": {
37
+ "southwest": {
38
+ "lat": -33.8788097,
39
+ "lng": 151.1785330
40
+ },
41
+ "northeast": {
42
+ "lat": -33.8602805,
43
+ "lng": 151.2105478
44
+ }
45
+ }
46
+ },
47
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
48
+ "reference": "CnRoAAAAZjKdehGj2kVxm9J7E0UoOGJo_bGXDThTlRlifDJlDlPGeEJ5yQ-2fUSofYhS3twtTZED0hhebpOYLA8b8VvR_9TkrrxfZXIg9S_UsHMYh_F5eABunplqLwAggfyWfch5YK5SqxazWa2WoQoz05H7IxIQyvxeUL8FrzZFAmdqRKrR6BoUknI6yaGcbMY6CyLuIyMRYmpdt4Y",
49
+ "id": "40840d476baa531e0227a353b1bef70262f66e7e"
50
+ }, {
51
+ "name": "Star City",
52
+ "vicinity": "Pyrmont Street, Pyrmont",
53
+ "types": [ "lodging", "establishment" ],
54
+ "geometry": {
55
+ "location": {
56
+ "lat": -33.8682000,
57
+ "lng": 151.1945860
58
+ }
59
+ },
60
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png",
61
+ "reference": "CnRhAAAAKjwqd8kGDNgdvMj2_VJjLqoizf80ohJLumWHxK6cY4E3MHZM92Y8lywFuFCPCo73dowC4U0vxqVTLP607XOw7ndmkexMRF22spdKNCgtfQcLVaC4tXKqUKjsjG9lALCHyIrTay4jbGNMZwcr4e2qRRIQtbUuBsA5rx65luq526M-VRoUGJUT7lIgHoSWDAk6tTG5Pv6zGTw",
62
+ "id": "be880205d64059c306bbf198f908b81cabb9f066"
63
+ }, {
64
+ "name": "Ripples at Sydney Wharf",
65
+ "vicinity": "Pirrama Road, Pyrmont",
66
+ "types": [ "establishment" ],
67
+ "geometry": {
68
+ "location": {
69
+ "lat": -33.8667010,
70
+ "lng": 151.1973990
71
+ }
72
+ },
73
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
74
+ "reference": "CnRuAAAAboUpEekYUmyLEpeyN5g6dPpHB9HjZpNUJ8wQ4DVmfV0-4vyPJpBjMLXtqlH35vrVB_8Mp8Lxnw0m3mSCpbpGWg5yawiR5CKpkKhV4FGWOkFaU10U9yuN35MBPcQPZht73_TF8l_RWA4fKY293fR90BIQO_6doKC1JbNu_FoeFlSRSRoU3vuANKslG6fG_owbbMxYQll58iQ",
75
+ "id": "dd030d236b8ccdc525f7a40893eb492f8fc5d55d"
76
+ }, {
77
+ "name": "Google Sydney",
78
+ "vicinity": "Pirrama Road, Pyrmont",
79
+ "types": [ "establishment" ],
80
+ "geometry": {
81
+ "location": {
82
+ "lat": -33.8669710,
83
+ "lng": 151.1958750
84
+ }
85
+ },
86
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
87
+ "reference": "CnRlAAAAvclMmIcKJtY2kLeOz_rqW3ikacM7LuFwnX1qD5PiDRrQCRO0v9cm6Mo7WYKGCIO_ngg5zoyfueoQVQxbdRPQoOHYouwI0kxI3EkzhfpI5t8lCRCu_wcx4RmG9-mQNesbfwRL7xdX9CTQKmlyzNJ3LBIQpoWWkt1UACMUMyf_u5J-wBoUF5QZuOBgOo2p_W67o10WnABV72k",
88
+ "id": "4f89212bf76dde31f092cfc14d7506555d85b5c7"
89
+ }, {
90
+ "name": "Signorelli Gastronomia",
91
+ "vicinity": "Trouton Place, Pyrmont",
92
+ "types": [ "restaurant", "food", "establishment" ],
93
+ "geometry": {
94
+ "location": {
95
+ "lat": -33.8665470,
96
+ "lng": 151.1959410
97
+ }
98
+ },
99
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
100
+ "reference": "CnRuAAAA-wkpRsz-a-oCbui2nF7oE1laTV_2CGAqj4OjkpT2oi49JDG2egl89MjT7qGr59H8epStVq-Y91ZNMVZJoQXOGDrwgzdr3cFv-Q6ZSu8VQedz2sUOcehgL6-bvwbzdymfplRMgGm1wd6FMkSnEorvNxIQJJSCO5xFerHFlrHgAinPAhoU1h3gw1_Wq_WA678SKzN9u9_7hK4",
101
+ "id": "4d716a646c32978aa12d1057dcf9f503a20195c0"
102
+ }, {
103
+ "name": "Garden Buffet",
104
+ "vicinity": "Pyrmont Street, Pyrmont",
105
+ "types": [ "restaurant", "food", "establishment" ],
106
+ "geometry": {
107
+ "location": {
108
+ "lat": -33.8681980,
109
+ "lng": 151.1945840
110
+ }
111
+ },
112
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
113
+ "reference": "CnRlAAAAUrboV7a3e4QO_4PUrx1SgoWrF5EBlsSYHWXea8yEY4Zj4kpHY4QrcPOYjiR6s900N-sfZk4_HjUPW9fq0TtVANyHVqnHoOZITHIYGJY9Lji640IGgRtiKod1C9hiKPxcjfdz4ENXC0dqGjiBU5lqCxIQB5r-0dXxGtLSYHga7z7sFBoUJF9uHMWgU_xDKYuLIoVqv3fh6fc",
114
+ "id": "eaf5d4b14ebeae84df661e1f6d593259abac83d4"
115
+ }, {
116
+ "name": "Astral",
117
+ "vicinity": "Pyrmont Street, Sydney",
118
+ "types": [ "restaurant", "food", "establishment" ],
119
+ "geometry": {
120
+ "location": {
121
+ "lat": -33.8681980,
122
+ "lng": 151.1945840
123
+ }
124
+ },
125
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
126
+ "reference": "CmReAAAAehMqsOqjki53jOYHTSzNb3JPzx6K-hPgg2ngZajWjGCAiE4VxRRTsDX9kqx7EaRJbYNNeJSNO8L4WW81brQdxQj_cRoQyA2rG1xufcgn4UNa6d8RE2M4d_JoWhFR-qahEhD0zHl0SlHzGKtXbaU-ORSyGhRZKXSaWjD3gfzsuVp8YZLcrdD2CQ",
127
+ "id": "bceeb9b6d5ac2f9f2573bbed9e1b3240f1fd0e12"
128
+ }, {
129
+ "name": "Accenture",
130
+ "vicinity": "Pirrama Road, Pyrmont",
131
+ "types": [ "establishment" ],
132
+ "geometry": {
133
+ "location": {
134
+ "lat": -33.8670840,
135
+ "lng": 151.1959500
136
+ }
137
+ },
138
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
139
+ "reference": "CoQBfgAAALEv8hs9sdLazHlXXwsxxZ2UOxL7cI5thGrPiEPzIWGzUO3kJ7AtOuFlZj1rrcohZ-IKd00HL75TI-zL-eeCjLLlQcwLJKDDEyhnxdfXpPXWKMSpctmNlFZzuc-q-5QT7zCiP_SkXD0_E8JhHiD4koirfgUaKrghycMPWF9Z4fNWEhCLxE4D2_vKwhxLy4v1qqElGhRtvU3-A-zgoHSs6um69bXj0ePdJg",
140
+ "id": "27e84d1acda19c14b9c7f5271242796891bc9c9e"
141
+ }, {
142
+ "name": "Fairfax Media",
143
+ "vicinity": "Darling Island Road, Pyrmont",
144
+ "types": [ "establishment" ],
145
+ "geometry": {
146
+ "location": {
147
+ "lat": -33.8654620,
148
+ "lng": 151.1959830
149
+ }
150
+ },
151
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
152
+ "reference": "CnRlAAAA3s8dTF4shgM5feBxw8cyuuzghSaW2FcdNlAeWLh6s5JMUxF7W-oCnDczD3Q_zAxXki049KMI8nNboUNcq0FiqkfkOesd_DTt5M3XqfGJy-SA8ooF9Jg1YGp4YxnEH8OiXOba39RgNMB3fply8-CIDBIQrMlWAE9hX0WQw8F_T7EnlRoU94zo4ZY_wapa8_S3CxVv-FUYkT4",
153
+ "id": "3e2826e1b4b4e5cbee354260f687d14938e6068f"
154
+ }, {
155
+ "name": "Fairfax Media",
156
+ "vicinity": "Darling Island Road, Pyrmont",
157
+ "types": [ "establishment" ],
158
+ "geometry": {
159
+ "location": {
160
+ "lat": -33.8652490,
161
+ "lng": 151.1961010
162
+ }
163
+ },
164
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
165
+ "reference": "CnRkAAAAkdvnxcBAPpeOMt3t-MmIJ0YMDqHgOrAq4RO8YcgNqcRtadnX_1Iej61nsIsgtMBeigVWBE4-Hrj7vR993RzpmmYkRqgIIXYxBqF911JkgZwMPVaQBJp6xb3MsWvBjYRKZa0LbSul89Rx14PVxdK_FhIQCWmL3fkjhn94Oz786uPF3xoUSwuum2vDZEa1EHT_cD8dNSAeHnA",
166
+ "id": "1f2ddcefca08ffc687247c1ecf209054336aebb8"
167
+ }, {
168
+ "name": "John Holland",
169
+ "vicinity": "Pirrama Rd, Pyrmont",
170
+ "types": [ "establishment" ],
171
+ "geometry": {
172
+ "location": {
173
+ "lat": -33.8687940,
174
+ "lng": 151.1968300
175
+ }
176
+ },
177
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
178
+ "reference": "CnRjAAAAtKWuPt-xPqEuys5kHwscxex99t4OWVpG8s-3IDLwDCJtT72Fq9JDSMqBTtNx0Tj-jdZ_QGy80KnYbBB0wWMs3pwXXFXoGub0pivpPpBi5JpJ_lnljyscthh6vIKECl9JQtF_798os9rL8D7iWKZx7BIQ4Bex-MXFyB1ytBcB9w5H_xoUqeAM8bsU5C3t_T6xe46j_tuPdis",
179
+ "id": "61178ac5b42a4045c415fffdf6d474ba9b08d068"
180
+ }, {
181
+ "name": "Seans Kitchen",
182
+ "vicinity": "Pyrmont Street, Pyrmont",
183
+ "types": [ "restaurant", "food", "establishment" ],
184
+ "geometry": {
185
+ "location": {
186
+ "lat": -33.8681980,
187
+ "lng": 151.1945840
188
+ }
189
+ },
190
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
191
+ "reference": "CnRkAAAAYCQHi4uqW9_FO82_aWfKGlJYshMRIgjhThKvGxNi0HRRn5WDMEweiz7SYjz6Bl0BlEloBDw6PJnxg88KtkoS1ItfiMOHVuJf049XPqfdoLk58CayJL8fzfzhg_F7bnD5aQLBXwJjpBrlRk63w_8W6BIQTB98PvbgYXRIP0qNBEW9VhoUbg4LBDKRUlSQncPJJaUN4V4d6RI",
192
+ "id": "88751426b87d7072ea1acf98f35695d02985addb"
193
+ }, {
194
+ "name": "Channel Seven",
195
+ "vicinity": "Pirrama Road, Pyrmont",
196
+ "types": [ "establishment" ],
197
+ "geometry": {
198
+ "location": {
199
+ "lat": -33.8660710,
200
+ "lng": 151.1944390
201
+ }
202
+ },
203
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
204
+ "reference": "CnRlAAAALz1LkbIHsaliP6WoAaNxU01M6zC3kZNewLqu2R6u2zOxkpTFv5R9B0tRbDD9mly1R7NgHZzZSI2BTLXfJj8YKTBNvPTNSF-JM8BmY1YTFrXryxWThrMg172gU40ypom4o2qhNidm_fkbgUHKv-bDhxIQuAzFJvp28JqqePT8CRFWHxoUQQffs7Qp7giQZaipftWiEBglHzs",
205
+ "id": "19cdf89322aa1fc3523c583a74a27645b11430e8"
206
+ }, {
207
+ "name": "Avis",
208
+ "vicinity": "Pyrmont Street, Pyrmont",
209
+ "types": [ "car_rental", "establishment" ],
210
+ "geometry": {
211
+ "location": {
212
+ "lat": -33.8681980,
213
+ "lng": 151.1945840
214
+ }
215
+ },
216
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
217
+ "reference": "CmRbAAAA1IUBZVA5jwmicTiW8zNbvLulmf2GJ-uEiDfLevJnoVy8VcczuKi3IXFEXtRtXoZuGYqq2nLa0XKQrH3dNSaV4xgwPxSVhSBRU4yevB_Z2hRifoFbVNgMTbtgPo1_A1X0EhABhJpeDfk5MbbWqC_bw9y5GhSHrreEdpex54mreNHTaIlZZc9Cgg",
218
+ "id": "d559b2e8e491212130cf17c4d0ac595c72b3931f"
219
+ }, {
220
+ "name": "Lotus Pond",
221
+ "vicinity": "Pyrmont Street, Pyrmont",
222
+ "types": [ "restaurant", "food", "establishment" ],
223
+ "geometry": {
224
+ "location": {
225
+ "lat": -33.8681980,
226
+ "lng": 151.1945840
227
+ }
228
+ },
229
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
230
+ "reference": "CnRiAAAAZ4ToVtI44jrLdD_HwTqrDis69gKZR3KpPz1U7t24gj0jF-hXgeLDij8CywRTX02Ed4ttYguSqCofCakRf1K0G6l15D7ODUma7_VLBs-77i3OPBpQBNe30IhUWpAsQRSAK3B_OZF7iWY95IyhSpnZ-hIQGjvxTeK7zKnY3h23cbMR0hoUPlwdkmCZ_GQ9l897p7jdZpqx22U",
231
+ "id": "ca11a8721d7fa06d9ed6ce80c7e49af70f440fd8"
232
+ }, {
233
+ "name": "Bite Me Burger",
234
+ "vicinity": "Pyrmont Street, Pyrmont",
235
+ "types": [ "restaurant", "food", "establishment" ],
236
+ "geometry": {
237
+ "location": {
238
+ "lat": -33.8681980,
239
+ "lng": 151.1945840
240
+ }
241
+ },
242
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
243
+ "reference": "CnRlAAAALDu5NYsmU6qyxiaqJt-jDB2TfH4LuKr65ETEl1MFu8BR3BzmHpOU1IhS6bLlk0IKNQCOhVxxuOlGj-NH3TLgvjxm7HMkcG3rtOKrs73VhBwOFxtcnrwKkGOaOXzfUdle0yRF8qkK_-BR1I95tfYj2BIQdyXkbNEJmJiH6uzlZtGbFhoUlde33-u74nwjYIhNNG2-fXy9N9I",
244
+ "id": "c59ee010f131efcf1cd728c05ef73215319e52f0"
245
+ }, {
246
+ "name": "Fairfax Digital",
247
+ "vicinity": "Pirrama Road, Pyrmont",
248
+ "types": [ "establishment" ],
249
+ "geometry": {
250
+ "location": {
251
+ "lat": -33.8660710,
252
+ "lng": 151.1944390
253
+ }
254
+ },
255
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
256
+ "reference": "CnRnAAAA2BjS9rAagMs7a4VIWYpIyiIwYFH7zXDILVNmldtwofuuPT7fEjXUP-Vq9_SqWvGsO3bTu7_ySbjyM71g5bW3kDu53O_5n_HjWm8JuEhuA5PAn5_NxGekLMhNPGKLKtZJmdQBlYisETGUqGQ7lbPDqxIQ05yEZ568oiOIi4FYzK9d_xoUXxS7lhyjgNg1nIqoJ0hKhu0S3Q0",
257
+ "id": "6b3cb6af5b5bed3297d96b48aac81a96f95ead4c"
258
+ }, {
259
+ "name": "Doltone House - Darling Island Wharf",
260
+ "vicinity": "Pirrama Road, Pyrmont",
261
+ "types": [ "establishment" ],
262
+ "geometry": {
263
+ "location": {
264
+ "lat": -33.8670520,
265
+ "lng": 151.1957360
266
+ }
267
+ },
268
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
269
+ "reference": "CoQBfAAAAIOvkBRskkkLdw2PoZpvoXJhDs9hNqdt5Emap9eDf1mNu86F92Abh8TGQrzHVGJIzQ8ZX5VAdFe6M8Gwon_Q69-19VRkkHQ0KK7WZhYYt3fH74ZYIapFr3JlYkgyxhj5yeQa4solpc2C3YA1fbYH4fJeof66_sj99S8oP-zYkBDgEhBRNNWZT8cri0UTvZPZa2K2GhRTKKbIbD4bs8S5cYhXkz7fVCYSKw",
270
+ "id": "3ef986cd56bb3408bc1cf394f3dad9657c1d30f6"
271
+ }, {
272
+ "name": "Domain.Com.Au",
273
+ "vicinity": "Pirrama Road, Pyrmont",
274
+ "types": [ "real_estate_agency", "establishment" ],
275
+ "geometry": {
276
+ "location": {
277
+ "lat": -33.8660710,
278
+ "lng": 151.1944390
279
+ }
280
+ },
281
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
282
+ "reference": "CnRkAAAA_C4kyy2pAof94NA2Z-qmYafl6n4QSk3l69DN37B049DUTEGAUkGj48Z_N2w7n1z2kuTzP-8CWaFga3RX7MUgt1oMmnqjrIKbqdKGwyJsMtI-XZdBw9ZRCwJuM5Jmk1MdjTHUxLljUG6Kh4dl4Jls5BIQUwrmN7ZD-tfPC7f-ZyfhoxoUYxYye9Llb3foY5Wpj5Eo-JnO9xQ",
283
+ "id": "22069082ad380a2f09db4675e7474c87e8557f3d"
284
+ }, {
285
+ "name": "Fat Noodle",
286
+ "vicinity": "Pyrmont Street, Pyrmont",
287
+ "types": [ "restaurant", "food", "establishment" ],
288
+ "geometry": {
289
+ "location": {
290
+ "lat": -33.8681980,
291
+ "lng": 151.1945840
292
+ }
293
+ },
294
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
295
+ "reference": "CnRhAAAA_QIS77PlT4aALc3BSQdII-L8WjsbqTdZXWkgQ_sbDB1eqEBqUy1MvTN3q52Yx7TJSZYpQHWahZ_31qUFt13fK0E00cwF6X6zvZpJXLGcmskfaN795mS1RZVpRzxQLihSpy066luwHDnZ5DtNeo0DJhIQO7RgNUxdMeJbA9V6LG4RQhoUX6dwl7glDhc3-VhN0LdXWM2gAto",
296
+ "id": "ba9494fbebdb7e40f9a646aab93379212763195c"
297
+ }, {
298
+ "name": "Blue Eye Dragon",
299
+ "vicinity": "Pyrmont Street, Pyrmont",
300
+ "types": [ "restaurant", "food", "establishment" ],
301
+ "geometry": {
302
+ "location": {
303
+ "lat": -33.8676090,
304
+ "lng": 151.1936860
305
+ }
306
+ },
307
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
308
+ "reference": "CnRmAAAAXkho1LLdtwMiNA1qppitMrj6zyw7KaTpvUuls_UHx_xunllNxp4mfiMwzm3uv_xDrVvKm4oc1baW1qzo0ZEEsOwc73dV4kPrjaLVek8nVD1tAFLRqpCi2wOI8TKs3Y4XxdJ2SUJ-RYZ__ZgY57YAGBIQU2FOTpI5dGTP2XmstdKseRoUl4KQPjQwbd78jnUQOKdI4mNhZ1k",
309
+ "id": "00060cf64f16375913ec49d25cbb7829d3e08a88"
310
+ }, {
311
+ "name": "Port Jackson",
312
+ "types": [ "locality", "political" ],
313
+ "geometry": {
314
+ "location": {
315
+ "lat": -33.8517149,
316
+ "lng": 151.1966444
317
+ }
318
+ },
319
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
320
+ "reference": "CnRtAAAAqPzE3Of-4UH_8Jgo3_J7zCnDf5LfoQaTEezOcV1XH3P8WtlERBzwX5LMiEnc_gUz6FnOaBWSTNgcwdb1cfXJ0Ws6kJtqjS4Y9QtcpTmTuqUq4cwtzkwpSl0Cq6Staelh_4KncPMa6uma7R0oiDWhExIQVz3GTt8Uv9kaw8z6nQ-KXRoUIPaol1HIGplToOFrTiw7L5XxSP4",
321
+ "id": "8dbf2c11a8cca5b1457b442e05d006a21969ce22"
322
+ } ],
323
+ "html_attributions": [ "Listings by \u003ca href=\"http://www.yellowpages.com.au/\"\u003eYellow Pages\u003c/a\u003e" ]
324
+ }
325
+
326
+ http_version: "1.1"
@@ -0,0 +1,100 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://maps.googleapis.com:443/maps/api/place/search/json?reference=CoQBeAAAAO-prCRp9Atcj_rvavsLyv-DnxbGkw8QyRZb6Srm6QHOcww6lqFhIs2c7Ie6fMg3PZ4PhicfJL7ZWlaHaLDTqmRisoTQQUn61WTcSXAAiCOzcm0JDBnafqrskSpFtNUgzGAOx29WGnWSP44jmjtioIsJN9ik8yjK7UxP4buAmMPVEhBXPiCfHXk1CQ6XRuQhpztsGhQU4U6-tWjTHcLSVzjbNxoiuihbaA&sensor=false&key=AIzaSyATGBjcfrRXQtNEMMyt8Fw7tSGEY8PQwv0
6
+ body:
7
+ headers:
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 200
11
+ message: OK
12
+ headers:
13
+ content-type:
14
+ - application/json; charset=UTF-8
15
+ date:
16
+ - Mon, 16 May 2011 20:56:23 GMT
17
+ server:
18
+ - mafe
19
+ x-xss-protection:
20
+ - 1; mode=block
21
+ vary:
22
+ - Accept-Language
23
+ cache-control:
24
+ - private
25
+ body: |
26
+ {
27
+ "status": "INVALID_REQUEST",
28
+ "results": [ ],
29
+ "html_attributions": [ ]
30
+ }
31
+
32
+ http_version: "1.1"
33
+ - !ruby/struct:VCR::HTTPInteraction
34
+ request: !ruby/struct:VCR::Request
35
+ method: :get
36
+ uri: https://maps.googleapis.com:443/maps/api/place/details/json?reference=CoQBeAAAAO-prCRp9Atcj_rvavsLyv-DnxbGkw8QyRZb6Srm6QHOcww6lqFhIs2c7Ie6fMg3PZ4PhicfJL7ZWlaHaLDTqmRisoTQQUn61WTcSXAAiCOzcm0JDBnafqrskSpFtNUgzGAOx29WGnWSP44jmjtioIsJN9ik8yjK7UxP4buAmMPVEhBXPiCfHXk1CQ6XRuQhpztsGhQU4U6-tWjTHcLSVzjbNxoiuihbaA&sensor=false&key=AIzaSyATGBjcfrRXQtNEMMyt8Fw7tSGEY8PQwv0
37
+ body:
38
+ headers:
39
+ response: !ruby/struct:VCR::Response
40
+ status: !ruby/struct:VCR::ResponseStatus
41
+ code: 200
42
+ message: OK
43
+ headers:
44
+ content-type:
45
+ - application/json; charset=UTF-8
46
+ x-xss-protection:
47
+ - 1; mode=block
48
+ server:
49
+ - mafe
50
+ date:
51
+ - Mon, 16 May 2011 20:56:23 GMT
52
+ cache-control:
53
+ - private
54
+ vary:
55
+ - Accept-Language
56
+ body: |
57
+ {
58
+ "status": "OK",
59
+ "result": {
60
+ "name": "Strike Bowling Bar Darling Harbour",
61
+ "vicinity": "The Promenade, Sydney",
62
+ "types": [ "bar", "establishment" ],
63
+ "formatted_phone_number": "(02) 9276 7100",
64
+ "formatted_address": "22 The Promenade, Sydney NSW, Australia",
65
+ "address_components": [ {
66
+ "long_name": "22",
67
+ "short_name": "22",
68
+ "types": [ "street_number" ]
69
+ }, {
70
+ "long_name": "The Promenade",
71
+ "short_name": "The Promenade",
72
+ "types": [ "route" ]
73
+ }, {
74
+ "long_name": "Sydney",
75
+ "short_name": "Sydney",
76
+ "types": [ "locality", "political" ]
77
+ }, {
78
+ "long_name": "NSW",
79
+ "short_name": "NSW",
80
+ "types": [ "administrative_area_level_1", "political" ]
81
+ }, {
82
+ "long_name": "2000",
83
+ "short_name": "2000",
84
+ "types": [ "postal_code" ]
85
+ } ],
86
+ "geometry": {
87
+ "location": {
88
+ "lat": -33.8662990,
89
+ "lng": 151.2016580
90
+ }
91
+ },
92
+ "url": "http://maps.google.com/maps/place?cid=8959672613212618319",
93
+ "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
94
+ "reference": "CoQBeAAAAAUMe04SUnm6RIGcuqMjKTx-Ic-IUjZvVWd7iAUix9aXSq5zc6HD1qz0eV7WpKw6OYRn8ROXtP30MbsuXA6hwDnqMZP4CCEbuM0wzYxRhQYA8w1u5PhPc68qPYpnJewYgdAn8ABQS4HsAlngvJCzoUvQ3FgvTRtE-AvWiPNfb3QiEhBQr_GLVUynpIk18yxa89eGGhSs16baRJ75DexGyna6FTtzOTS97Q",
95
+ "id": "0a4e24c365f4bd70080f99bb80153c5ba3faced8"
96
+ },
97
+ "html_attributions": [ ]
98
+ }
99
+
100
+ http_version: "1.1"
data/spec/vcr_setup.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'vcr'
2
+
3
+ VCR.config do |c|
4
+ c.cassette_library_dir = 'spec/vcr_cassettes'
5
+ c.stub_with :fakeweb
6
+ c.ignore_localhost = true
7
+ c.default_cassette_options = { :record => :new_episodes }
8
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google_places
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Marcel de Graaf
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-16 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: httparty
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: fakeweb
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: vcr
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :development
76
+ version_requirements: *id004
77
+ description: This gem provides a Ruby wrapper around the Google Places API for use in your own project. Please note that this gem does not provide OAuth authentication.
78
+ email:
79
+ - mail@marceldegraaf.net
80
+ executables: []
81
+
82
+ extensions: []
83
+
84
+ extra_rdoc_files: []
85
+
86
+ files:
87
+ - .gitignore
88
+ - Gemfile
89
+ - README.rdoc
90
+ - Rakefile
91
+ - google_places.gemspec
92
+ - lib/google_places.rb
93
+ - lib/google_places/client.rb
94
+ - lib/google_places/location.rb
95
+ - lib/google_places/request.rb
96
+ - lib/google_places/spot.rb
97
+ - spec/api_key.sample.rb
98
+ - spec/google_places/client_spec.rb
99
+ - spec/google_places/location_spec.rb
100
+ - spec/google_places/request_spec.rb
101
+ - spec/google_places/spot_spec.rb
102
+ - spec/spec_helper.rb
103
+ - spec/vcr_cassettes/list_spots.yml
104
+ - spec/vcr_cassettes/single_spot.yml
105
+ - spec/vcr_setup.rb
106
+ has_rdoc: true
107
+ homepage: http://marceldegraaf.net
108
+ licenses: []
109
+
110
+ post_install_message:
111
+ rdoc_options: []
112
+
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ requirements: []
134
+
135
+ rubyforge_project:
136
+ rubygems_version: 1.5.0
137
+ signing_key:
138
+ specification_version: 3
139
+ summary: A Ruby wrapper around the Google Places API.
140
+ test_files:
141
+ - spec/api_key.sample.rb
142
+ - spec/google_places/client_spec.rb
143
+ - spec/google_places/location_spec.rb
144
+ - spec/google_places/request_spec.rb
145
+ - spec/google_places/spot_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/vcr_cassettes/list_spots.yml
148
+ - spec/vcr_cassettes/single_spot.yml
149
+ - spec/vcr_setup.rb