google_places 0.1.0 → 0.1.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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_places (0.0.8)
4
+ google_places (0.1.0)
5
5
  httparty
6
6
 
7
7
  GEM
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "google_places"
6
- s.version = '0.1.0'
6
+ s.version = '0.1.1'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Marcel de Graaf"]
9
9
  s.email = ["mail@marceldegraaf.net"]
@@ -0,0 +1,13 @@
1
+ module GooglePlaces
2
+ class Review
3
+ attr_accessor :rating, :type, :author_name, :author_url, :text, :time
4
+ def initialize(rating, type, author_name, author_url, text, time)
5
+ @rating = rating
6
+ @type = type
7
+ @author_name = author_name
8
+ @author_url = author_url
9
+ @text = text
10
+ @time = time
11
+ end
12
+ end
13
+ end
@@ -1,6 +1,8 @@
1
+ require 'google_places/review'
2
+
1
3
  module GooglePlaces
2
4
  class Spot
3
- attr_accessor :lat, :lng, :name, :icon, :reference, :vicinity, :types, :id, :formatted_phone_number, :international_phone_number, :formatted_address, :address_components, :street_number, :street, :city, :region, :postal_code, :country, :rating, :url, :cid, :website
5
+ attr_accessor :lat, :lng, :name, :icon, :reference, :vicinity, :types, :id, :formatted_phone_number, :international_phone_number, :formatted_address, :address_components, :street_number, :street, :city, :region, :postal_code, :country, :rating, :url, :cid, :website, :reviews
4
6
 
5
7
  def self.list(lat, lng, api_key, options = {})
6
8
  radius = options.delete(:radius) || 200
@@ -124,6 +126,7 @@ module GooglePlaces
124
126
  @url = json_result_object['url']
125
127
  @cid = json_result_object['url'].to_i
126
128
  @website = json_result_object['website']
129
+ @reviews = reviews_component(json_result_object['reviews'])
127
130
  end
128
131
 
129
132
  def address_component(address_component_type, address_component_length)
@@ -136,5 +139,21 @@ module GooglePlaces
136
139
  @address_components.select{ |c| c['types'].include?(type.to_s) } unless @address_components.nil?
137
140
  end
138
141
 
142
+ def reviews_component(json_reviews)
143
+ if json_reviews
144
+ json_reviews.map { |r|
145
+ Review.new(
146
+ r['aspects'].empty? ? nil : r['aspects'][0]['rating'],
147
+ r['aspects'].empty? ? nil : r['aspects'][0]['type'],
148
+ r['author_name'],
149
+ r['author_url'],
150
+ r['text'],
151
+ r['time'].to_i
152
+ )
153
+ }
154
+ else []
155
+ end
156
+ end
157
+
139
158
  end
140
159
  end
@@ -116,9 +116,6 @@ describe GooglePlaces::Spot do
116
116
 
117
117
  end
118
118
 
119
-
120
-
121
-
122
119
  context 'List spots by query' do
123
120
  use_vcr_cassette 'list_spots'
124
121
 
@@ -145,6 +142,14 @@ describe GooglePlaces::Spot do
145
142
  @spot.respond_to?(attribute).should == true
146
143
  end
147
144
  end
145
+ it 'should contain 5 reviews' do
146
+ @spot.reviews.size == 5
147
+ end
148
+ %w(rating type author_name author_url text time).each do |attribute|
149
+ it "should have the review attribute: #{attribute}" do
150
+ @spot.reviews[0].respond_to?(attribute).should be true
151
+ end
152
+ end
148
153
  end
149
154
 
150
155
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_places
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcel de Graaf
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-01 00:00:00 Z
18
+ date: 2012-07-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty
@@ -94,6 +94,7 @@ files:
94
94
  - lib/google_places/error.rb
95
95
  - lib/google_places/location.rb
96
96
  - lib/google_places/request.rb
97
+ - lib/google_places/review.rb
97
98
  - lib/google_places/spot.rb
98
99
  - spec/api_key.sample.rb
99
100
  - spec/google_places/client_spec.rb