yelpr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +55 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/README.md +20 -0
- data/Rakefile +8 -0
- data/fixtures/cassette_library/test_0001_gets_an_error_response_if_oauth_credentials_are_missing.yml +33 -0
- data/fixtures/cassette_library/test_0001_gets_search_results_based_on_parameters.yml +81 -0
- data/fixtures/cassette_library/test_0001_gets_specific_business_results_by_id.yml +70 -0
- data/lib/yelpr.rb +5 -0
- data/lib/yelpr/client.rb +36 -0
- data/lib/yelpr/version.rb +3 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/vcr.rb +8 -0
- data/spec/yelpr/client_spec.rb +54 -0
- data/yelpr.gemspec +31 -0
- metadata +163 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
+
environment_id="ruby-1.9.2-p290@yelpr"
|
8
|
+
|
9
|
+
#
|
10
|
+
# Uncomment following line if you want options to be set only for given project.
|
11
|
+
#
|
12
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
13
|
+
|
14
|
+
#
|
15
|
+
# First we attempt to load the desired environment directly from the environment
|
16
|
+
# file. This is very fast and efficient compared to running through the entire
|
17
|
+
# CLI and selector. If you want feedback on which environment was used then
|
18
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
19
|
+
#
|
20
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
21
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
22
|
+
then
|
23
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
24
|
+
|
25
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
26
|
+
then
|
27
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
28
|
+
fi
|
29
|
+
else
|
30
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
31
|
+
if ! rvm --create use "$environment_id"
|
32
|
+
then
|
33
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
34
|
+
exit 1
|
35
|
+
fi
|
36
|
+
fi
|
37
|
+
|
38
|
+
#
|
39
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
40
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
41
|
+
# necessary.
|
42
|
+
#
|
43
|
+
# filename=".gems"
|
44
|
+
# if [[ -s "$filename" ]]
|
45
|
+
# then
|
46
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
47
|
+
# fi
|
48
|
+
|
49
|
+
# If you use bundler, this might be useful to you:
|
50
|
+
# if command -v bundle && [[ -s Gemfile ]]
|
51
|
+
# then
|
52
|
+
# bundle
|
53
|
+
# fi
|
54
|
+
|
55
|
+
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Yelpr
|
2
|
+
===========
|
3
|
+
|
4
|
+
[![Build Status](https://secure.travis-ci.org/justinbeltran/yelpr.png)](http://travis-ci.org/justinbeltran/yelpr)
|
5
|
+
|
6
|
+
Yelpr is a yelp gem for the masses. In general, it's just a wrapper on top of the existing Yelp v2 API.
|
7
|
+
|
8
|
+
Before you use Yelpr and Yelp's v2 API, you must set up API OAuth access on the following page:
|
9
|
+
|
10
|
+
[http://www.yelp.com/developers/getting_started/api_access](http://www.yelp.com/developers/getting_started/api_access)
|
11
|
+
|
12
|
+
See the following for reference, when using the client:
|
13
|
+
|
14
|
+
[http://www.yelp.com/developers/documentation/v2/overview](http://www.yelp.com/developers/documentation/v2/overview)
|
15
|
+
|
16
|
+
Setup && Installation
|
17
|
+
------------
|
18
|
+
```bash
|
19
|
+
TBD
|
20
|
+
```
|
data/Rakefile
ADDED
data/fixtures/cassette_library/test_0001_gets_an_error_response_if_oauth_credentials_are_missing.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.yelp.com:80/v2/search
|
6
|
+
body: !!null
|
7
|
+
headers:
|
8
|
+
accept-encoding:
|
9
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
10
|
+
response: !ruby/struct:VCR::Response
|
11
|
+
status: !ruby/struct:VCR::ResponseStatus
|
12
|
+
code: 400
|
13
|
+
message: Bad Request
|
14
|
+
headers:
|
15
|
+
date:
|
16
|
+
- Fri, 25 Nov 2011 23:55:16 GMT
|
17
|
+
server:
|
18
|
+
- Apache
|
19
|
+
x-node:
|
20
|
+
- web43, api_com
|
21
|
+
set-cookie:
|
22
|
+
- bs=185300a9bd803545ec049dfe9646b1bb; Max-Age=631094683; Path=/; expires=Tue,
|
23
|
+
25-Nov-2031 08:00:00 GMT; HttpOnly
|
24
|
+
content-type:
|
25
|
+
- application/json
|
26
|
+
content-length:
|
27
|
+
- '120'
|
28
|
+
vary:
|
29
|
+
- User-Agent
|
30
|
+
x-proxied:
|
31
|
+
- lb2
|
32
|
+
body: ! '{"error":{"text":"One or more parameters are missing in request","id":"MISSING_PARAMETER","field":"oauth_consumer_key"}}'
|
33
|
+
http_version: '1.1'
|
@@ -0,0 +1,81 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.yelp.com:80/v2/search?limit=5&location=Irvine,%20CA&term=food
|
6
|
+
body: !!null
|
7
|
+
headers:
|
8
|
+
authorization:
|
9
|
+
- OAuth oauth_consumer_key="i0dj2IWqCUY_A_0ZotwPtQ", oauth_nonce="b36903300c85b8817fdf5b5df1ae1d06",
|
10
|
+
oauth_signature="zcs6JVz76Ly%2BVsA%2BXiqJEvJu5q4%3D", oauth_signature_method="HMAC-SHA1",
|
11
|
+
oauth_timestamp="1322265488", oauth_token="dJN9A1_-TNJoXNcOuk3xgn4AVJze-nU5",
|
12
|
+
oauth_version="1.0"
|
13
|
+
accept-encoding:
|
14
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
15
|
+
response: !ruby/struct:VCR::Response
|
16
|
+
status: !ruby/struct:VCR::ResponseStatus
|
17
|
+
code: 200
|
18
|
+
message: OK
|
19
|
+
headers:
|
20
|
+
date:
|
21
|
+
- Fri, 25 Nov 2011 23:55:17 GMT
|
22
|
+
server:
|
23
|
+
- Apache
|
24
|
+
x-node:
|
25
|
+
- web40, api_com
|
26
|
+
set-cookie:
|
27
|
+
- bs=4f7ddd7f73b5823f87e2b76ff9de43bd; Max-Age=631094682; Path=/; expires=Tue,
|
28
|
+
25-Nov-2031 08:00:00 GMT; HttpOnly
|
29
|
+
content-type:
|
30
|
+
- application/json
|
31
|
+
vary:
|
32
|
+
- Accept-Encoding,User-Agent
|
33
|
+
content-encoding:
|
34
|
+
- gzip
|
35
|
+
transfer-encoding:
|
36
|
+
- chunked
|
37
|
+
x-proxied:
|
38
|
+
- lb1
|
39
|
+
body: !binary |-
|
40
|
+
H4sIAAAAAAAAA8yYW1PjOhLHv4rWD3seNk58kW+8nAoJCRnu1yEMUynFVmwx
|
41
|
+
smUsOyZMzXffdhxgSAIMp9gFKuQiS/9ut1q/dOenktGQiUTZ+KnIlMxfOclZ
|
42
|
+
XgR0FFCeE2VDa2qu4Xiurnua7Zie5rlWQ+EiCZen2bZn6pbu2o5uedi13F8N
|
43
|
+
xadJTrPfdZUN02zaruPYpqW5tu1oGv5NT9lQdd1purqHDey6BjaMX6CTi5xw
|
44
|
+
ZcPwNKehjAvJEiollcrGt59KBspJqGzgJjgWizHjdFRkMFuJ8jzdaL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lO4rgu7sCVlmV
|
76
|
+
YDNRVBUcorcp9fMG6h1vtXcG+33U3doddAYHZyf/QhXsuqIYc4qC+qXqK1GY
|
77
|
+
Mc5pAFiEA1IbIAmgBYCWz2BSbQ0MQelYyIJwqBYnaPBXjCYUisUk/Mc/skW7
|
78
|
+
HTwo1Oi6xy73brHvbN5kk7d1pisIrZXxKWZ+0adip/uljemOeu5fxkcvcg6C
|
79
|
+
r0L01UX4P45zz6bJEusWGaFUv5jX7+a12/sQEOvQXXZInBZybSP7jr/ALZl6
|
80
|
+
pa6zILTuS10s1mzbWdR93lr2ff/1XwAAAP//AwBMTXybGhkAAA==
|
81
|
+
http_version: '1.1'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.yelp.com:80/v2/business/yelp-san-francisco
|
6
|
+
body: !!null
|
7
|
+
headers:
|
8
|
+
authorization:
|
9
|
+
- OAuth oauth_consumer_key="i0dj2IWqCUY_A_0ZotwPtQ", oauth_nonce="d342567e5b9bfc167153bc6af48b12fc",
|
10
|
+
oauth_signature="%2FygpDXHZTYkAaVqhU4h4AIWFKbg%3D", oauth_signature_method="HMAC-SHA1",
|
11
|
+
oauth_timestamp="1322265487", oauth_token="dJN9A1_-TNJoXNcOuk3xgn4AVJze-nU5",
|
12
|
+
oauth_version="1.0"
|
13
|
+
accept-encoding:
|
14
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
15
|
+
response: !ruby/struct:VCR::Response
|
16
|
+
status: !ruby/struct:VCR::ResponseStatus
|
17
|
+
code: 200
|
18
|
+
message: OK
|
19
|
+
headers:
|
20
|
+
date:
|
21
|
+
- Fri, 25 Nov 2011 23:55:17 GMT
|
22
|
+
server:
|
23
|
+
- Apache
|
24
|
+
x-node:
|
25
|
+
- web37, api_com
|
26
|
+
set-cookie:
|
27
|
+
- bs=a61ba2c7b3a7a78cf57dd08b3e2e427e; Max-Age=631094682; Path=/; expires=Tue,
|
28
|
+
25-Nov-2031 08:00:00 GMT; HttpOnly
|
29
|
+
content-type:
|
30
|
+
- application/json
|
31
|
+
vary:
|
32
|
+
- Accept-Encoding,User-Agent
|
33
|
+
content-encoding:
|
34
|
+
- gzip
|
35
|
+
transfer-encoding:
|
36
|
+
- chunked
|
37
|
+
x-proxied:
|
38
|
+
- lb2
|
39
|
+
body: !binary |-
|
40
|
+
H4sIAAAAAAAAA+SXXVPbOBSG/4rqi87ubOL4M7FzZ6ChKaWBoZTSlvEosmyr
|
41
|
+
sa1UknHSTv/7HtmEBkhhudjZi+WCjC2dD73n0ZH8w2AyJgVmJU2MsRI17RkC
|
42
|
+
K1Zlxtg1rZ5R8jkraFyLwhgbuVLL8WBQmmtaLE3Cy8GcfR94i+O96+mri5PV
|
43
|
+
xeLiaPIujoOz1amxcRSzMrtnTxOGbRMvWj8kqVpXUsF0MnAs27Ide2gPQ88d
|
44
|
+
WiMvHICDASNczxCy+x+75hJyhBj0mtEmJryulDH2LCvoGRUuKUS7BOcPsohl
|
45
|
+
iYvn5uK47six/FHo7cyldXmb0Z2lNk1zVyz90Je46qcCV4RJwsGkrQGXugQp
|
46
|
+
LiTdLEsa488/buvh9wy6IlQsYaFGhDJBsUKCSl4LQlHKBepmSoSrBCmOUga/
|
47
|
+
FW3QssCESv0q4y8gnoJyx0Tb65C26zjO0At9Z0ssnN0vuhbKfUoofxQMbdux
|
48
|
+
RjuF8jdF247Sqff8WHbohUPLCyz3kaJsItaSCmP8w9ixMOn223jO/XjLnCs+
|
49
|
+
GOJqFr3ZL1MWxKo5bHg0O/wYDUppfl1qzwwUNLI3s4MDItLTMk3PiTNfRkfR
|
50
|
+
vDFuUdwXa8iqQHum8fPe8gssdkr9FJOu742s0BntVrrzull9lyO3JlH0qdp7
|
51
|
+
f74YhulKsrUip5DPL8K8bcKmCJctPYCN3kotVTm+pkjltUQpFsBcDe+YgiFE
|
52
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V07KSN1/rQe4fraxh8LSS6OJ0D
|
68
|
+
yFt/PIj15vX5Gbz7fbJX2oCLhFUgtNamAJVUrU3dkQkdFsrpWt2frVWsspvh
|
69
|
+
vu04pmc5vhu40Fl0+ekm6H5k/Pz5NwAAAP//AwCtVNjFjg0AAA==
|
70
|
+
http_version: '1.1'
|
data/lib/yelpr.rb
ADDED
data/lib/yelpr/client.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
module Yelpr
|
5
|
+
class Client
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
auth = {
|
9
|
+
:consumer_key => options[:consumer_key],
|
10
|
+
:consumer_secret => options[:consumer_secret],
|
11
|
+
:token => options[:token],
|
12
|
+
:token_secret => options[:token_secret]
|
13
|
+
}
|
14
|
+
|
15
|
+
@conn = Faraday.new(:url => 'http://api.yelp.com') do |builder|
|
16
|
+
builder.use Faraday::Request::OAuth, auth if auth.values.all?
|
17
|
+
builder.use Faraday::Response::Mashify
|
18
|
+
builder.use Faraday::Response::ParseJson
|
19
|
+
builder.adapter Faraday.default_adapter
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def search(options = {})
|
24
|
+
response = @conn.get do |request|
|
25
|
+
request.url '/v2/search', options
|
26
|
+
end
|
27
|
+
|
28
|
+
response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
def business(id)
|
32
|
+
response = @conn.get "/v2/business/#{id}"
|
33
|
+
response.body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
gem 'minitest'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
class ColoredIO
|
6
|
+
ESC = "\e["
|
7
|
+
NND = "#{ESC}0m"
|
8
|
+
|
9
|
+
def initialize(io)
|
10
|
+
@io = io
|
11
|
+
end
|
12
|
+
|
13
|
+
def print(o)
|
14
|
+
case o
|
15
|
+
when "."
|
16
|
+
@io.send(:print, "#{ESC}32m#{o}#{NND}")
|
17
|
+
when "E"
|
18
|
+
@io.send(:print, "#{ESC}33m#{o}#{NND}")
|
19
|
+
when "F"
|
20
|
+
@io.send(:print, "#{ESC}31m#{o}#{NND}")
|
21
|
+
:w! else
|
22
|
+
@io.send(:print, o)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def puts(*o)
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
MiniTest::Unit.output = ColoredIO.new(MiniTest::Unit.output)
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path('../../../lib/yelpr/client', __FILE__)
|
2
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
3
|
+
require File.expand_path('../../support/vcr', __FILE__)
|
4
|
+
|
5
|
+
describe Yelpr::Client do
|
6
|
+
|
7
|
+
before do
|
8
|
+
VCR.insert_cassette(__name__, :record => :new_episodes)
|
9
|
+
@client = Yelpr::Client.new(
|
10
|
+
:consumer_key => 'i0dj2IWqCUY_A_0ZotwPtQ',
|
11
|
+
:consumer_secret => 'z6tUShId0oPctG5po6I_D16Ld8M',
|
12
|
+
:token => 'dJN9A1_-TNJoXNcOuk3xgn4AVJze-nU5',
|
13
|
+
:token_secret => '6Pr0C98rHNlfT23APD12TV-b5Eg'
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
VCR.eject_cassette
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when created" do
|
22
|
+
it 'gets an error response if OAuth credentials are missing' do
|
23
|
+
noauth_client = Yelpr::Client.new
|
24
|
+
response = noauth_client.search
|
25
|
+
response.error.text.must_match /One or more parameters are missing in request/
|
26
|
+
response.error.id.must_match /MISSING_PARAMETER/
|
27
|
+
response.error.field.must_match /oauth_consumer_key/
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "when searching for businesses" do
|
32
|
+
it 'gets search results based on parameters' do
|
33
|
+
response = @client.search(
|
34
|
+
:term => 'food',
|
35
|
+
:location => 'Irvine, CA',
|
36
|
+
:limit => 5
|
37
|
+
)
|
38
|
+
response.businesses.size.must_equal 5
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "when finding business by id" do
|
43
|
+
it "gets specific business results by id" do
|
44
|
+
response = @client.business('yelp-san-francisco')
|
45
|
+
|
46
|
+
response.categories.wont_be_empty
|
47
|
+
response.reviews.wont_be_empty
|
48
|
+
response.location.wont_be_nil
|
49
|
+
response.rating.wont_be_nil
|
50
|
+
response.id.must_match /yelp-san-francisco/
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/yelpr.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "yelpr/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "yelpr"
|
7
|
+
s.version = Yelpr::VERSION
|
8
|
+
s.authors = ["Justin Beltran"]
|
9
|
+
s.email = ["justinvbeltran@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Yelp API v2.0 Ruby gem}
|
12
|
+
s.description = %q{Yelp gem for the masses.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "yelpr"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "webmock"
|
23
|
+
s.add_development_dependency "rake"
|
24
|
+
s.add_development_dependency "minitest"
|
25
|
+
s.add_development_dependency "vcr"
|
26
|
+
s.add_runtime_dependency "faraday"
|
27
|
+
s.add_runtime_dependency "faraday_middleware"
|
28
|
+
s.add_runtime_dependency "hashie"
|
29
|
+
s.add_runtime_dependency "multi_json"
|
30
|
+
s.add_runtime_dependency "simple_oauth"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yelpr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Justin Beltran
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: webmock
|
16
|
+
requirement: &70218731032480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70218731032480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70218731032040 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70218731032040
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: minitest
|
38
|
+
requirement: &70218731031580 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70218731031580
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: vcr
|
49
|
+
requirement: &70218731031160 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70218731031160
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: faraday
|
60
|
+
requirement: &70218731030700 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70218731030700
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday_middleware
|
71
|
+
requirement: &70218731030280 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70218731030280
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: hashie
|
82
|
+
requirement: &70218731029860 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70218731029860
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: multi_json
|
93
|
+
requirement: &70218731029440 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70218731029440
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: simple_oauth
|
104
|
+
requirement: &70218731029020 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70218731029020
|
113
|
+
description: Yelp gem for the masses.
|
114
|
+
email:
|
115
|
+
- justinvbeltran@gmail.com
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- .gitignore
|
121
|
+
- .rvmrc
|
122
|
+
- .travis.yml
|
123
|
+
- Gemfile
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- fixtures/cassette_library/test_0001_gets_an_error_response_if_oauth_credentials_are_missing.yml
|
127
|
+
- fixtures/cassette_library/test_0001_gets_search_results_based_on_parameters.yml
|
128
|
+
- fixtures/cassette_library/test_0001_gets_specific_business_results_by_id.yml
|
129
|
+
- lib/yelpr.rb
|
130
|
+
- lib/yelpr/client.rb
|
131
|
+
- lib/yelpr/version.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/support/vcr.rb
|
134
|
+
- spec/yelpr/client_spec.rb
|
135
|
+
- yelpr.gemspec
|
136
|
+
homepage: ''
|
137
|
+
licenses: []
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project: yelpr
|
156
|
+
rubygems_version: 1.8.10
|
157
|
+
signing_key:
|
158
|
+
specification_version: 3
|
159
|
+
summary: Yelp API v2.0 Ruby gem
|
160
|
+
test_files:
|
161
|
+
- spec/spec_helper.rb
|
162
|
+
- spec/support/vcr.rb
|
163
|
+
- spec/yelpr/client_spec.rb
|