yelpster 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTBmZGM4MzdmNGI0OGRiNjRiNjc4YzEzYTJlZmJkZDg1ZTc5NTJlMQ==
5
+ data.tar.gz: !binary |-
6
+ OTY2NmY2ZjJlMGMxY2EwMDM3MzkzODE4NTI0ZDhjYzRkYWJiOThmMw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MWUxYzViMTVjNWM1NGMyZTk3ZmMzODYyYTAxMTFlOTY4MTZkMmQ2MWQ3MDAy
10
+ NDZlNDE1NWQ3OWU4YzY0MmY4NTRhNmY0MDNkMDQ1ZTBmZWU0YmUwYjI2M2Mw
11
+ MmM0MGJjMjllODY3ZGQ3OWViNjZkNGI4MTczYTEzZjk4YzlkZTM=
12
+ data.tar.gz: !binary |-
13
+ YWU0MWJmMTU2NjIxOWM3ZjM0NzFlM2UyN2MyZmZhMTc5ZGZmNGY0NWI3M2Fl
14
+ NjkyNDhlNDNlNWY1ZmIyYjczOTZjYzk3ZjRlMzUzZDgzYjcyN2EwNTdiN2M3
15
+ OWMzYTA0NmJmYWExNDFhMDNmN2EwYTY0NGE1Njk0MTJhNGEwYjY=
@@ -1,4 +1,11 @@
1
- == YELP_20111013_1_1_1
1
+ == YELPSTER_20130429_1_1_2
2
+ * [naveed] switched testing and deployment libraries
3
+
4
+ * [naveed] Add deals_filter in business search
5
+
6
+ * [naveed] Remove claimed_filter in business search
7
+
8
+ == YELPSTER_20111013_1_1_1
2
9
  * [naveed]
3
10
  - updated Rakefile (removed hoe; added echoe for building)
4
11
  - Renamed 'yelp.rb' to 'yelpster.rb'
@@ -1,13 +1,4 @@
1
- This is an expansion of the yelp api ruby gem written by Walter Korman. The gem has been extended to support version 2 of the yelp api. V2 supports business details retrieval via yelp id as well as searches for businesses using geo-point, bounding box or address/location. It also uses OAuth for authorization of requests.
2
-
3
- NOTE: Use of this code will break legacy code. You need to update all existing references to Yelp::Request::.. with Yelp::V1::Request::... Check out sample usage section for more information.
4
-
5
- The source for the original gem can be found here: http://github.com/shaper/yelp
6
- Following is the updated extract of the readme file.
7
-
8
- --------------------------------------------------------------------------------
9
-
10
- == yelp
1
+ == Yelpster
11
2
 
12
3
  A Ruby object-oriented interface to the local business content available
13
4
  on Yelp at http://www.yelp.com. Functionality is provided to perform
@@ -25,22 +16,6 @@ The RubyForge project is hosted at http://rubyforge.org/projects/yelpster. This
25
16
 
26
17
  The latest source code is at http://github.com/nvd/yelpster.
27
18
 
28
- == About
29
-
30
- Everybody loves Yelp! For those seeking burritos in the Mission District of
31
- San Francisco, it's easy to feel awash in a sea of taquerias with little to go
32
- on for decision-making other than whether the rice has peas in it (generally a
33
- negatory data point) or how long the line happens to be around lunchtime.
34
-
35
- Worry no longer! Yelp is here.
36
-
37
- Why should you use this library rather than writing directly to their API, or rolling your own? A few reasons that come to mind:
38
-
39
- * we've done a variety of mini-legwork from which you, Yelp and our fellow netizens will benefit, such as making sure we inform the Yelp server that we support gzipped data over the wire to save on bandwidth.
40
- * we have rudimentary tests, whereas your implementation doesn't (since you haven't even written it yet).
41
- * we return responses (by default, configurable) as JSON data converted into a Ruby hash and appropriate data types where applicable.
42
- * (subjective but we know we're right) -- we think our API is a nicer layer for Ruby developers to work with than the bare-bones REST API that Yelp provides.
43
-
44
19
  == Requirements
45
20
 
46
21
  You must have a Yelp Web Service ID (YWSID) if you're using v1 of the api or Consumer Key, Consumer Secret, Token and a Token Secret for version 2. These are available at http://www.yelp.com/developers/getting_started/api_access.
@@ -48,26 +23,20 @@ You must have a Yelp Web Service ID (YWSID) if you're using v1 of the api or Con
48
23
  You must conform to the Yelp Branding Requirements when making use of content
49
24
  retrieved via their API, documented at http://www.yelp.com/developers/getting_started/api_branding.
50
25
 
51
- For tests to execute successfully you must have the YWSID (for v1) or CONSUMER_KEY, CONSUMER_SECRET, TOKEN and TOKEN_SECRET(for v2) set in your environment via (shell-dependent, bash example provided):
26
+ For tests to execute successfully you must have the YWSID (for v1) or YELP_CONSUMER_KEY, YELP_CONSUMER_SECRET, YELP_TOKEN and YELP_TOKEN_SECRET(for v2) set in your environment via (shell-dependent, bash example provided):
52
27
 
53
28
  % export YWSID='YOUR_ID_HERE'
54
29
 
55
30
  or
56
31
 
57
- % export CONSUMER_KEY='YOUR_CONSUMER_KEY_HERE'
58
- % export CONSUMER_SECRET='YOUR_CONSUMER_SECRET_HERE'
59
- % export TOKEN='YOUR_TOKEN_HERE'
60
- % export TOKEN_SECRET='YOUR_TOKEN_SECRET_HERE'
32
+ % export YELP_CONSUMER_KEY='YOUR_CONSUMER_KEY_HERE'
33
+ % export YELP_CONSUMER_SECRET='YOUR_CONSUMER_SECRET_HERE'
34
+ % export YELP_PTOKEN='YOUR_TOKEN_HERE'
35
+ % export YELPP_TOKEN_SECRET='YOUR_TOKEN_SECRET_HERE'
61
36
 
62
37
  == Installing
63
38
 
64
- NOTE: At the moment, this source (and support for yelp api v2) has not been incorporated into the original gem. You can install the original gem following the instructions below
65
-
66
- Install +rubygems+ if you don't already have it. See http://rubyforge.org/projects/rubygems/.
67
-
68
- Then install the +yelp+ gem by executing:
69
-
70
- % gem install yelp
39
+ % gem install yelpster
71
40
 
72
41
  == Usage
73
42
 
@@ -20,5 +20,5 @@ require 'yelpster/v2/search/request/bounding_box'
20
20
  require 'yelpster/v2/search/request/location'
21
21
 
22
22
  class Yelp
23
- VERSION = '1.1.1'
23
+ VERSION = '1.1.2'
24
24
  end
@@ -32,9 +32,8 @@ class Yelp
32
32
  # integer specifying the search radius in meters
33
33
  attr_reader :radius_filter
34
34
 
35
- # boolean representing if business has claimed location
36
- # not implemented by yelp as of 13-8-2011
37
- attr_reader :claimed_filter
35
+ # boolean representing if business has a deal available
36
+ attr_reader :deals_filter
38
37
  #---------------------------------------------------------------
39
38
 
40
39
  #--------------------------- Locale Params ---------------------
@@ -56,8 +55,7 @@ class Yelp
56
55
  :sort => sort,
57
56
  :category_filter => category_filter,
58
57
  :radius_filter => radius_filter,
59
- :claimed_filter => claimed_filter,
60
-
58
+ :deals_filter => deals_filter,
61
59
  :cc => cc,
62
60
  :lang => lang)
