yelpme 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/lib/yelpme/version.rb +1 -1
- data/lib/yelpme.rb +36 -6
- data/yelpme.gemspec +1 -0
- metadata +19 -7
data/README.md
CHANGED
@@ -12,6 +12,19 @@ Yes, I know I know.. I could go to Yelp's site and type this in, but
|
|
12
12
|
fuck that. As I said I'm lazy.
|
13
13
|
|
14
14
|
##How
|
15
|
+
__IMPORTANT__ You should probably sign in/up for yelp.com and go to [the api](http://www.yelp.com/developers/getting_started/api_access)
|
16
|
+
and request some api-hotness. After doing so, mosey your way over to your .bash_profile/rc/whichever and enter the
|
17
|
+
following:
|
18
|
+
|
19
|
+
export YELP_CONSUMER_KEY='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
20
|
+
export YELP_CONSUMER_SECRET='xxxxxxxxxxxxxxxxxxxxxxxxxx'
|
21
|
+
export YELP_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
22
|
+
export YELP_TOKEN_SECRET='xxxxxxxxxxxxxxxxxxxxxxxxx'
|
23
|
+
|
24
|
+
Obviously put in your read consumer key, consumer secret, token, and token secret in place of those Xs.
|
25
|
+
|
26
|
+
Cool. Good job, I'm proud of you for doing that. Now we can run:
|
27
|
+
|
15
28
|
$ yelpme breakfast "san francisco"
|
16
29
|
#=> etc etc
|
17
30
|
$ yelpme plow "potrero hill"
|
data/lib/yelpme/version.rb
CHANGED
data/lib/yelpme.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
require "yelpme/version"
|
2
2
|
|
3
|
+
|
3
4
|
begin
|
4
5
|
require 'rubygems'
|
5
6
|
rescue LoadError
|
6
7
|
end
|
7
|
-
require
|
8
|
-
|
9
|
-
|
8
|
+
require 'yelp2'
|
9
|
+
require 'pp'
|
10
|
+
require 'optparse'
|
10
11
|
module Yelpme
|
11
12
|
|
12
|
-
# A quick search to get the first result
|
13
|
+
# A quick search to get the first result. Additional arguments
|
14
|
+
# used with flags are picked up by Slop...Which sounds dirty.
|
13
15
|
#
|
14
16
|
# args - the list of arguments you may pass in to search on yelp
|
15
17
|
#
|
@@ -23,7 +25,35 @@ module Yelpme
|
|
23
25
|
term = args.shift
|
24
26
|
location = {}
|
25
27
|
location[:location] = args.shift
|
26
|
-
|
27
|
-
|
28
|
+
options = {}
|
29
|
+
OptionParser.new do |opts|
|
30
|
+
opts.on("-r", "--random", "Random result") do |r|
|
31
|
+
options[:random] = r
|
32
|
+
end
|
33
|
+
opts.on("-V", "--version", "Print the version") do |v|
|
34
|
+
options[:version] = v
|
35
|
+
end
|
36
|
+
end.parse!
|
37
|
+
|
38
|
+
raise ArgumentError, "Location needs a value" if location[:location].nil?
|
39
|
+
if %w{YELP_CONSUMER_KEY YELP_CONSUMER_SECRET YELP_TOKEN YELP_TOKEN_SECRET}.all?{|word| ENV.include?(word)}
|
40
|
+
query = Yelp::Base.new(ENV["YELP_CONSUMER_KEY"],ENV["YELP_CONSUMER_SECRET"],ENV["YELP_TOKEN"], ENV["YELP_TOKEN_SECRET"])
|
41
|
+
businesses = query.search(term, location)
|
42
|
+
business = parse_businesses(businesses, options)
|
43
|
+
pp business
|
44
|
+
else
|
45
|
+
raise LoadError, "Verify that your ENV variables for authentication to Yelp are set. View the README for more information."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Parse how the business should be parsed based upon the options
|
50
|
+
# are passed in.
|
51
|
+
#
|
52
|
+
# businesses - Array of businesses returned from the Yelp search.
|
53
|
+
# options - Options passed in from OptionParser.
|
54
|
+
#
|
55
|
+
# Returns one or many businesses.
|
56
|
+
def self.parse_businesses(businesses, options)
|
57
|
+
options[:random].nil? ? businesses.first : businesses[rand(businesses.size)]
|
28
58
|
end
|
29
59
|
end
|
data/yelpme.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yelpme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- brntbeer
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-09-17 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: yelp2
|
@@ -34,6 +33,20 @@ dependencies:
|
|
34
33
|
version: 0.0.3
|
35
34
|
type: :runtime
|
36
35
|
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: slop
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
37
50
|
description: Yelpme is used to utilize Yelp's API from the command line using the already existing yelp2 gem.
|
38
51
|
email:
|
39
52
|
- brent.beer@gmail.com
|
@@ -52,7 +65,6 @@ files:
|
|
52
65
|
- lib/yelpme.rb
|
53
66
|
- lib/yelpme/version.rb
|
54
67
|
- yelpme.gemspec
|
55
|
-
has_rdoc: true
|
56
68
|
homepage: http://rubygems.org/gems/yelpme
|
57
69
|
licenses: []
|
58
70
|
|
@@ -82,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
94
|
requirements: []
|
83
95
|
|
84
96
|
rubyforge_project: yelpme
|
85
|
-
rubygems_version: 1.
|
97
|
+
rubygems_version: 1.8.10
|
86
98
|
signing_key:
|
87
99
|
specification_version: 3
|
88
100
|
summary: Yelpme is an interface to using Yelp's API.
|