untappd 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- untappd (0.0.1)
4
+ untappd (0.0.2)
5
5
  hashie (>= 1.0.0)
6
6
  httparty (>= 0.7.3)
7
7
 
data/README.rdoc CHANGED
@@ -9,6 +9,7 @@ This is a simple wrapper around the untappd API packaged as a ruby gem.
9
9
 
10
10
  == Releases
11
11
 
12
+ * 0.0.2 User feed, distinct beers, info, badges, friends, wish list
12
13
  * 0.0.1 Beer Search, Info and Checkins
13
14
 
14
15
  == Examples
@@ -20,7 +21,7 @@ Configure your API KEY
20
21
 
21
22
  Get all the checkins for Arrogant Bastard Ale
22
23
 
23
- checkins = Untappd.beer_checkins(18099)
24
+ checkins = Untappd::Beer.checkins(18099)
24
25
  checkins.each do |checkin|
25
26
  puts "#{checkin.user.first_name} at #{checkin.created_at}"
26
27
  end
@@ -37,8 +38,44 @@ Get extended info for Arrogant Bastard Ale
37
38
  info = Untappd::Beer.info(18099)
38
39
  puts "#{info.name} by #{info.brewery}"
39
40
 
41
+ All Methods can take additional options specified in the API
42
+
43
+ checkins = Untappd::Beer.checkins(18099, :offset => 100)
44
+
45
+ beers = Untappd::Beer.search('stone', :sort => "count")
46
+
40
47
  == Debugging
41
48
  You can dump any result to see what values are available with
42
49
 
43
50
  info = Untappd::Beer.info(18099)
44
- puts info.inspect
51
+ puts info.inspect
52
+
53
+ == API Coverage
54
+
55
+ Beer Object
56
+ * Beer Feed - done
57
+ * Beer Info - done
58
+ * Beer Search - done
59
+
60
+ User Object
61
+ * User Feed - done
62
+ * User Info - done
63
+ * User Badges - done
64
+ * User Friends - done
65
+ * User Wish List - done
66
+ * User Distinct Beers - done
67
+
68
+ TODO
69
+ * Friend Feed
70
+ * The Pub Feed
71
+ * Venue Feed
72
+ * Brewery Checkins
73
+ * Venue Info
74
+ * Checkin Info
75
+ * Trending
76
+ * Checkin (Test)
77
+ * Checkin
78
+ * Add Comment
79
+ * Remove Comment
80
+ * Toast
81
+ * Remove Toast
@@ -0,0 +1,12 @@
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
+ feed = Untappd::User.feed("cmar")
10
+ feed.each do |f|
11
+ puts "#{f.user.first_name} at #{f.created_at}"
12
+ end
data/lib/untappd.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
 
3
3
  require "untappd/base"
4
4
  require "untappd/beer"
5
+ require "untappd/user"
5
6
 
6
7
  module Untappd
7
8
  @apikey = nil
data/lib/untappd/beer.rb CHANGED
@@ -29,4 +29,4 @@ module Untappd
29
29
  end
30
30
  end
31
31
 