63
61
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Find Business by Id' do
4
+ let!(:client) { create_client(AdditionalSpecHelpers::API_V2) }
5
+
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
14
+
15
+ it 'returns a valid business hash' do
16
+ subject.should be_valid_business_hash
17
+ end
18
+
19
+ it 'returns the correct business' do
20
+ expect(subject['id']).to eq('chocolate-san-francisco')
21
+ end
22
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
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
+ } }
19
+
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
33
+ end
34
+ end
35
+
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)
47
+ end
48
+ end
49
+
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')
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yelp::Client do
4
+ it 'creates a new client' do
5
+ expect { Yelp::Client.new }.to_not raise_error
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Neighborhood Search' do
4
+ let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
5
+
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')
14
+ end
15
+ end
16
+
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')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Search by phone number' do
4
+ let!(:client) { create_client(AdditionalSpecHelpers::API_V1) }
5
+
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
9
+ end
10
+ end
@@ -0,0 +1,145 @@
1
+ require 'spec_helper'
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
16
+ end
17
+ end
18
+
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
28
+ end
29
+ end
30
+
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)
40
+ expect(client.search(request)).to be_valid_response_hash
41
+ end
42
+ end
43
+
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)
53
+ response = client.search(request)
54
+
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
67
+ end
68
+ end
69
+
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
74
+
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
79
+
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
85
+
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
110
+
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)
115
+
116
+ expect(response).to be_valid_response_hash
117
+
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' }
125
+
126
+ donut_count += 1 if has_donut
127
+ icecream_count += 1 if has_icecream
128
+
129
+ expect(has_donut || has_icecream).to_not be_nil
130
+ end
131
+
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))
144
+ end
145
+ end
@@ -0,0 +1,73 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require 'rspec/autorun'
3
+ require 'yelpster'
4
+ require 'json'
5
+
6
+ module AdditionalSpecHelpers
7
+ API_V1 = 'v1'
8
+ API_V2 = 'v2'
9
+
10
+ def create_client(api_ver)
11
+ client = Yelp::Client.new
12
+
13
+ case api_ver
14
+ when API_V1
15
+ ENV['YWSID'].should_not be_nil, "Missing YWSID. Obtain from http://www.yelp.com/developers and set in your shell environment under 'YWSID'."
16
+ @yws_id = ENV['YWSID']
17
+ when API_V2
18
+ ENV['YELP_CONSUMER_KEY'].should_not be_nil, "Missing YELP_CONSUMER_KEY. Obtain from http://www.yelp.com/developers and set in your shell environment under 'YELP_CONSUMER_KEY'."
19
+ @consumer_key = ENV['YELP_CONSUMER_KEY']
20
+
21
+ ENV['YELP_CONSUMER_SECRET'].should_not be_nil, "Missing YELP_CONSUMER_SECRET. Obtain from http://www.yelp.com/developers and set in your shell environment under 'YELP_CONSUMER_SECRET'."
22
+ @consumer_secret = ENV['YELP_CONSUMER_SECRET']
23
+
24
+ ENV['YELP_TOKEN'].should_not be_nil, "Missing YELP_TOKEN. Obtain from http://www.yelp.com/developers and set in your shell environment under 'YELP_TOKEN'."
25
+ @token = ENV['YELP_TOKEN']
26
+
27
+ ENV['YELP_TOKEN_SECRET'].should_not be_nil, "Missing YELP_TOKEN_SECRET. Obtain from http://www.yelp.com/developers and set in your shell environment under 'YELP_TOKEN_SECRET'."
28
+ @token_secret = ENV['YELP_TOKEN_SECRET']
29
+ else
30
+ assert_false('No api version specified in test case; cannot continue')
31
+ end
32
+ # client.debug = true
33
+ client
34
+ end
35
+
36
+ end
37
+
38
+ #TODO: These matchers are quite lame and need to meaningfully test
39
+ # No point in testing ruby conversion of json to hashes
40
+
41
+ RSpec::Matchers.define :be_valid_json do
42
+ match do |actual|
43
+ begin
44
+ JSON.parse(actual) && true
45
+ rescue JSON::ParserError
46
+ false
47
+ end
48
+ end
49
+ end
50
+
51
+ RSpec::Matchers.define :be_valid_business_hash do
52
+ match do |business|
53
+ expect(business['id'].length).to be > 0
54
+ expect(business['url']).to match_regex(/^https?:\/\/[a-z0-9]/i)
55
+ end
56
+ end
57
+
58
+ RSpec::Matchers.define :be_valid_response_hash do
59
+ match do |response|
60
+ expect(response).to_not be_nil
61
+ expect(response['businesses'] || response['neighborhoods']).to_not be_nil
62
+ if(response['businesses'])
63
+ # TODO: loop in a test? - should just pick one if at all
64
+ response['businesses'].each { |b| expect(b).to be_valid_business_hash }
65
+ else
66
+ true
67
+ end
68
+ end
69
+ end
70
+
71
+ RSpec.configure do |config|
72
+ config.include AdditionalSpecHelpers
73
+ end
metadata CHANGED
@@ -1,76 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: yelpster
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.2
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Naveed Siddiqui
9
8
  autorequire:
