yelpster 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+ [![Build Status](https://travis-ci.org/nvd/yelpster.png?branch=develop)](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 +search+ method to make requests of
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 +response_format+ parameter, available in all request record
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 = Yelp::V1::Review::Request::Location.new(
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 = Yelp::V1::Review::Request::Location.new(
94
+ request = Location.new(
89
95
  :city => 'San Francisco',
90
96
  :state => 'CA',
91
- :category => [ 'donuts', 'icecream' ],
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 = Yelp::V1::Neighborhood::Request::GeoPoint.new(
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 = Yelp::V1::Phone::Request::Number.new(
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 = Yelp::V2::Business::Request::Id.new(
110
- :yelp_business_id => "pjb2WMwa0AfK3L-dWimO8w",
111
- :consumer_key => 'YOUR_CONSUMER_KEY',
112
- :consumer_secret => 'YOUR_CONSUMER_SECRET',
113
- :token => 'YOUR_TOKEN',
114
- :token_secret => 'YOUR_TOKEN_SECRET')
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 = Yelp::V2::Search::Request::BoundingBox.new(
119
- :term => "cream puffs",
120
- :sw_latitude => 37.900000,
121
- :sw_longitude => -122.500000,
122
- :ne_latitude => 37.788022,
123
- :ne_longitude => -122.399797,
124
- :limit => 3,
125
- :consumer_key => 'YOUR_CONSUMER_KEY',
126
- :consumer_secret => 'YOUR_CONSUMER_SECRET',
127
- :token => 'YOUR_TOKEN',
128
- :token_secret => 'YOUR_TOKEN_SECRET')
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 = Yelp::V2::Search::Request::GeoPoint.new(
133
- :term => "cream puffs",
134
- :latitude => 37.788022,
135
- :longitude => -122.399797,
136
- :consumer_key => 'YOUR_CONSUMER_KEY',
137
- :consumer_secret => 'YOUR_CONSUMER_SECRET',
138
- :token => 'YOUR_TOKEN',
139
- :token_secret => 'YOUR_TOKEN_SECRET')
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 = Yelp::V2::Search::Request::Location.new(
144
- :term => "cream puffs",
145
- :city => "San Francisco",
146
- :consumer_key => 'YOUR_CONSUMER_KEY',
147
- :consumer_secret => 'YOUR_CONSUMER_SECRET',
148
- :token => 'YOUR_TOKEN',
149
- :token_secret => 'YOUR_TOKEN_SECRET')
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 = Yelp::V2::Search::Request::Location.new(
153
- :term => "german food",
154
- :address => "Hayes",
155
- :latitude => 37.77493,
156
- :longitude => -122.419415,
157
- :consumer_key => 'YOUR_CONSUMER_KEY',
158
- :consumer_secret => 'YOUR_CONSUMER_SECRET',
159
- :token => 'YOUR_TOKEN',
160
- :token_secret => 'YOUR_TOKEN_SECRET')
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
 
@@ -18,7 +18,3 @@ require 'yelpster/v2/search/request/base'
18
18
  require 'yelpster/v2/search/request/geo_point'
19
19
  require 'yelpster/v2/search/request/bounding_box'
20
20
  require 'yelpster/v2/search/request/location'
21
-
22
- class Yelp
23
- VERSION = '1.1.3'
24
- end
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
  require 'json'
5
5
  require 'yaml'
6
6
 
7
- class Yelp
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
- .to_a
95
- .map { |key, value| "#{escape(key)}=#{escape(value)}" }
96
- .join('&')
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)
@@ -1,4 +1,4 @@
1
- class Yelp
1
+ module Yelp
2
2
  # General-purpose record that allows passing a hash with parameters
3
3
  # to populate object attributes defined via methods like
4
4
  # +attr_reader+ or +attr_accessor+.
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/record'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  # Describes the available response formats when querying the Yelp web
5
5
  # service for results.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/request'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Neighborhood
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/neighborhood/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Neighborhood
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/neighborhood/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Neighborhood
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/request'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Phone
6
6
  module Request
@@ -2,7 +2,7 @@ require 'yelpster/record'
2
2
  require 'open-uri'
3
3
  require 'zlib'
4
4
 
5
- class Yelp
5
+ module Yelp
6
6
  module V1
7
7
  class Request < Yelp::Record
8
8
  # specifies whether the response content should be transmitted
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/request'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Review
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/review/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Review
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/review/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Review
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v1/review/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V1
5
5
  module Review
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v2/request'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V2
5
5
  module Business
6
6
  module Request
@@ -1,7 +1,7 @@
1
1
  require 'yelpster/record'
2
2
  require 'oauth'
3
3
 
4
- class Yelp
4
+ module Yelp
5
5
  module V2
6
6
  class Request < Yelp::Record
7
7
  # specifies whether the response content should be transmitted
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v2/request'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V2
5
5
  module Search
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v2/search/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V2
5
5
  module Search
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v2/search/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V2
5
5
  module Search
6
6
  module Request
@@ -1,6 +1,6 @@
1
1
  require 'yelpster/v2/search/request/base'
2
2
 
3
- class Yelp
3
+ module Yelp
4
4
  module V2
5
5
  module Search
6
6
  module Request
@@ -0,0 +1,3 @@
1
+ module Yelp
2
+ VERSION = '1.1.4'.freeze
3
+ end
@@ -1,22 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Find Business by Id' do
4
- let!(:client) { create_client(AdditionalSpecHelpers::API_V2) }
3
+ module Yelp::V2::Business::Request
4
+ describe Id do
5
+ let!(:client) { create_client(AdditionalSpecHelpers::API_V2) }
5
6
 
6
- subject do
7
- client.search(Yelp::V2::Business::Request::Id.new(
8
- :yelp_business_id => 'pjb2WMwa0AfK3L-dWimO8w',
9
- :consumer_key => @consumer_key,
10
- :consumer_secret => @consumer_secret,
11
- :token => @token,
12
- :token_secret => @token_secret))
13
- end
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
- it 'returns a valid business hash' do
16
- subject.should be_valid_business_hash
17
- end
16
+ it 'returns a valid business hash' do
17
+ subject.should be_valid_business_hash
18
+ end
18
19
 
19
- it 'returns the correct business' do
20
- expect(subject['id']).to eq('chocolate-san-francisco')
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
- describe 'Business Search' do
4
- let!(:client) { create_client(AdditionalSpecHelpers::API_V2) }
5
- let(:latitude) { 37.782303 }
6
- let(:longitude) { -122.484101 }
7
- let(:location) { {
8
- 'cross_streets' => '24th Ave & 25th Ave',
9
- 'city' => 'San Francisco',
10
- 'display_address' => ['2308 Clement St', '(b/t 24th Ave & 25th Ave)', 'Outer Richmond', 'San Francisco, CA 94121'],
11
- 'geo_accuracy' => 8,
12
- 'neighborhoods' => ['Outer Richmond'],
13
- 'postal_code' => '94121',
14
- 'country_code' => 'US',
15
- 'address' => ['2308 Clement St'],
16
- 'coordinate' => {'latitude' => latitude, 'longitude' => longitude},
17
- 'state_code' => 'CA'
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
- describe 'by Bounding Box' do
21
- it 'returns businesses within a bounding box' do
22
- request = Yelp::V2::Search::Request::BoundingBox.new(
23
- sw_latitude: 37.9,
24
- sw_longitude: -122.5,
25
- ne_latitude: 37.788022,
26
- ne_longitude: -122.399797,
27
- term: 'yelp',
28
- consumer_key: @consumer_key,
29
- consumer_secret: @consumer_secret,
30
- token: @token,
31
- token_secret: @token_secret)
32
- expect(client.search(request)).to be_valid_response_hash
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
- describe 'by GeoPoint' do
37
- it 'returns business at geo point' do
38
- request = Yelp::V2::Search::Request::GeoPoint.new(latitude: latitude,
39
- longitude: longitude,
40
- consumer_key: @consumer_key,
41
- consumer_secret: @consumer_secret,
42
- token: @token,
43
- token_secret: @token_secret)
44
- response = client.search(request)
45
- expect(response).to be_valid_response_hash
46
- expect(response['businesses'].first['location']).to eq(location)
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
- describe 'by Location' do
51
- it 'by Location' do
52
- request = Yelp::V2::Search::Request::Location.new(address: '2308 Clement St',
53
- city: 'San Francisco',
54
- state: 'CA',
55
- zipcode: 94121,
56
- consumer_key: @consumer_key,
57
- consumer_secret: @consumer_secret,
58
- token: @token,
59
- token_secret: @token_secret)
60
- response = client.search(request)
61
- expect(response).to be_valid_response_hash
62
- expect(response['businesses'].first['location']['postal_code']).to eq('94121')
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
- describe 'Neighborhood Search' do
4
- let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
3
+ module Yelp::V1::Neighborhood::Request
4
+ describe 'Neighborhood Search' do
5
+ let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
5
6
 
6
- describe 'by GeoPoint' do
7
- it 'returns neighbourhoods at point' do
8
- request = Yelp::V1::Neighborhood::Request::GeoPoint.new(:latitude => 37.782093,
9
- :longitude => -122.483230,
10
- :yws_id => @yws_id)
11
- response = client.search(request)
12
- expect(response).to be_valid_response_hash
13
- expect(response['neighborhoods'].first['name']).to eq('Outer Richmond')
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
- describe 'by Location' do
18
- it 'returns neighbourhoods at location' do
19
- request = Yelp::V1::Neighborhood::Request::Location.new(:address => '2252 Clement Street',
20
- :city => 'San Francisco',
21
- :state => 'CA',
22
- :zipcode => 94121,
23
- :yws_id => @yws_id)
24
- response = client.search(request)
25
- expect(response).to be_valid_response_hash
26
- expect(response['neighborhoods'].first['name']).to eq('Outer Richmond')
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
@@ -1,10 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Search by phone number' do
4
- let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
3
+ module Yelp::V1::Phone::Request
4
+ describe 'Search by phone number' do
5
+ let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
5
6
 
6
- it 'returns business with specified phone number' do
7
- request = Yelp::V1::Phone::Request::Number.new(phone_number: '4155666011', yws_id: @yws_id)
8
- expect(client.search(request)).to be_valid_response_hash
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
@@ -1,145 +1,147 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Review Search' do
4
- let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
5
-
6
- describe 'by Bounding Box' do
7
- it 'returns reviews in box' do
8
- request = Yelp::V1::Review::Request::BoundingBox.new(
9
- :bottom_right_latitude => 37.788022,
10
- :bottom_right_longitude => -122.399797,
11
- :top_left_latitude => 37.9,
12
- :top_left_longitude => -122.5,
13
- :term => 'yelp',
14
- :yws_id => @yws_id)
15
- expect(client.search(request)).to be_valid_response_hash
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
- describe 'by GeoPoint' do
20
- it 'returns reviews at point' do
21
- request = Yelp::V1::Review::Request::GeoPoint.new(
22
- :latitude => 37.78022,
23
- :longitude => -122.399797,
24
- :radius => 2,
25
- :term => 'yelp',
26
- :yws_id => @yws_id)
27
- expect(client.search(request)).to be_valid_response_hash
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
- describe 'by Location' do
32
- it 'returns reviews at location' do
33
- request = Yelp::V1::Review::Request::Location.new(
34
- :address => '650 Mission St',
35
- :city => 'San Francisco',
36
- :state => 'CA',
37
- :radius => 2,
38
- :term => 'cream puffs',
39
- :yws_id => @yws_id)
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
- context 'when filtered with category' do
45
- it 'returns less results than unfiltered search' do
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
- # perform the same search focusing only on playgrounds
56
- narrowed_request = Yelp::V1::Review::Request::GeoPoint.new(
57
- :latitude => 37.78022,
58
- :longitude => -122.399797,
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
- it 'returns valid json' do
71
- request = basic_request(:response_format => Yelp::ResponseFormat::JSON)
72
- expect(client.search(request)).to be_valid_json
73
- end
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
- it 'returns valid ruby hash' do
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
- pending 'returns valid pickle' do
81
- request = basic_request(:response_format => Yelp::ResponseFormat::PICKLE)
82
- response = client.search(request)
83
- # TODO: validation
84
- end
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
- pending 'returns valid php' do
87
- request = basic_request(:response_format => Yelp::ResponseFormat::PHP)
88
- response = client.search(request)
89
- # TODO: validation
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
- # now fetch for businesses with two categories
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
- expect(response).to be_valid_response_hash
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
- # make sure we have at least one of each specified category, and
119
- # that each business has at least one
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
- donut_count += 1 if has_donut
127
- icecream_count += 1 if has_icecream
130
+ expect(has_donut || has_icecream).to_not be_nil
131
+ end
128
132
 
129
- expect(has_donut || has_icecream).to_not be_nil
133
+ expect((donut_count > 0) && (icecream_count > 0)).to be_true
130
134
  end
131
135
 
132
- expect((donut_count > 0) && (icecream_count > 0)).to be_true
133
- end
134
-
135
- private
136
- def basic_request(options = {})
137
- default_params = {
138
- :city => 'San Francisco',
139
- :state => 'CA',
140
- :term => 'gordo',
141
- :yws_id => @yws_id
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.3
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-08 00:00:00.000000000 Z
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: 2.0.3
109
+ rubygems_version: 1.8.23
97
110
  signing_key:
98
- specification_version: 4
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=