yelpster 1.1.3 → 1.1.4
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/CHANGELOG.rdoc +9 -0
- data/README.md +63 -48
- data/lib/yelpster.rb +0 -4
- data/lib/yelpster/client.rb +6 -5
- data/lib/yelpster/record.rb +1 -1
- data/lib/yelpster/response_format.rb +1 -1
- data/lib/yelpster/v1/neighborhood/request/base.rb +1 -1
- data/lib/yelpster/v1/neighborhood/request/geo_point.rb +1 -1
- data/lib/yelpster/v1/neighborhood/request/location.rb +1 -1
- data/lib/yelpster/v1/phone/request/number.rb +1 -1
- data/lib/yelpster/v1/request.rb +1 -1
- data/lib/yelpster/v1/review/request/base.rb +1 -1
- data/lib/yelpster/v1/review/request/bounding_box.rb +1 -1
- data/lib/yelpster/v1/review/request/geo_point.rb +1 -1
- data/lib/yelpster/v1/review/request/location.rb +1 -1
- data/lib/yelpster/v2/business/request/id.rb +1 -1
- data/lib/yelpster/v2/request.rb +1 -1
- data/lib/yelpster/v2/search/request/base.rb +1 -1
- data/lib/yelpster/v2/search/request/bounding_box.rb +1 -1
- data/lib/yelpster/v2/search/request/geo_point.rb +1 -1
- data/lib/yelpster/v2/search/request/location.rb +1 -1
- data/lib/yelpster/version.rb +3 -0
- data/spec/business_retrieve_spec.rb +17 -15
- data/spec/business_search_spec.rb +57 -55
- data/spec/neighborhood_search_spec.rb +23 -21
- data/spec/phone_search_spec.rb +7 -5
- data/spec/review_search_spec.rb +122 -120
- metadata +18 -5
- checksums.yaml +0 -15
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== YELPSTER_20130629_1_1_4
|
2
|
+
* [naveed] Convert Yelp to a module
|
3
|
+
|
4
|
+
* [naveed] Make lib ruby v1.8 compatible
|
5
|
+
|
6
|
+
* [naveed] Add rdoc task
|
7
|
+
|
8
|
+
* [naveed] Add Travis CI
|
9
|
+
|
1
10
|
== YELPSTER_20130608_1_1_3
|
2
11
|
* [naveed] Combine address components with ',' rather than space
|
3
12
|
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## Yelpster
|
2
2
|
|
3
|
+
[](https://travis-ci.org/nvd/yelpster)
|
4
|
+
|
3
5
|
A Ruby object-oriented interface to the local business content available
|
4
6
|
on Yelp at http://www.yelp.com. Functionality is provided to perform
|
5
7
|
all searches available via the developer API including:
|
@@ -46,7 +48,7 @@ or
|
|
46
48
|
|
47
49
|
## Usage
|
48
50
|
|
49
|
-
Instantiate a Yelp::Client and use its
|
51
|
+
Instantiate a Yelp::Client and use its ```search``` method to make requests of
|
50
52
|
the Yelp server.
|
51
53
|
|
52
54
|
The available search request types are:
|
@@ -62,10 +64,13 @@ The available search request types are:
|
|
62
64
|
* Yelp::V2::Search::Request::GeoPoint
|
63
65
|
* Yelp::V2::Search::Request::Location
|
64
66
|
|
67
|
+
You can ```include``` the overlying module to cut back on typing
|
68
|
+
or in case of conflicts between classes, use the fully qualified search request class name.
|
69
|
+
|
65
70
|
By default, response content is formatted as a Ruby hash converted from Yelp's
|
66
71
|
source JSON response content. Alternate response formats (including the
|
67
72
|
original pure JSON) can be specified on request record construction via the
|
68
|
-
Yelp::[V1/V2]::Request
|
73
|
+
Yelp::[V1/V2]::Request ```response_format``` parameter, available in all request record
|
69
74
|
types.
|
70
75
|
|
71
76
|
A few examples:
|
@@ -74,8 +79,9 @@ A few examples:
|
|
74
79
|
# construct a client instance
|
75
80
|
client = Yelp::Client.new
|
76
81
|
|
82
|
+
include Yelp::V1::Review::Request
|
77
83
|
# perform an address/location-based search for cream puffs nearby
|
78
|
-
request =
|
84
|
+
request = Location.new(
|
79
85
|
:address => '650 Mission St',
|
80
86
|
:city => 'San Francisco',
|
81
87
|
:state => 'CA',
|
@@ -85,79 +91,88 @@ A few examples:
|
|
85
91
|
response = client.search(request)
|
86
92
|
|
87
93
|
# perform a location-based category search for either ice cream or donut shops in SF
|
88
|
-
request =
|
94
|
+
request = Location.new(
|
89
95
|
:city => 'San Francisco',
|
90
96
|
:state => 'CA',
|
91
|
-
:category => [
|
97
|
+
:category => ['donuts', 'icecream'],
|
92
98
|
:yws_id => 'YOUR_YWSID_HERE')
|
93
99
|
response = client.search(request)
|
94
100
|
|
95
101
|
# perform a neighborhood name lookup for a specific geo-location point
|
96
|
-
request =
|
102
|
+
request = GeoPoint.new(
|
97
103
|
:latitude => 37.782093,
|
98
104
|
:longitude => -122.483230,
|
99
105
|
:yws_id => 'YOUR_YWSID_HERE')
|
100
106
|
response = client.search(request)
|
101
107
|
|
108
|
+
# -------------------------------------------------------
|
109
|
+
|
110
|
+
include Yelp::V1::Phone::Request
|
102
111
|
# perform a business review search based on a business phone number
|
103
|
-
request =
|
112
|
+
request = Number.new(
|
104
113
|
:phone_number => '4155551212',
|
105
114
|
:yws_id => 'YOUR_YWSID_HERE')
|
106
115
|
response = client.search(request)
|
107
116
|
|
117
|
+
# -------------------------------------------------------
|
118
|
+
|
119
|
+
include Yelp::V2::Business::Request
|
108
120
|
# retrieve details of business vi yelp business id
|
109
|
-
request =
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
121
|
+
request = Id.new(
|
122
|
+
:yelp_business_id => "pjb2WMwa0AfK3L-dWimO8w",
|
123
|
+
:consumer_key => 'YOUR_CONSUMER_KEY',
|
124
|
+
:consumer_secret => 'YOUR_CONSUMER_SECRET',
|
125
|
+
:token => 'YOUR_TOKEN',
|
126
|
+
:token_secret => 'YOUR_TOKEN_SECRET')
|
115
127
|
response = client.search(request)
|
116
128
|
|
129
|
+
# -------------------------------------------------------
|
130
|
+
|
131
|
+
include Yelp::V2::Search::Request
|
117
132
|
# search for businesses via bounding box geo coords'
|
118
|
-
request =
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
133
|
+
request = BoundingBox.new(
|
134
|
+
:term => "cream puffs",
|
135
|
+
:sw_latitude => 37.900000,
|
136
|
+
:sw_longitude => -122.500000,
|
137
|
+
:ne_latitude => 37.788022,
|
138
|
+
:ne_longitude => -122.399797,
|
139
|
+
:limit => 3,
|
140
|
+
:consumer_key => 'YOUR_CONSUMER_KEY',
|
141
|
+
:consumer_secret => 'YOUR_CONSUMER_SECRET',
|
142
|
+
:token => 'YOUR_TOKEN',
|
143
|
+
:token_secret => 'YOUR_TOKEN_SECRET')
|
129
144
|
response = client.search(request)
|
130
145
|
|
131
146
|
# search for businesses via lat/long geo point'
|
132
|
-
request =
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
147
|
+
request = GeoPoint.new(
|
148
|
+
:term => "cream puffs",
|
149
|
+
:latitude => 37.788022,
|
150
|
+
:longitude => -122.399797,
|
151
|
+
:consumer_key => 'YOUR_CONSUMER_KEY',
|
152
|
+
:consumer_secret => 'YOUR_CONSUMER_SECRET',
|
153
|
+
:token => 'YOUR_TOKEN',
|
154
|
+
:token_secret => 'YOUR_TOKEN_SECRET')
|
140
155
|
response = client.search(request)
|
141
156
|
|
142
157
|
# search for businesses via location (address, neighbourhood, city, state, zip, country, latitude, longitude)'
|
143
|
-
request =
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
158
|
+
request = Location.new(
|
159
|
+
:term => "cream puffs",
|
160
|
+
:city => "San Francisco",
|
161
|
+
:consumer_key => 'YOUR_CONSUMER_KEY',
|
162
|
+
:consumer_secret => 'YOUR_CONSUMER_SECRET',
|
163
|
+
:token => 'YOUR_TOKEN',
|
164
|
+
:token_secret => 'YOUR_TOKEN_SECRET')
|
150
165
|
response = client.search(request)
|
151
166
|
|
152
|
-
request =
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
167
|
+
request = Location.new(
|
168
|
+
:term => "german food",
|
169
|
+
:address => "Hayes",
|
170
|
+
:latitude => 37.77493,
|
171
|
+
:longitude => -122.419415,
|
172
|
+
:consumer_key => 'YOUR_CONSUMER_KEY',
|
173
|
+
:consumer_secret => 'YOUR_CONSUMER_SECRET',
|
174
|
+
:token => 'YOUR_TOKEN',
|
175
|
+
:token_secret => 'YOUR_TOKEN_SECRET')
|
161
176
|
response = client.search(request)
|
162
177
|
```
|
163
178
|
|
data/lib/yelpster.rb
CHANGED
data/lib/yelpster/client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'json'
|
5
5
|
require 'yaml'
|
6
6
|
|
7
|
-
|
7
|
+
module Yelp
|
8
8
|
# Provides access to the Yelp search facilities as documented at:
|
9
9
|
#
|
10
10
|
# http://www.yelp.com/developers/documentation
|
@@ -64,6 +64,7 @@ class Yelp
|
|
64
64
|
# http_request_params not used in v2 as OAuth (implemented in v2) only takes response params
|
65
65
|
http_params = { 'User-Agent' => @agent }
|
66
66
|
http_params['Accept-Encoding'] = 'gzip,deflate' if request.compress_response?
|
67
|
+
http_params[:proxy] = nil
|
67
68
|
content = request.pull_results(url, http_params)
|
68
69
|
|
69
70
|
# read the response content
|
@@ -90,10 +91,10 @@ class Yelp
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def to_query_string(params)
|
93
|
-
params.delete_if { |_, v| v.nil? }
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
params.delete_if { |_, v| v.nil? }.
|
95
|
+
to_a.
|
96
|
+
map { |key, value| "#{escape(key)}=#{escape(value)}" }.
|
97
|
+
join('&')
|
97
98
|
end
|
98
99
|
|
99
100
|
def escape(object)
|
data/lib/yelpster/record.rb
CHANGED
data/lib/yelpster/v1/request.rb
CHANGED
data/lib/yelpster/v2/request.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Yelp::V2::Business::Request
|
4
|
+
describe Id do
|
5
|
+
let!(:client) { create_client(AdditionalSpecHelpers::API_V2) }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
subject do
|
8
|
+
client.search(Id.new(
|
9
|
+
:yelp_business_id => 'pjb2WMwa0AfK3L-dWimO8w',
|
10
|
+
:consumer_key => @consumer_key,
|
11
|
+
:consumer_secret => @consumer_secret,
|
12
|
+
:token => @token,
|
13
|
+
:token_secret => @token_secret))
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
it 'returns a valid business hash' do
|
17
|
+
subject.should be_valid_business_hash
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
it 'returns the correct business' do
|
21
|
+
expect(subject['id']).to eq('chocolate-san-francisco')
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
@@ -1,65 +1,67 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
module Yelp::V2::Search::Request
|
4
|
+
describe 'Business Search' do
|
5
|
+
let!(:client) { create_client(AdditionalSpecHelpers::API_V2) }
|
6
|
+
let(:latitude) { 37.782303 }
|
7
|
+
let(:longitude) { -122.484101 }
|
8
|
+
let(:location) { {
|
9
|
+
'cross_streets' => '24th Ave & 25th Ave',
|
10
|
+
'city' => 'San Francisco',
|
11
|
+
'display_address' => ['2308 Clement St', '(b/t 24th Ave & 25th Ave)', 'Outer Richmond', 'San Francisco, CA 94121'],
|
12
|
+
'geo_accuracy' => 8,
|
13
|
+
'neighborhoods' => ['Outer Richmond'],
|
14
|
+
'postal_code' => '94121',
|
15
|
+
'country_code' => 'US',
|
16
|
+
'address' => ['2308 Clement St'],
|
17
|
+
'coordinate' => {'latitude' => latitude, 'longitude' => longitude},
|
18
|
+
'state_code' => 'CA'
|
19
|
+
} }
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
describe 'by Bounding Box' do
|
22
|
+
it 'returns businesses within a bounding box' do
|
23
|
+
request = BoundingBox.new(
|
24
|
+
:sw_latitude => 37.9,
|
25
|
+
:sw_longitude => -122.5,
|
26
|
+
:ne_latitude => 37.788022,
|
27
|
+
:ne_longitude => -122.399797,
|
28
|
+
:term => 'yelp',
|
29
|
+
:consumer_key => @consumer_key,
|
30
|
+
:consumer_secret => @consumer_secret,
|
31
|
+
:token => @token,
|
32
|
+
:token_secret => @token_secret)
|
33
|
+
expect(client.search(request)).to be_valid_response_hash
|
34
|
+
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
describe 'by GeoPoint' do
|
38
|
+
it 'returns business at geo point' do
|
39
|
+
request = GeoPoint.new(:latitude => latitude,
|
40
|
+
:longitude => longitude,
|
41
|
+
:consumer_key => @consumer_key,
|
42
|
+
:consumer_secret => @consumer_secret,
|
43
|
+
:token => @token,
|
44
|
+
:token_secret => @token_secret)
|
45
|
+
response = client.search(request)
|
46
|
+
expect(response).to be_valid_response_hash
|
47
|
+
expect(response['businesses'].first['location']).to eq(location)
|
48
|
+
end
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
describe 'by Location' do
|
52
|
+
it 'by Location' do
|
53
|
+
request = Location.new(:address => '2308 Clement St',
|
54
|
+
:city => 'San Francisco',
|
55
|
+
:state => 'CA',
|
56
|
+
:zipcode => 94121,
|
57
|
+
:consumer_key => @consumer_key,
|
58
|
+
:consumer_secret => @consumer_secret,
|
59
|
+
:token => @token,
|
60
|
+
:token_secret => @token_secret)
|
61
|
+
response = client.search(request)
|
62
|
+
expect(response).to be_valid_response_hash
|
63
|
+
expect(response['businesses'].first['location']['postal_code']).to eq('94121')
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
@@ -1,29 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Yelp::V1::Neighborhood::Request
|
4
|
+
describe 'Neighborhood Search' do
|
5
|
+
let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
describe 'by GeoPoint' do
|
8
|
+
it 'returns neighbourhoods at point' do
|
9
|
+
request = GeoPoint.new(:latitude => 37.782093,
|
10
|
+
:longitude => -122.483230,
|
11
|
+
:yws_id => @yws_id)
|
12
|
+
response = client.search(request)
|
13
|
+
expect(response).to be_valid_response_hash
|
14
|
+
expect(response['neighborhoods'].first['name']).to eq('Outer Richmond')
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
describe 'by Location' do
|
19
|
+
it 'returns neighbourhoods at location' do
|
20
|
+
request = Location.new(:address => '2252 Clement Street',
|
21
|
+
:city => 'San Francisco',
|
22
|
+
:state => 'CA',
|
23
|
+
:zipcode => 94121,
|
24
|
+
:yws_id => @yws_id)
|
25
|
+
response = client.search(request)
|
26
|
+
expect(response).to be_valid_response_hash
|
27
|
+
expect(response['neighborhoods'].first['name']).to eq('Outer Richmond')
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
data/spec/phone_search_spec.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Yelp::V1::Phone::Request
|
4
|
+
describe 'Search by phone number' do
|
5
|
+
let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
it 'returns business with specified phone number' do
|
8
|
+
request = Number.new(:phone_number => '4155666011', :yws_id => @yws_id)
|
9
|
+
expect(client.search(request)).to be_valid_response_hash
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
data/spec/review_search_spec.rb
CHANGED
@@ -1,145 +1,147 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
module Yelp::V1::Review::Request
|
4
|
+
describe 'Review Search' do
|
5
|
+
let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
|
6
|
+
|
7
|
+
describe 'by Bounding Box' do
|
8
|
+
it 'returns reviews in box' do
|
9
|
+
request = BoundingBox.new(
|
10
|
+
:bottom_right_latitude => 37.788022,
|
11
|
+
:bottom_right_longitude => -122.399797,
|
12
|
+
:top_left_latitude => 37.9,
|
13
|
+
:top_left_longitude => -122.5,
|
14
|
+
:term => 'yelp',
|
15
|
+
:yws_id => @yws_id)
|
16
|
+
expect(client.search(request)).to be_valid_response_hash
|
17
|
+
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
describe 'by GeoPoint' do
|
21
|
+
it 'returns reviews at point' do
|
22
|
+
request = GeoPoint.new(
|
23
|
+
:latitude => 37.78022,
|
24
|
+
:longitude => -122.399797,
|
25
|
+
:radius => 2,
|
26
|
+
:term => 'yelp',
|
27
|
+
:yws_id => @yws_id)
|
28
|
+
expect(client.search(request)).to be_valid_response_hash
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
describe 'by Location' do
|
33
|
+
it 'returns reviews at location' do
|
34
|
+
request = Location.new(
|
35
|
+
:address => '650 Mission St',
|
36
|
+
:city => 'San Francisco',
|
37
|
+
:state => 'CA',
|
38
|
+
:radius => 2,
|
39
|
+
:term => 'cream puffs',
|
40
|
+
:yws_id => @yws_id)
|
41
|
+
expect(client.search(request)).to be_valid_response_hash
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when filtered with category' do
|
46
|
+
it 'returns less results than unfiltered search' do
|
47
|
+
# perform a basic search of businesses near SOMA
|
48
|
+
request = GeoPoint.new(
|
49
|
+
:latitude => 37.78022,
|
50
|
+
:longitude => -122.399797,
|
51
|
+
:radius => 5,
|
52
|
+
:term => 'yelp',
|
53
|
+
:yws_id => @yws_id)
|
54
|
+
response = client.search(request)
|
55
|
+
|
56
|
+
# perform the same search focusing only on playgrounds
|
57
|
+
narrowed_request = GeoPoint.new(
|
58
|
+
:latitude => 37.78022,
|
59
|
+
:longitude => -122.399797,
|
60
|
+
:radius => 5,
|
61
|
+
:term => 'yelp',
|
62
|
+
:category => 'playgrounds',
|
63
|
+
:yws_id => @yws_id)
|
64
|
+
narrowed_response = client.search(narrowed_request)
|
65
|
+
|
66
|
+
# make sure we got less for the second
|
67
|
+
expect(response['businesses'].length).to be > narrowed_response['businesses'].length
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns valid json' do
|
72
|
+
request = basic_request(:response_format => Yelp::ResponseFormat::JSON)
|
73
|
+
expect(client.search(request)).to be_valid_json
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'returns valid ruby hash' do
|
77
|
+
request = basic_request(:response_format => Yelp::ResponseFormat::JSON_TO_RUBY)
|
40
78
|
expect(client.search(request)).to be_valid_response_hash
|
41
79
|
end
|
42
|
-
end
|
43
80
|
|
44
|
-
|
45
|
-
|
46
|
-
# perform a basic search of businesses near SOMA
|
47
|
-
request = Yelp::V1::Review::Request::GeoPoint.new(
|
48
|
-
:latitude => 37.78022,
|
49
|
-
:longitude => -122.399797,
|
50
|
-
:radius => 5,
|
51
|
-
:term => 'yelp',
|
52
|
-
:yws_id => @yws_id)
|
81
|
+
pending 'returns valid pickle' do
|
82
|
+
request = basic_request(:response_format => Yelp::ResponseFormat::PICKLE)
|
53
83
|
response = client.search(request)
|
84
|
+
# TODO: validation
|
85
|
+
end
|
54
86
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
:radius => 5,
|
60
|
-
:term => 'yelp',
|
61
|
-
:category => 'playgrounds',
|
62
|
-
:yws_id => @yws_id)
|
63
|
-
narrowed_response = client.search(narrowed_request)
|
64
|
-
|
65
|
-
# make sure we got less for the second
|
66
|
-
expect(response['businesses'].length).to be > narrowed_response['businesses'].length
|
87
|
+
pending 'returns valid php' do
|
88
|
+
request = basic_request(:response_format => Yelp::ResponseFormat::PHP)
|
89
|
+
response = client.search(request)
|
90
|
+
# TODO: validation
|
67
91
|
end
|
68
|
-
end
|
69
92
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
93
|
+
it 'returns multiple categories' do
|
94
|
+
# fetch results for only one category
|
95
|
+
params = {
|
96
|
+
:city => 'San Francisco',
|
97
|
+
:state => 'CA',
|
98
|
+
:yws_id => @yws_id,
|
99
|
+
:category => 'donuts'
|
100
|
+
}
|
101
|
+
request = Location.new(params)
|
102
|
+
response = client.search(request)
|
74
103
|
|
75
|
-
|
76
|
-
request = basic_request(:response_format => Yelp::ResponseFormat::JSON_TO_RUBY)
|
77
|
-
expect(client.search(request)).to be_valid_response_hash
|
78
|
-
end
|
104
|
+
expect(response).to be_valid_response_hash
|
79
105
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
106
|
+
# make sure all businesses returned have at least the specified category
|
107
|
+
response['businesses'].each do |b|
|
108
|
+
cat_exists = b['categories'].find { |c| c['category_filter'] == 'donuts' }
|
109
|
+
expect(cat_exists).to_not be_nil
|
110
|
+
end
|
85
111
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'returns multiple categories' do
|
93
|
-
# fetch results for only one category
|
94
|
-
params = {
|
95
|
-
:city => 'San Francisco',
|
96
|
-
:state => 'CA',
|
97
|
-
:yws_id => @yws_id,
|
98
|
-
:category => 'donuts'
|
99
|
-
}
|
100
|
-
request = Yelp::V1::Review::Request::Location.new(params)
|
101
|
-
response = client.search(request)
|
102
|
-
|
103
|
-
expect(response).to be_valid_response_hash
|
104
|
-
|
105
|
-
# make sure all businesses returned have at least the specified category
|
106
|
-
response['businesses'].each do |b|
|
107
|
-
cat_exists = b['categories'].find { |c| c['category_filter'] == 'donuts' }
|
108
|
-
expect(cat_exists).to_not be_nil
|
109
|
-
end
|
112
|
+
# now fetch for businesses with two categories
|
113
|
+
params[:category] = [ 'donuts', 'icecream' ]
|
114
|
+
request = Location.new(params)
|
115
|
+
response = client.search(request)
|
110
116
|
|
111
|
-
|
112
|
-
params[:category] = [ 'donuts', 'icecream' ]
|
113
|
-
request = Yelp::V1::Review::Request::Location.new(params)
|
114
|
-
response = client.search(request)
|
117
|
+
expect(response).to be_valid_response_hash
|
115
118
|
|
116
|
-
|
119
|
+
# make sure we have at least one of each specified category, and
|
120
|
+
# that each business has at least one
|
121
|
+
donut_count = 0
|
122
|
+
icecream_count = 0
|
123
|
+
response['businesses'].each do |b|
|
124
|
+
has_donut = b['categories'].find { |c| c['category_filter'] == 'donuts' }
|
125
|
+
has_icecream = b['categories'].find { |c| c['category_filter'] == 'icecream' }
|
117
126
|
|
118
|
-
|
119
|
-
|
120
|
-
donut_count = 0
|
121
|
-
icecream_count = 0
|
122
|
-
response['businesses'].each do |b|
|
123
|
-
has_donut = b['categories'].find { |c| c['category_filter'] == 'donuts' }
|
124
|
-
has_icecream = b['categories'].find { |c| c['category_filter'] == 'icecream' }
|
127
|
+
donut_count += 1 if has_donut
|
128
|
+
icecream_count += 1 if has_icecream
|
125
129
|
|
126
|
-
|
127
|
-
|
130
|
+
expect(has_donut || has_icecream).to_not be_nil
|
131
|
+
end
|
128
132
|
|
129
|
-
expect(
|
133
|
+
expect((donut_count > 0) && (icecream_count > 0)).to be_true
|
130
134
|
end
|
131
135
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
}
|
143
|
-
Yelp::V1::Review::Request::Location.new(default_params.merge(options))
|
136
|
+
private
|
137
|
+
def basic_request(options = {})
|
138
|
+
default_params = {
|
139
|
+
:city => 'San Francisco',
|
140
|
+
:state => 'CA',
|
141
|
+
:term => 'gordo',
|
142
|
+
:yws_id => @yws_id
|
143
|
+
}
|
144
|
+
Location.new(default_params.merge(options))
|
145
|
+
end
|
144
146
|
end
|
145
147
|
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yelpster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Naveed Siddiqui
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-29 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: json
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: oauth
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -65,6 +70,7 @@ files:
|
|
65
70
|
- lib/yelpster/v2/search/request/bounding_box.rb
|
66
71
|
- lib/yelpster/v2/search/request/geo_point.rb
|
67
72
|
- lib/yelpster/v2/search/request/location.rb
|
73
|
+
- lib/yelpster/version.rb
|
68
74
|
- lib/yelpster.rb
|
69
75
|
- spec/business_retrieve_spec.rb
|
70
76
|
- spec/business_search_spec.rb
|
@@ -76,26 +82,33 @@ files:
|
|
76
82
|
homepage: https://github.com/nvd/yelpster
|
77
83
|
licenses:
|
78
84
|
- LGPL
|
79
|
-
metadata: {}
|
80
85
|
post_install_message:
|
81
86
|
rdoc_options: []
|
82
87
|
require_paths:
|
83
88
|
- lib
|
84
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
85
91
|
requirements:
|
86
92
|
- - ! '>='
|
87
93
|
- !ruby/object:Gem::Version
|
88
94
|
version: '0'
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
hash: 1283160560018612419
|
89
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
90
100
|
requirements:
|
91
101
|
- - ! '>='
|
92
102
|
- !ruby/object:Gem::Version
|
93
103
|
version: '0'
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
hash: 1283160560018612419
|
94
107
|
requirements: []
|
95
108
|
rubyforge_project:
|
96
|
-
rubygems_version:
|
109
|
+
rubygems_version: 1.8.23
|
97
110
|
signing_key:
|
98
|
-
specification_version:
|
111
|
+
specification_version: 3
|
99
112
|
summary: Wrapper for Yelp Developer API
|
100
113
|
test_files:
|
101
114
|
- spec/business_retrieve_spec.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
MDhiOTVjZGU2NWRiMTI1ZjU4OGJjMWVmOWI5MWMxNTZhMGVmODA5Yg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmUyZjBmNmUzZTJkMjE1M2QyMzUzNjNkZTA1Y2VkMmVhMTJhMTFjNQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
OTc2MzAyOTdhN2I4NWFmMTA1OTUyYzI3MDc0ZDdiNGRkMWNmNjg5NDA0ODI1
|
10
|
-
Zjc5OWZlOTQxYzNlZWNjNmQ4NmJhOWJhOGMyOTliZjY0ZjRmMzdkNDExNWQ0
|
11
|
-
MWIxMmE1MDdiZDk1MjE4ZjIzNDc5NzA5ODQxYWRiOGNhYzQ1ZTQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YTg4Mzc5MGIwYWRjMzNjMDEyYzhjODdkODZkYzU1ZGNjYzQ3NGQzMjAyMzNl
|
14
|
-
NzU3ZGU0ZTRlZGQyODIwNmY1MGEzODc5ZjY1NmJhYWI3MmNjOTJlZTdjNzYz
|
15
|
-
M2QzYjU5OWVmOGFiNzM3ODcwNjVjM2ZhODY4N2IwMWE5MTI0MjU=
|