10
9
  bindir: bin
11
- cert_chain:
12
- - |
13
- -----BEGIN CERTIFICATE-----
14
- MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMQ8wDQYDVQQDDAZuYXZl
15
- ZWQxGjAYBgoJkiaJk/IsZAEZFgoxMGVpZ2h0ZWVuMRMwEQYKCZImiZPyLGQBGRYD
16
- Y29tMB4XDTExMTAxMzE0MTg0NloXDTEyMTAxMjE0MTg0NlowQjEPMA0GA1UEAwwG
17
- bmF2ZWVkMRowGAYKCZImiZPyLGQBGRYKMTBlaWdodGVlbjETMBEGCgmSJomT8ixk
18
- ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM/MW7owmvsy
19
- BlEVc5yDWxLMWQvK6igewl4YBienALpPzcVnLEcYVS9gQIGbx4weiw3gNMm+6keY
20
- lFYFOzu29KvYQrmc8QqSfLq8r8hRe/3Lcx4fQdZHQuoPtvZ7YOZSAGRIQuBont9W
21
- 8VVgbF8KjDj1IUFi/YI+VfMXD4xypyXC8mzaEaHFpquM9GKh46++s382IBOv2sZV
22
- UNVBRvmHYkV+8ysGiH6vgwkNTTHC9+oHhXQYPQ51A+I1CI1jnMs5LRgwKiZ/L93G
23
- V8NbvR/CdKKbAtOs20QT60CMVOF5UsF9XTynu3+HRNYQ7eQirukp8275R5I3Geh8
24
- 2XtRv8hzO+MCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUGgYrXrTHBcRx
25
- IGkT4AgsUqHCPUIwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQDLI4Li
26
- SDEmqnyONx7uFK9vDnzr1crqRyK5F3HkFYLudCrtgpPz2PSHxg9z421rWp34n18Z
27
- E9mWA8SrBVAFmqH9zuj5TSmXKrO72157MdNy2MIIych8auu3CATZTVCFdGVkcYXx
28
- HyAiuqfHI73U1D0BWRz7ZzOnE2QqVBekmDLmEGZyiJUoQPSAFb1Zr7h8hKyPkHev
29
- 0iXzgNY1VjcdDGmhcbg86mk3sWk0AnVk3oLwxo+6r8lc+AuRT59edeRkxN7HA3zb
30
- ahJOnBb3+Ql5b9v2KMN1rct+SqTnjD+zEkVeGz9gW5zsRWvx1sbNCxgD6zQJ9SXH
31
- zztOQ91rVpCrfFhH
32
- -----END CERTIFICATE-----
33
-
34
- date: 2011-10-13 00:00:00 Z
35
- dependencies:
36
- - !ruby/object:Gem::Dependency
10
+ cert_chain: []
11
+ date: 2013-04-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
37
14
  name: json
38
- prerelease: false
39
- requirement: &id001 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
44
19
  version: 1.1.1
45
20
  type: :runtime
46
- version_requirements: *id001
47
- - !ruby/object:Gem::Dependency
48
- name: oauth
49
21
  prerelease: false
50
- requirement: &id002 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: oauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
55
33
  version: 0.4.5
56
34
  type: :runtime
57
- version_requirements: *id002
58
- description: |
59
- Extension of Korman's Ruby wrapper to interface with Yelp's REST API described in detail at:
60
-
61
- http://www.yelp.com/developers/getting_started
62
-
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.5
41
+ description: Wrapper for Yelp Developer API
63
42
  email: naveed@10eighteen.com
64
43
  executables: []
65
-
66
44
  extensions: []
67
-
68
- extra_rdoc_files:
45
+ extra_rdoc_files: []
46
+ files:
69
47
  - CHANGELOG.rdoc
70
48
  - LICENSE.txt
71
49
  - README.rdoc
