untappd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/README.rdoc +44 -0
- data/Rakefile +2 -0
- data/examples/aba_checkins.rb +52 -0
- data/lib/untappd.rb +21 -0
- data/lib/untappd/base.rb +20 -0
- data/lib/untappd/beer.rb +32 -0
- data/lib/untappd/version.rb +3 -0
- data/spec/checkins_spec.rb +5 -0
- data/untappd.gemspec +26 -0
- metadata +124 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
untappd (0.0.1)
|
5
|
+
hashie (>= 1.0.0)
|
6
|
+
httparty (>= 0.7.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
crack (0.1.8)
|
12
|
+
diff-lcs (1.1.2)
|
13
|
+
hashie (1.0.0)
|
14
|
+
httparty (0.7.4)
|
15
|
+
crack (= 0.1.8)
|
16
|
+
rspec (2.5.0)
|
17
|
+
rspec-core (~> 2.5.0)
|
18
|
+
rspec-expectations (~> 2.5.0)
|
19
|
+
rspec-mocks (~> 2.5.0)
|
20
|
+
rspec-core (2.5.1)
|
21
|
+
rspec-expectations (2.5.0)
|
22
|
+
diff-lcs (~> 1.1.2)
|
23
|
+
rspec-mocks (2.5.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
rspec
|
30
|
+
untappd!
|
data/README.rdoc
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
== untappd API
|
2
|
+
|
3
|
+
I have just started and would love help trying to cover all the end points.
|
4
|
+
|
5
|
+
This is a simple wrapper around the untappd API packaged as a ruby gem.
|
6
|
+
|
7
|
+
* You will need to register for an API key: http://untappd.com/api/register
|
8
|
+
* Attempting to wrap all the API documented here: http://untappd.com/api/docs/v3
|
9
|
+
|
10
|
+
== Releases
|
11
|
+
|
12
|
+
* 0.0.1 Beer Search, Info and Checkins
|
13
|
+
|
14
|
+
== Examples
|
15
|
+
Configure your API KEY
|
16
|
+
|
17
|
+
Untappd.configure do |config|
|
18
|
+
config.apikey = 'YOUR_API_KEY'
|
19
|
+
end
|
20
|
+
|
21
|
+
Get all the checkins for Arrogant Bastard Ale
|
22
|
+
|
23
|
+
checkins = Untappd.beer_checkins(18099)
|
24
|
+
checkins.each do |checkin|
|
25
|
+
puts "#{checkin.user.first_name} at #{checkin.created_at}"
|
26
|
+
end
|
27
|
+
|
28
|
+
Search for beers with the name Stone
|
29
|
+
|
30
|
+
beers = Untappd::Beer.search('stone')
|
31
|
+
beers.each do |beer|
|
32
|
+
puts "#{beer.beer_name}"
|
33
|
+
end
|
34
|
+
|
35
|
+
Get extended info for Arrogant Bastard Ale
|
36
|
+
|
37
|
+
info = Untappd::Beer.info(18099)
|
38
|
+
puts "#{info.name} by #{info.brewery}"
|
39
|
+
|
40
|
+
== Debugging
|
41
|
+
You can dump any result to see what values are available with
|
42
|
+
|
43
|
+
info = Untappd::Beer.info(18099)
|
44
|
+
puts info.inspect
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#list the recent checkins for Arrogant Bastard Ale
|
2
|
+
require 'rubygems'
|
3
|
+
require 'untappd'
|
4
|
+
|
5
|
+
Untappd.configure do |config|
|
6
|
+
config.apikey = 'YOUR_API_KEY'
|
7
|
+
end
|
8
|
+
|
9
|
+
checkins = Untappd::Beer.checkins(18099)
|
10
|
+
checkins.each do |checkin|
|
11
|
+
puts "#{checkin.user.first_name} at #{checkin.created_at}"
|
12
|
+
end
|
13
|
+
|
14
|
+
info = Untappd::Beer.info(18099)
|
15
|
+
puts "#{info.name} by #{info.brewery}"
|
16
|
+
puts info.inspect
|
17
|
+
|
18
|
+
# Example JSON response
|
19
|
+
# {
|
20
|
+
# "next_query":"http:\/\/api.untappd.com\/v3\/beer_checkins?bid=18099&since=603321",
|
21
|
+
# "next_page":"http:\/\/api.untappd.com\/v3\/beer_checkins?bid=18099&offset=25",
|
22
|
+
# "http_code":200,
|
23
|
+
# "results":
|
24
|
+
# [
|
25
|
+
# {
|
26
|
+
# "user":
|
27
|
+
# {
|
28
|
+
# "user_name":"JJP1115",
|
29
|
+
# "first_name":"Jim",
|
30
|
+
# "last_name":"P.",
|
31
|
+
# "user_avatar":"http:\/\/gravatar.com\/avatar.php?gravatar_id=a0bb3b077c11e0c087e53212bf49ba49&rating=X&size=80&default=https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/default_avatar.jpg",
|
32
|
+
# "location":"Berkeley,
|
33
|
+
# Illinois",
|
34
|
+
# "bio":"",
|
35
|
+
# "is_friends":null,
|
36
|
+
# "url":"http:\/\/www.facebook.com\/#!\/JPerez1115"
|
37
|
+
# },
|
38
|
+
# "checkin_id":"610208",
|
39
|
+
# "beer_id":"18099",
|
40
|
+
# "brewery_id":"1204",
|
41
|
+
# "beer_name":"Arrogant Bastard Ale",
|
42
|
+
# "brewery_name":"Stone Brewing Co.",
|
43
|
+
# "created_at":"Fri,
|
44
|
+
# 08 Apr 2011 05:24:23 +0000",
|
45
|
+
# "check_in_comment":"",
|
46
|
+
# "checkin_link":"http:\/\/untappd.com\/user\/JJP1115\/checkin\/NUekq56",
|
47
|
+
# "beer_stamp":"https:\/\/untappd.s3.amazonaws.com\/site\/beer_logos\/beer-arrogantBastardAle.jpg",
|
48
|
+
# "venue_name":null,
|
49
|
+
# "venue_id":null,
|
50
|
+
# "venue_lat":null,
|
51
|
+
# "venue_lng":null
|
52
|
+
# },
|
data/lib/untappd.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require "untappd/base"
|
4
|
+
require "untappd/beer"
|
5
|
+
|
6
|
+
module Untappd
|
7
|
+
@apikey = nil
|
8
|
+
|
9
|
+
def self.apikey
|
10
|
+
@@apikey
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.apikey=(apikey)
|
14
|
+
@@apikey = apikey
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
yield self
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/untappd/base.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'hashie'
|
3
|
+
|
4
|
+
module Untappd
|
5
|
+
|
6
|
+
class Base
|
7
|
+
include HTTParty
|
8
|
+
base_uri 'http://api.untappd.com/v3'
|
9
|
+
format :json
|
10
|
+
|
11
|
+
def self.response_to_mash(response)
|
12
|
+
if response.code == 200
|
13
|
+
Hashie::Mash.new(response).results
|
14
|
+
else
|
15
|
+
Hashie::Mash.new {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/untappd/beer.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Untappd
|
2
|
+
|
3
|
+
class Beer < Base
|
4
|
+
def self.checkins(beer_id, options={})
|
5
|
+
options.merge!({
|
6
|
+
:key => Untappd::apikey,
|
7
|
+
:bid => beer_id
|
8
|
+
})
|
9
|
+
|
10
|
+
response_to_mash get("/beer_checkins", :query => options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.info(beer_id, options={})
|
14
|
+
options.merge!({
|
15
|
+
:key => Untappd::apikey,
|
16
|
+
:bid => beer_id
|
17
|
+
})
|
18
|
+
|
19
|
+
response_to_mash get("/beer_info", :query => options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.search(q, options={})
|
23
|
+
options.merge!({
|
24
|
+
:key => Untappd::apikey,
|
25
|
+
:q => q
|
26
|
+
})
|
27
|
+
|
28
|
+
response_to_mash get("/beer_search", :query => options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/untappd.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "untappd/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "untappd"
|
7
|
+
s.version = Untappd::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["cmar"]
|
10
|
+
s.email = ["cmar@github.com"]
|
11
|
+
s.homepage = "http://cmar.me"
|
12
|
+
s.summary = %q{Wrapper around the untappd.com API}
|
13
|
+
s.description = %q{wrapper around the untappd.com API}
|
14
|
+
|
15
|
+
s.rubyforge_project = "untappd"
|
16
|
+
|
17
|
+
s.add_dependency('httparty', '>= 0.7.3')
|
18
|
+
s.add_dependency('hashie', '>= 1.0.0')
|
19
|
+
|
20
|
+
s.add_development_dependency('rspec')
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: untappd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- cmar
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-08 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: httparty
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 5
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 7
|
33
|
+
- 3
|
34
|
+
version: 0.7.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: hashie
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 23
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 1.0.0
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: wrapper around the untappd.com API
|
68
|
+
email:
|
69
|
+
- cmar@github.com
|
70
|
+
executables: []
|
71
|
+
|
72
|
+
extensions: []
|
73
|
+
|
74
|
+
extra_rdoc_files: []
|
75
|
+
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- README.rdoc
|
81
|
+
- Rakefile
|
82
|
+
- examples/aba_checkins.rb
|
83
|
+
- lib/untappd.rb
|
84
|
+
- lib/untappd/base.rb
|
85
|
+
- lib/untappd/beer.rb
|
86
|
+
- lib/untappd/version.rb
|
87
|
+
- spec/checkins_spec.rb
|
88
|
+
- untappd.gemspec
|
89
|
+
has_rdoc: true
|
90
|
+
homepage: http://cmar.me
|
91
|
+
licenses: []
|
92
|
+
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
requirements: []
|
117
|
+
|
118
|
+
rubyforge_project: untappd
|
119
|
+
rubygems_version: 1.6.2
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: Wrapper around the untappd.com API
|
123
|
+
test_files:
|
124
|
+
- spec/checkins_spec.rb
|