32
- end
32
+ end
@@ -0,0 +1,60 @@
1
+ module Untappd
2
+
3
+ class User < Base
4
+
5
+ def self.info(user, options={})
6
+ options.merge!({
7
+ :key => Untappd::apikey,
8
+ :user => user
9
+ })
10
+
11
+ response_to_mash get("/user", :query => options)
12
+ end
13
+
14
+ def self.badges(user, options={})
15
+ options.merge!({
16
+ :key => Untappd::apikey,
17
+ :user => user
18
+ })
19
+
20
+ response_to_mash get("/user_badge", :query => options)
21
+ end
22
+
23
+ def self.friends(user, options={})
24
+ options.merge!({
25
+ :key => Untappd::apikey,
26
+ :user => user
27
+ })
28
+
29
+ response_to_mash get("/friends", :query => options)
30
+ end
31
+
32
+ def self.wish_list(user, options={})
33
+ options.merge!({
34
+ :key => Untappd::apikey,
35
+ :user => user
36
+ })
37
+
38
+ response_to_mash get("/wish_list", :query => options)
39
+ end
40
+
41
+ def self.distinct(user, options={})
42
+ options.merge!({
43
+ :key => Untappd::apikey,
44
+ :user => user
45
+ })
46
+
47
+ response_to_mash get("/distinct", :query => options)
48
+ end
49
+
50
+ def self.feed(user, options={})
51
+ options.merge!({
52
+ :key => Untappd::apikey,
53
+ :user => user
54
+ })
55
+
56
+ response_to_mash get("/user_feed", :query => options)
57
+ end
58
+ end
59
+
60
+ end
@@ -1,3 +1,3 @@
1
1
  module Untappd
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/beer_spec.rb ADDED
@@ -0,0 +1,55 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "Beer" do
4
+
5
+ before(:all) do
6
+ Untappd.configure do |config|
7
+ config.apikey = '6666666666666666666666'
8
+ end
9
+ end
10
+
11
+ before(:each) do
12
+ @response = {:results =>[]}
13
+ @response.stub(:code => 200)
14
+ Untappd::Beer.stub(:get => @response)
15
+ end
16
+
17
+ it "should get checkins" do
18
+ @response[:results] << {:checkin_id => "610208",
19
+ :beer_id => "18099",
20
+ :beer_name => "Arrogant Bastard Ale",
21
+ :brewery_name => "Stone Brewing Co."}
22
+
23
+ checkins = Untappd::Beer.checkins(18099)
24
+ checkins.first.beer_name.should == "Arrogant Bastard Ale"
25
+ end
26
+
27
+ it "should get info" do
28
+ @response[:results] = {:brewery_id => "1204",
29
+ :beer_id => "18099",
30
+ :name => "Arrogant Bastard Ale",
31
+ :brewery => "Stone Brewing Co."}
32
+
33
+ info = Untappd::Beer.info(18099)
34
+ info.name.should == "Arrogant Bastard Ale"
35
+ end
36
+
37
+ it "should search" do
38
+ @response[:results] << {:beer_id => "18099",
39
+ :beer_name => "Arrogant Bastard Ale",
40
+ :brewery_name => "Stone Brewing Co."}
41
+
42
+ search = Untappd::Beer.info('stone')
43
+ search.first.beer_name.should == "Arrogant Bastard Ale"
44
+ end
45
+
46
+ end
47
+
48
+ #beer checkin JSON
49
+ #{"next_query":"http:\/\/api.untappd.com\/v3\/beer_checkins?bid=18099&since=610053","next_page":"http:\/\/api.untappd.com\/v3\/beer_checkins?bid=18099&offset=25","http_code":200,"results":[{"user":{"user_name":"micek","first_name":"Cory","last_name":"M.","user_avatar":"https:\/\/untappd.s3.amazonaws.com\/profile\/0d781dfce6d3acfdfbbe9f2692a0d0e4_thumb.jpg","location":"San Diego, CA","bio":"interactive designer\/developer\/creativist, obsessed with user experience, loose leaf teas and micro brews","is_friends":null,"url":""},"checkin_id":"618853","beer_id":"18099","brewery_id":"1204","beer_name":"Arrogant Bastard Ale","brewery_name":"Stone Brewing Co.","created_at":"Sat, 09 Apr 2011 05:27:09 +0000","check_in_comment":"","checkin_link":"http:\/\/untappd.com\/user\/micek\/checkin\/BETZs89","beer_stamp":"https:\/\/untappd.s3.amazonaws.com\/site\/beer_logos\/beer-arrogantBastardAle.jpg","venue_name":"El Take It Easy","venue_id":"272","venue_lat":"32.749","venue_lng":"-117.13"}
50
+
51
+ #beer info JSON
52
+ # {"http_code":200,"results":{"name":"Arrogant Bastard Ale","beer_id":"18099","brewery":"Stone Brewing Co.","brewery_id":"1204","img":"https:\/\/untappd.s3.amazonaws.com\/site\/beer_logos\/beer-arrogantBastardAle.jpg","total_count":"1553","unique_count":"1041","monthly_count":"193","weekly_count":"161","beer_abv":"7.2","beer_created":"Mon, 27 Dec 2010 20:34:38 +0000","type":"American Strong Ale","beer_creator":"Firmansyah","beer_creator_id":"9041"}}
53
+
54
+ #beer search JSON
55
+ #{"search_term":"stone","http_code":200,"returned_results":25,"next_page":"http:\/\/api.untappd.com\/v3\/beer_search?q=stone&offset=25","results":[{"beer_id":"29100","beer_name":" Arrogant Bastard Ale Aged In Bourbon Barrels","beer_stamp":"https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/temp\/badge-beer-default.png","brewery_id":"1204","brewery_name":"Stone Brewing Co.","brewery_stamp":"https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/temp\/badge-brewery-default.png","country_name":"United States","total_count":"11"}
@@ -0,0 +1,4 @@
1
+ $TESTING=true
2
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ require 'untappd'
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "Untappd" do
4
+
5
+ it "should configure Rails initializer style" do
6
+ Untappd.configure do |config|
7
+ config.apikey = 'c01822f029486661bb3669a845b5ec14'
8
+ end
9
+
10
+ Untappd.apikey.should eq 'c01822f029486661bb3669a845b5ec14'
11
+ end
12
+
13
+ end
data/spec/user_spec.rb ADDED
@@ -0,0 +1,100 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "User" do
4
+
5
+ before(:all) do
6
+ Untappd.configure do |config|
7
+ config.apikey = '6666666666666666666666'
8
+ end
9
+ end
10
+
11
+ before(:each) do
12
+ @response = {:results =>[]}
13
+ @response.stub(:code => 200)
14
+ Untappd::User.stub(:get => @response)
15
+ end
16
+
17
+ it "should get info" do
18
+ @response[:results] = {:user => {
19
+ :user_name => "cmar",
20
+ :first_name => "cmar"
21
+ }
22
+ }
23
+
24
+ info = Untappd::User.info("cmar")
25
+ info.user.user_name.should == "cmar"
26
+ end
27
+
28
+ it "should get badges" do
29
+ @response[:results] << {
30
+ :badge_name => "Newbie",
31
+ :checkin_id => "413105"
32
+ }
33
+
34
+ badges = Untappd::User.badges("cmar")
35
+ badges.first.badge_name.should == "Newbie"
36
+ end
37
+
38
+ it "should get friends" do
39
+ @response[:results] << {
40
+ :user_name => "pks1850",
41
+ :user_id => "10819"
42
+ }
43
+
44
+ friends = Untappd::User.friends("cmar")
45
+ friends.first.user_name.should == "pks1850"
46
+ end
47
+
48
+ it "should get the wish list" do
49
+ @response[:results] << {
50
+ :user => {:user_name => "cmar"},
51
+ :beer_name => "Aprihop",
52
+ :beer_id => "4665"
53
+ }
54
+
55
+ wish_list = Untappd::User.wish_list("cmar")
56
+ wish_list.first.beer_name.should == "Aprihop"
57
+ end
58
+
59
+ it "should get distinct beers" do
60
+ @response[:results] << {
61
+ :user => {:user_name => "cmar"},
62
+ :beer_name => "Aprihop",
63
+ :beer_id => "4665"
64
+ }
65
+
66
+ distinct_beers = Untappd::User.distinct("cmar")
67
+ distinct_beers.first.beer_name.should == "Aprihop"
68
+ end
69
+
70
+ it "should get feed" do
71
+ @response[:results] << {
72
+ :user => {:user_name => "cmar"},
73
+ :beer_name => "Aprihop",
74
+ :checkin_id => "551239"
75
+ }
76
+
77
+ feed = Untappd::User.feed("cmar")
78
+ feed.first.beer_name.should == "Aprihop"
79
+ end
80
+
81
+ end
82
+
83
+ #User feed JSON
84
+ #{"http_code":200,"returned_results":2,"next_query":"http:\/\/api.untappd.com\/v3\/user_feed?user=cmar&since=551239","next_page":"http:\/\/api.untappd.com\/v3\/user_feed?user=cmar&offset=25","results":[{"user":{"user_name":"cmar","first_name":"cmar","last_name":"","user_avatar":"http:\/\/gravatar.com\/avatar.php?gravatar_id=cf989ae1f7ddd979f38b00ec033a0e7d&amp;rating=X&amp;size=80&amp;default=https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/default_avatar.jpg","location":"Leesburg, VA","bio":"","is_friends":null,"url":""},"checkin_id":"551239","beer_id":"4665","brewery_id":"459","beer_name":"Aprihop","brewery_name":"Dogfish Head Craft Brewery","created_at":"Wed, 30 Mar 2011 20:03:03 +0000","check_in_comment":"Love this beer. Similar to Magic Hat #9","checkin_link":"http:\/\/untappd.com\/user\/cmar\/checkin\/551239","beer_stamp":"https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/temp\/badge-beer-default.png","venue_name":null,"venue_id":null,"venue_lat":null,"venue_lng":null},
85
+
86
+ #User distinct JSON
87
+ #{"http_code":200,"returned_results":2,"next_page":"http:\/\/api.untappd.com\/v3\/user_distinct\/cmar?offset=25","results":[{"user":{"user_name":"cmar","first_name":"cmar","last_name":"","user_avatar":"http:\/\/gravatar.com\/avatar.php?gravatar_id=cf989ae1f7ddd979f38b00ec033a0e7d&amp;rating=X&amp;size=80&amp;default=https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/default_avatar.jpg","location":"Leesburg, VA","bio":"","is_friends":null,"url":""},"beer_id":"4665","brewery_id":"459","checkin_id":"551239","beer_name":"Aprihop","brewery_name":"Dogfish Head Craft Brewery","created_at":"Wed, 30 Mar 2011 20:03:03 +0000","checkin_link":"http:\/\/untappd.com\/user\/cmar\/checkin\/551239","beer_stamp":"https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/temp\/badge-beer-default.png"},
88
+
89
+ #User wishlist JSON
90
+ #{"http_code":200,"returned_results":2,"results":[{"user":{"user_name":"cmar","first_name":"cmar","last_name":"","user_avatar":"http:\/\/gravatar.com\/avatar.php?gravatar_id=cf989ae1f7ddd979f38b00ec033a0e7d&amp;rating=X&amp;size=80&amp;default=https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/default_avatar.jpg","location":"Leesburg, VA","bio":"","is_friends":null,"url":""},"beer_name":"Aprihop","beer_id":"4665","brewery_id":"459","brewery_name":"Dogfish Head Craft Brewery","created_at":"Wed, 30 Mar 2011 20:03:27 +0000","beer_stamp":"https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/temp\/badge-beer-default.png"},
91
+
92
+ #User friends JSON
93
+ #{"http_code":200,"returned_results":1,"next_page":"http:\/\/api.untappd.com\/v3\/friends\/cmar?offset=25","results":[{"user_id":"10819","user_name":"pks1850","first_name":"sam","last_name":"","user_avatar":"http:\/\/gravatar.com\/avatar.php?gravatar_id=414bd46a3e2ccdb0620d80a30c088ac2&amp;rating=X&amp;size=80&amp;default=https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/default_avatar.jpg","location":"","bio":"","is_friends":null,"is_requested":null,"url":"http:\/\/WWW.TEST.COM","date_joined":"Thu, 23 Dec 2010 16:58:12 +0000","is_private":"0"}]}
94
+
95
+ #User Badges JSON
96
+ #{"http_code":200,"returned_results":1,"results":[{"badge_name":"Newbie","checkin_id":"413105","badge_description":"So, you're new around here? Congrats on your first brew! This ones for you.","badge_image_sm":"https:\/\/untappd.s3.amazonaws.com\/assets\/badges\/bdg_newbie_sm.png","badge_image_md":"https:\/\/untappd.s3.amazonaws.com\/assets\/badges\/bdg_newbie_md.png","badge_image_lg":"https:\/\/untappd.s3.amazonaws.com\/assets\/badges\/bdg_newbie_lg.png","badge_category":"Beer Badges","badge_earned_date":"Mon, 07 Mar 2011 01:45:07 +0000","badge_link":"http:\/\/untappd.com\/user\/cmar\/badge\/58708"}]}
97
+
98
+
99
+ #User Info JSON
100
+ #{"http_code":200,"results":{"user":{"user_name":"cmar","first_name":"cmar","last_name":"","user_avatar":"http:\/\/gravatar.com\/avatar.php?gravatar_id=cf989ae1f7ddd979f38b00ec033a0e7d&amp;rating=X&amp;size=80&amp;default=https:\/\/untappd.s3.amazonaws.com\/site\/assets\/images\/default_avatar.jpg","location":"Leesburg, VA","bio":"","is_friends":null,"url":"","date_joined":"Thu, 23 Dec 2010 17:22:26 +0000","is_private":"0","total_badges":"1","total_friends":"1","total_checkins":"2","total_beers":"2","total_created_beers":"0","social_accounts":{"facebook":true,"twitter":true,"foursquare":true}}}}
data/untappd.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency('httparty', '>= 0.7.3')
18
18
  s.add_dependency('hashie', '>= 1.0.0')