72
- - TODO.txt
73
- - lib/yelpster.rb
74
50
  - lib/yelpster/client.rb
75
51
  - lib/yelpster/record.rb
76
52
  - lib/yelpster/response_format.rb
@@ -89,76 +65,43 @@ extra_rdoc_files:
89
65
  - lib/yelpster/v2/search/request/bounding_box.rb
90
66
  - lib/yelpster/v2/search/request/geo_point.rb
91
67
  - lib/yelpster/v2/search/request/location.rb
92
- files:
93
- - CHANGELOG.rdoc
94
- - LICENSE.txt
95
- - Manifest
96
- - README.rdoc
97
- - Rakefile
98
- - TODO.txt
99
68
  - lib/yelpster.rb
100
- - lib/yelpster/client.rb
101
- - lib/yelpster/record.rb
102
- - lib/yelpster/response_format.rb
103
- - lib/yelpster/v1/neighborhood/request/base.rb
104
- - lib/yelpster/v1/neighborhood/request/geo_point.rb
105
- - lib/yelpster/v1/neighborhood/request/location.rb
106
- - lib/yelpster/v1/phone/request/number.rb
107
- - lib/yelpster/v1/request.rb
108
- - lib/yelpster/v1/review/request/base.rb
109
- - lib/yelpster/v1/review/request/bounding_box.rb
110
- - lib/yelpster/v1/review/request/geo_point.rb
111
- - lib/yelpster/v1/review/request/location.rb
112
- - lib/yelpster/v2/business/request/id.rb
113
- - lib/yelpster/v2/request.rb
114
- - lib/yelpster/v2/search/request/base.rb
115
- - lib/yelpster/v2/search/request/bounding_box.rb
116
- - lib/yelpster/v2/search/request/geo_point.rb
117
- - lib/yelpster/v2/search/request/location.rb
118
- - test/test_business_retrieve.rb
119
- - test/test_business_search.rb
120
- - test/test_client.rb
121
- - test/test_neighborhood_search.rb
122
- - test/test_phone_search.rb
123
- - test/test_review_search.rb
124
- - test/yelp_helper.rb
125
- - yelpster.gemspec
69
+ - spec/business_retrieve_spec.rb
70
+ - spec/business_search_spec.rb
71
+ - spec/client_spec.rb
72
+ - spec/neighborhood_search_spec.rb
73
+ - spec/phone_search_spec.rb
74
+ - spec/review_search_spec.rb
75
+ - spec/spec_helper.rb
126
76
  homepage: https://github.com/nvd/yelpster
127
- licenses: []
128
-
77
+ licenses:
78
+ - LGPL
79
+ metadata: {}
129
80
  post_install_message:
130
- rdoc_options:
131
- - --line-numbers
132
- - --inline-source
133
- - --title
134
- - Yelpster
135
- - --main
136
- - README.rdoc
137
- require_paths:
81
+ rdoc_options: []
82
+ require_paths:
138
83
  - lib
139
- required_ruby_version: !ruby/object:Gem::Requirement
140
- none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: "0"
145
- required_rubygems_version: !ruby/object:Gem::Requirement
146
- none: false
147
- requirements:
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- version: "1.2"
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
151
94
  requirements: []
152
-
153
- rubyforge_project: yelpster
154
- rubygems_version: 1.8.11
95
+ rubyforge_project:
96
+ rubygems_version: 2.0.3
155
97
  signing_key:
156
- specification_version: 3
157
- summary: An object-oriented interface to the Yelp Developer API.
158
- test_files:
159
- - test/test_business_retrieve.rb
160
- - test/test_business_search.rb
161
- - test/test_client.rb
162
- - test/test_neighborhood_search.rb
163
- - test/test_phone_search.rb
164
- - test/test_review_search.rb
98
+ specification_version: 4
99
+ summary: Wrapper for Yelp Developer API
100
+ test_files:
101
+ - spec/business_retrieve_spec.rb
102
+ - spec/business_search_spec.rb
103
+ - spec/client_spec.rb
104
+ - spec/neighborhood_search_spec.rb
105
+ - spec/phone_search_spec.rb
106
+ - spec/review_search_spec.rb
107
+ - spec/spec_helper.rb
data.tar.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- ��� *㲣�=�ׁkJ���6��S$Q��2ғ����Rz�d{M� -W�_�.��f�-]@b�Q΄�W�=7S�V��ʢ�`Kx��X�u@ ��m���� �u���{�&h��� �eU|,+[�.�+���>C��s�W��Y�!��� �m�
2
- F��G�H��k��'�~v%£k>�M;�?쓞����>�����mq��VP�st*mԃE5o�5RP
3
- ��2W��9�<Ÿ9�.�@n��^�u)�
data/Manifest DELETED
@@ -1,32 +0,0 @@
1
- CHANGELOG.rdoc
2
- LICENSE.txt
3
- Manifest
4
- README.rdoc
5
- Rakefile
6
- TODO.txt
7
- lib/yelpster.rb
8
- lib/yelpster/client.rb
9
- lib/yelpster/record.rb
10
- lib/yelpster/response_format.rb
11
- lib/yelpster/v1/neighborhood/request/base.rb
12
- lib/yelpster/v1/neighborhood/request/geo_point.rb
13
- lib/yelpster/v1/neighborhood/request/location.rb
14
- lib/yelpster/v1/phone/request/number.rb
15
- lib/yelpster/v1/request.rb
16
- lib/yelpster/v1/review/request/base.rb
17
- lib/yelpster/v1/review/request/bounding_box.rb
18
- lib/yelpster/v1/review/request/geo_point.rb
19
- lib/yelpster/v1/review/request/location.rb
20
- lib/yelpster/v2/business/request/id.rb
21
- lib/yelpster/v2/request.rb
22
- lib/yelpster/v2/search/request/base.rb
23
- lib/yelpster/v2/search/request/bounding_box.rb
24
- lib/yelpster/v2/search/request/geo_point.rb
25
- lib/yelpster/v2/search/request/location.rb
26
- test/test_business_retrieve.rb
27
- test/test_business_search.rb
28
- test/test_client.rb
29
- test/test_neighborhood_search.rb
30
- test/test_phone_search.rb
31
- test/test_review_search.rb
32
- test/yelp_helper.rb
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
4
- $:.unshift(File.dirname(__FILE__) + "/lib")
5
- require 'yelpster'
6
-
7
- Echoe.new('yelpster', Yelp::VERSION) do |p|
8
- p.author = 'Naveed Siddiqui'
9
- p.email = 'naveed@10eighteen.com'
10
- p.url = 'https://github.com/nvd/yelpster'
11
- p.summary = 'An object-oriented interface to the Yelp Developer API.'
12
- p.description = <<EDOC
13
- Extension of Korman's Ruby wrapper to interface with Yelp's REST API described in detail at:
14
-
15
- http://www.yelp.com/developers/getting_started
16
- EDOC
17
- p.ignore_pattern = ["tmp/*", "script/*"]
18
- p.runtime_dependencies = [ 'json >=1.1.1', 'oauth >=0.4.5' ]
19
- end
data/TODO.txt DELETED
@@ -1,6 +0,0 @@
1
- * look into rails partials inability to properly enumerate the response
2
- business records with the :collection param.
3
- * think about how to gracefully report errors
4
- * should we use "require 'json/add/rails'" for json for rails happiness?
5
- * use SAX-based XML parsing rather than DOM
6
- * consider supporting keep-alive for high volume requests
@@ -1,27 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'yelpster'
4
-
5
- require File.dirname(__FILE__) + '/yelp_helper'
6
-
7
- class TestBusinessRetrieve < Test::Unit::TestCase
8
- include YelpHelper
9
-
10
- def setup
11
- create_client YelpHelper::API_V2
12
- end
13
-
14
- CHOCOLATE_SF_ID = 'chocolate-san-francisco'
15
-
16
- def test_id_retrieval
17
- request = Yelp::V2::Business::Request::Id.new(
18
- :yelp_business_id => "pjb2WMwa0AfK3L-dWimO8w",
19
- :consumer_key => @consumer_key,
20
- :consumer_secret => @consumer_secret,
21
- :token => @token,
22
- :token_secret => @token_secret)
23
- response = @client.search(request)
24
- validate_json_to_ruby_business(response)
25
- assert_equal response['id'], CHOCOLATE_SF_ID
26
- end
27
- end
@@ -1,73 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'yelpster'
4
- require File.dirname(__FILE__) + '/yelp_helper'
5
-
6
- class TestBusinessSearch < Test::Unit::TestCase
7
- include YelpHelper
8
-
9
- def setup
10
- create_client YelpHelper::API_V2
11
- end
12
-
13
- BUSINESS_LAT = 37.782303
14
- BUSINESS_LON = -122.484101
15
- BUSINESS_LOCATION = {
16
- "cross_streets"=>"24th Ave & 25th Ave",
17
- "city"=>"San Francisco",
18
- "display_address"=>["2308 Clement St", "(b/t 24th Ave & 25th Ave)", "Outer Richmond", "San Francisco, CA 94121"],
19
- "geo_accuracy"=>8,
20
- "neighborhoods"=>["Outer Richmond"],
21
- "postal_code"=>"94121",
22
- "country_code"=>"US",
23
- "address"=>["2308 Clement St"],
24
- "coordinate"=>{"latitude"=>37.782303, "longitude"=>-122.484101},
25
- "state_code"=>"CA"
26
- }
27
-
28
- def test_bounding_box_search
29
- request = Yelp::V2::Search::Request::BoundingBox.new(
30
- :sw_latitude => 37.9,
31
- :sw_longitude => -122.5,
32
- :ne_latitude => 37.788022,
33
- :ne_longitude => -122.399797,
34
- # :radius => 1,
35
- # :business_count => 3,
36
- :term => 'yelp',
37
- :consumer_key => @consumer_key,
38
- :consumer_secret => @consumer_secret,
39
- :token => @token,
40
- :token_secret => @token_secret)
41
- response = @client.search(request)
42
- validate_json_to_ruby_response(response)
43
- end
44
-
45
- def test_geo_point_search
46
- request = Yelp::V2::Search::Request::GeoPoint.new(:latitude => BUSINESS_LAT,
47
- :longitude => BUSINESS_LON,
48
- :consumer_key => @consumer_key,
49
- :consumer_secret => @consumer_secret,
50
- :token => @token,
51
- :token_secret => @token_secret)
52
- response = @client.search(request)
53
- validate_json_to_ruby_response(response)
54
- assert_equal response['businesses'].first["location"], BUSINESS_LOCATION
55
- end
56
-
57
- BUSINESS_ADDRESS = '2308 Clement St'
58
-
59
- def test_location_search
60
- request = Yelp::V2::Search::Request::Location.new(:address => BUSINESS_ADDRESS,
61
- :city => 'San Francisco',
62
- :state => 'CA',
63
- :zipcode => 94121,
64
- :consumer_key => @consumer_key,
65
- :consumer_secret => @consumer_secret,
66
- :token => @token,
67
- :token_secret => @token_secret)
68
- response = @client.search(request)
69
- validate_json_to_ruby_response(response)
70
- assert_equal response['businesses'].first['location'], BUSINESS_LOCATION
71
- end
72
- end
73
-
@@ -1,11 +0,0 @@
1
- require 'test/unit'
2
- require 'yelpster'
3
-
4
- class TestClient < Test::Unit::TestCase
5
- def test_validation
6
- # make sure we can do basic client instantiation
7
- assert_nothing_raised do
8
- @client = Yelp::Client.new
9
- end
10
- end
11
- end
@@ -1,46 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'yelpster'
4
- require File.dirname(__FILE__) + '/yelp_helper'
5
-
6
- class TestNeighborhoodSearch < Test::Unit::TestCase
7
- include YelpHelper
8
-
9
- def setup
10
- create_client YelpHelper::API_V1
11
- end
12
-
13
- GORDO_LAT = 37.782093
14
- GORDO_LON = -122.483230
15
- GORDO_NEIGHBORHOOD = {
16
- "city" => "San Francisco",
17
- "name" => "Outer Richmond",
18
- "country_code" => "US",
19
- "country" => "USA",
20
- "borough" => "",
21
- "url" => "http://www.yelp.com/search?find_loc=Outer+Richmond%2C+San+Francisco%2C+CA%2C+USA",
22
- "state" => "CA",
23
- "state_code" => "CA" }
24
-
25
- def test_geo_point_search
26
- request = Yelp::V1::Neighborhood::Request::GeoPoint.new(:latitude => GORDO_LAT,
27
- :longitude => GORDO_LON,
28
- :yws_id => @yws_id)
29
- response = @client.search(request)
30
- validate_json_to_ruby_response(response)
31
- assert_equal response['neighborhoods'].first, GORDO_NEIGHBORHOOD
32
- end
33
-
34
- GORDO_ADDRESS = '2252 Clement Street'
35
-
36
- def test_location_search
37
- request = Yelp::V1::Neighborhood::Request::Location.new(:address => GORDO_ADDRESS,
38
- :city => 'San Francisco',
39
- :state => 'CA',
40
- :zipcode => 94121,
41
- :yws_id => @yws_id)
42
- response = @client.search(request)
43
- validate_json_to_ruby_response(response)
44
- assert_equal response['neighborhoods'].first, GORDO_NEIGHBORHOOD
45
- end
46
- end
@@ -1,20 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'yelpster'
4
- require File.dirname(__FILE__) + '/yelp_helper'
5
-
6
- class TestPhoneSearch < Test::Unit::TestCase
7
- include YelpHelper
8
-
9
- def setup
10
- create_client YelpHelper::API_V1
11
- end
12
-
13
- GORDO_PHONE_NUMBER = '4155666011'
14
-
15
- def test_phone_search
16
- request = Yelp::V1::Phone::Request::Number.new(:phone_number => GORDO_PHONE_NUMBER, :yws_id => @yws_id)
17
- response = @client.search(request)
18
- validate_json_to_ruby_response(response)
19
- end
20
- end
@@ -1,168 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'yelpster'
4
- require File.dirname(__FILE__) + '/yelp_helper'
5
-
6
- class TestReviewSearch < Test::Unit::TestCase
7
- include YelpHelper
8
-
9
- def setup
10
- create_client YelpHelper::API_V1
11
- end
12
-
13
- def test_bounding_box
14
- request = Yelp::V1::Review::Request::BoundingBox.new(
15
- :bottom_right_latitude => 37.788022,
16
- :bottom_right_longitude => -122.399797,
17
- :top_left_latitude => 37.9,
18
- :top_left_longitude => -122.5,
19
- # :radius => 1,
20
- # :business_count => 3,
21
- :term => 'yelp',
22
- :yws_id => @yws_id)
23
- response = @client.search(request)
24
- validate_json_to_ruby_response(response)
25
- end
26
-
27
- def test_geo_point
28
- request = Yelp::V1::Review::Request::GeoPoint.new(
29
- :latitude => 37.78022,
30
- :longitude => -122.399797,
31
- :radius => 2,
32
- # :business_count => 5,
33
- :term => 'yelp',
34
- :yws_id => @yws_id)
35
- response = @client.search(request)
36
- validate_json_to_ruby_response(response)
37
- end
38
-
39
- def test_location
40
- request = Yelp::V1::Review::Request::Location.new(
41
- :address => '650 Mission St',
42
- :city => 'San Francisco',
43
- :state => 'CA',
44
- :radius => 2,
45
- # :business_count => 5,
46
- :term => 'cream puffs',
47
- :yws_id => @yws_id)
48
- response = @client.search(request)
49
- validate_json_to_ruby_response(response)
50
- end
51
-
52
- def test_category
53
- # perform a basic search of businesses near SOMA
54
- request = Yelp::V1::Review::Request::GeoPoint.new(
55
- :latitude => 37.78022,
56
- :longitude => -122.399797,
57
- :radius => 5,
58
- :term => 'yelp',
59
- :yws_id => @yws_id)
60
- response = @client.search(request)
61
-
62
- # perform the same search focusing only on playgrounds
63
- narrowed_request = Yelp::V1::Review::Request::GeoPoint.new(
64
- :latitude => 37.78022,
65
- :longitude => -122.399797,
66
- :radius => 5,
67
- :term => 'yelp',
68
- :category => 'playgrounds',
69
- :yws_id => @yws_id)
70
- narrowed_response = @client.search(narrowed_request)
71
-
72
- # make sure we got less for the second
73
- assert(response['businesses'].length > narrowed_response['businesses'].length)
74
- end
75
-
76
- def test_json_response_format
77
- request = basic_request(:response_format => Yelp::ResponseFormat::JSON)
78
- response = @client.search(request)
79
- validate_json_response(response)
80
- end
81
-
82
- def test_json_to_ruby_response_format
83
- request = basic_request(:response_format => Yelp::ResponseFormat::JSON_TO_RUBY)
84
- response = @client.search(request)
85
- validate_json_to_ruby_response(response)
86
- end
87
-
88
- def test_pickle_response_format
89
- request = basic_request(:response_format => Yelp::ResponseFormat::PICKLE)
90
- @client.search(request)
91
- # TODO: validation
92
- end
93
-
94
- def test_php_response_format
95
- request = basic_request(:response_format => Yelp::ResponseFormat::PHP)
96
- response = @client.search(request)
97
- # TODO: validation
98
- end
99
-
100
- def test_compressed_response
101
- request = basic_request(:compress_response => true)
102
- response = @client.search(request)
103
- validate_json_to_ruby_response(response)
104
- end
105
-
106
- def test_uncompressed_response
107
- request = basic_request(:compress_response => false)
108
- response = @client.search(request)
109
- validate_json_to_ruby_response(response)
110
- end
111
-
112
- def test_multiple_categories
113
- # fetch results for only one category
114
- params = {
115
- :city => 'San Francisco',
116
- :state => 'CA',
117
- :yws_id => @yws_id,
118
- :category => 'donuts'
119
- }
120
- request = Yelp::V1::Review::Request::Location.new(params)
121
- response = @client.search(request)
122
-
123
- # make sure the overall request looks kosher
124
- validate_json_to_ruby_response(response)
125
-
126
- # make sure all businesses returned have at least the specified category
127
- response['businesses'].each do |b|
128
- cat_exists = b['categories'].find { |c| c['category_filter'] == 'donuts' }
129
- assert_not_nil(cat_exists)
130
- end
131
-
132
- # now fetch for businesses with two categories
133
- params[:category] = [ 'donuts', 'icecream' ]
134
- request = Yelp::V1::Review::Request::Location.new(params)
135
- response = @client.search(request)
136
-
137
- # make sure the overall request looks kosher
138
- validate_json_to_ruby_response(response)
139
-
140
- # make sure we have at least one of each specified category, and
141
- # that each business has at least one
142
- donut_count = 0
143
- icecream_count = 0
144
- response['businesses'].each do |b|
145
- has_donut = b['categories'].find { |c| c['category_filter'] == 'donuts' }
146
- has_icecream = b['categories'].find { |c| c['category_filter'] == 'icecream' }
147
-
148
- donut_count += 1 if has_donut
149
- icecream_count += 1 if has_icecream
150
-
151
- assert(has_donut || has_icecream)
152
- end
153
-
154
- assert((donut_count > 0) && (icecream_count > 0))
155
- end
156
-
157
- protected
158
-
159
- def basic_request (params = nil)
160
- default_params = {
161
- :city => 'San Francisco',
162
- :state => 'CA',
163
- :term => 'gordo',
164
- :yws_id => @yws_id
165
- }
166
- Yelp::V1::Review::Request::Location.new(default_params.merge(params))
167
- end
168
- end
@@ -1,74 +0,0 @@
1
- require 'pp'
2
-
3
- module YelpHelper
4
- API_V1 = 'v1'
5
- API_V2 = 'v2'
6
-
7
- def create_client(api_ver)
8
- @client = Yelp::Client.new
9
- @api_ver = api_ver
10
-
11
- case @api_ver
12
- when API_V1
13
- assert_not_nil(ENV['YWSID'], "Missing YWSID. Obtain from http://www.yelp.com/developer and " +
14
- "set in your shell environment under 'YWSID'.")
15
- @yws_id = ENV['YWSID']
16
- when API_V2
17
- assert_not_nil(ENV['CONSUMER_KEY'], "Missing CONSUMER_KEY. Obtain from http://www.yelp.com/developer and " +
18
- "set in your shell environment under 'CONSUMER_KEY'.")
19
- @consumer_key = ENV['CONSUMER_KEY']
20
- assert_not_nil(ENV['CONSUMER_SECRET'], "Missing CONSUMER_SECRET. Obtain from http://www.yelp.com/developer and " +
21
- "set in your shell environment under 'CONSUMER_SECRET'.")
22
- @consumer_secret = ENV['CONSUMER_SECRET']
23
- assert_not_nil(ENV['TOKEN'], "Missing TOKEN. Obtain from http://www.yelp.com/developer and " +
24
- "set in your shell environment under 'TOKEN'.")
25
- @token = ENV['TOKEN']
26
- assert_not_nil(ENV['TOKEN_SECRET'], "Missing TOKEN_SECRET. Obtain from http://www.yelp.com/developer and " +
27
- "set in your shell environment under 'TOKEN_SECRET'.")
28
- @token_secret = ENV['TOKEN_SECRET']
29
- else
30
- assert_false("No api version specified in test case; cannot continue")
31
- end
32
-
33
- # @client.debug = true
34
- end
35
-
36
- def validate_json_response (response)
37
- assert_not_nil response
38
- assert_instance_of String, response
39
- assert_match(/^\{\"message\":\{\"text\":\"OK\",\"code\":0,\"version\":\"1\.1\.1\"\},\"(businesses|neighborhoods)\":.*?\}$/, response)
40
- end
41
-
42
- def validate_json_to_ruby_response (response)
43
- assert_not_nil response
44
- assert_instance_of Hash, response
45
- case @api_ver
46
- when API_V1
47
- assert_not_nil response['message']
48
- assert(response['message']['code'] == 0)
49
- assert(response['message']['text'] == 'OK')
50
- when API_V2
51
- # v2 responses do not have a message field
52
- end
53
- assert_not_nil((response['businesses'] || response['neighborhoods']))
54
- if response['businesses']
55
- response['businesses'].each { |b| validate_json_to_ruby_business(b) }
56
- end
57
- end
58
-
59
- #YELP_BIZ_ID_LENGTH = 22
60
-
61
- def validate_json_to_ruby_business (business)
62
- # rudimentary checks to make sure it looks like a typical yelp business
63
- # result converted to a ruby hash
64
- assert business['id'].length > 0
65
- assert_valid_url business['url']
66
- end
67
-
68
- # just a rudimentary check will serve us fine
69
- VALID_URL_REGEXP = /^https?:\/\/[a-z0-9]/i
70
-
71
- def assert_valid_url (url)
72
- assert_match VALID_URL_REGEXP, url
73
- end
74
- end
@@ -1,38 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "yelpster"
5
- s.version = "1.1.1"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Naveed Siddiqui"]
9
- s.date = "2011-10-13"
10
- s.description = "Extension of Korman's Ruby wrapper to interface with Yelp's REST API described in detail at:\n\nhttp://www.yelp.com/developers/getting_started\n"
11
- s.email = "naveed@10eighteen.com"
12
- s.extra_rdoc_files = ["CHANGELOG.rdoc", "LICENSE.txt", "README.rdoc", "TODO.txt", "lib/yelpster.rb", "lib/yelpster/client.rb", "lib/yelpster/record.rb", "lib/yelpster/response_format.rb", "lib/yelpster/v1/neighborhood/request/base.rb", "lib/yelpster/v1/neighborhood/request/geo_point.rb", "lib/yelpster/v1/neighborhood/request/location.rb", "lib/yelpster/v1/phone/request/number.rb", "lib/yelpster/v1/request.rb", "lib/yelpster/v1/review/request/base.rb", "lib/yelpster/v1/review/request/bounding_box.rb", "lib/yelpster/v1/review/request/geo_point.rb", "lib/yelpster/v1/review/request/location.rb", "lib/yelpster/v2/business/request/id.rb", "lib/yelpster/v2/request.rb", "lib/yelpster/v2/search/request/base.rb", "lib/yelpster/v2/search/request/bounding_box.rb", "lib/yelpster/v2/search/request/geo_point.rb", "lib/yelpster/v2/search/request/location.rb"]
13
- s.files = ["CHANGELOG.rdoc", "LICENSE.txt", "Manifest", "README.rdoc", "Rakefile", "TODO.txt", "lib/yelpster.rb", "lib/yelpster/client.rb", "lib/yelpster/record.rb", "lib/yelpster/response_format.rb", "lib/yelpster/v1/neighborhood/request/base.rb", "lib/yelpster/v1/neighborhood/request/geo_point.rb", "lib/yelpster/v1/neighborhood/request/location.rb", "lib/yelpster/v1/phone/request/number.rb", "lib/yelpster/v1/request.rb", "lib/yelpster/v1/review/request/base.rb", "lib/yelpster/v1/review/request/bounding_box.rb", "lib/yelpster/v1/review/request/geo_point.rb", "lib/yelpster/v1/review/request/location.rb", "lib/yelpster/v2/business/request/id.rb", "lib/yelpster/v2/request.rb", "lib/yelpster/v2/search/request/base.rb", "lib/yelpster/v2/search/request/bounding_box.rb", "lib/yelpster/v2/search/request/geo_point.rb", "lib/yelpster/v2/search/request/location.rb", "test/test_business_retrieve.rb", "test/test_business_search.rb", "test/test_client.rb", "test/test_neighborhood_search.rb", "test/test_phone_search.rb", "test/test_review_search.rb", "test/yelp_helper.rb", "yelpster.gemspec"]
14
- s.homepage = "https://github.com/nvd/yelpster"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Yelpster", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = "yelpster"
18
- s.rubygems_version = "1.8.11"
19
- s.summary = "An object-oriented interface to the Yelp Developer API."
20
- s.test_files = ["test/test_business_retrieve.rb", "test/test_business_search.rb", "test/test_client.rb", "test/test_neighborhood_search.rb", "test/test_phone_search.rb", "test/test_review_search.rb"]
21
- s.signing_key = '/Users/naveed/Desktop/dev/Certificates/yelpster/gem-private_key.pem'
22
- s.cert_chain = ['gem-public_cert.pem']
23
-
24
- if s.respond_to? :specification_version then
25
- s.specification_version = 3
26
-
27
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
- s.add_runtime_dependency(%q<json>, [">= 1.1.1"])
29
- s.add_runtime_dependency(%q<oauth>, [">= 0.4.5"])
30
- else
31
- s.add_dependency(%q<json>, [">= 1.1.1"])
32
- s.add_dependency(%q<oauth>, [">= 0.4.5"])
33
- end
34
- else
35
- s.add_dependency(%q<json>, [">= 1.1.1"])
36
- s.add_dependency(%q<oauth>, [">= 0.4.5"])
37
- end
38
- end
metadata.gz.sig DELETED
Binary file