19
19
 
20
- s.add_development_dependency('rspec')
20
+ s.add_development_dependency('rspec', '>= 2.5.1')
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
23
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: untappd
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - cmar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-08 00:00:00 -04:00
18
+ date: 2011-04-11 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -58,10 +58,12 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- hash: 3
61
+ hash: 25
62
62
  segments:
63
- - 0
64
- version: "0"
63
+ - 2
64
+ - 5
65
+ - 1
66
+ version: 2.5.1
65
67
  type: :development
66
68
  version_requirements: *id003
67
69
  description: wrapper around the untappd.com API
@@ -80,11 +82,16 @@ files:
80
82
  - README.rdoc
81
83
  - Rakefile
82
84
  - examples/aba_checkins.rb
85
+ - examples/user_feed.rb
83
86
  - lib/untappd.rb
84
87
  - lib/untappd/base.rb
85
88
  - lib/untappd/beer.rb
89
+ - lib/untappd/user.rb
86
90
  - lib/untappd/version.rb
87
- - spec/checkins_spec.rb
91
+ - spec/beer_spec.rb
92
+ - spec/spec_helper.rb
93
+ - spec/untappd_spec.rb
94
+ - spec/user_spec.rb
88
95
  - untappd.gemspec
89
96
  has_rdoc: true
90
97
  homepage: http://cmar.me
@@ -121,4 +128,7 @@ signing_key:
121
128
  specification_version: 3
122
129
  summary: Wrapper around the untappd.com API
123
130
  test_files:
124
- - spec/checkins_spec.rb
131
+ - spec/beer_spec.rb
132
+ - spec/spec_helper.rb
133
+ - spec/untappd_spec.rb
134
+ - spec/user_spec.rb
@@ -1,5 +0,0 @@
1
- describe 'checkins' do
2
-
3
- pending 'write tests please!'
4
-
5
- end