gowalla-ruby 0.0.1 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest CHANGED
@@ -3,15 +3,25 @@ README.markdown
3
3
  Rakefile
4
4
  init.rb
5
5
  lib/gowalla.rb
6
+ lib/gowalla/activity.rb
6
7
  lib/gowalla/address.rb
7
8
  lib/gowalla/base.rb
9
+ lib/gowalla/category.rb
8
10
  lib/gowalla/checkin.rb
11
+ lib/gowalla/event.rb
12
+ lib/gowalla/map_bound.rb
9
13
  lib/gowalla/spot.rb
10
14
  lib/gowalla/stamp.rb
15
+ lib/gowalla/top_10.rb
11
16
  lib/gowalla/user.rb
17
+ test/fixtures/event.json
18
+ test/fixtures/spot.json
19
+ test/fixtures/spots.json
12
20
  test/fixtures/stamps.json
13
21
  test/fixtures/user.json
14
22
  test/helper.rb
23
+ test/test_event.rb
24
+ test/test_spot.rb
15
25
  test/test_stamp.rb
16
26
  test/test_user.rb
17
27
  Manifest
@@ -1,33 +1,36 @@
1
1
  gowalla-ruby
2
2
  ===
3
3
 
4
- Gowalla API wrapper for Ruby.
4
+ Gowalla API wrapper for Ruby. Not yet intended for production use, thought it is functional and more tests are always being added.
5
5
 
6
6
  Install
7
7
  ===
8
8
  gem install gowalla-ruby
9
+ config.gem 'gowalla-ruby', :lib => 'gowalla' # in environment.rb
10
+
11
+ or
12
+
13
+ ./script/plugin install git@github.com:webandy/gowalla-ruby.git
9
14
 
10
15
  Usage
11
16
  ===
12
17
 
13
- # for Rails as a plugin
14
- >> ./script/plugin install git@github.com:webandy/gowalla-ruby.git
15
- >> ./script/console
16
- >> user = Gowalla::User.find('andyatkinson')
17
- >> user.stamps
18
+ user = Gowalla::User.find('andyatkinson')
19
+ user.stamps
20
+ spot = Gowalla::Spot.find(23534)
21
+ spot.checkins_count
22
+ spot.creator # returns a Gowalla::User
23
+ spot.top_10
24
+ spot.top_10.first.user # returns a Gowalla::User
25
+ spot.events.activity # see all checkins
26
+ spot.events.activity.first.user # see the user from a checkin
18
27
 
19
- # for Rails as a gem
20
- >> gem install gowalla-ruby
21
- >> config.gem 'gowalla', :lib => 'gowalla-ruby' # in environment.rb
22
- >> ./script/console
23
- >> user = Gowalla::User.find('andyatkinson')
24
- >> user.stamps
25
28
 
26
- # for Ruby
27
- >> irb -r rubygems
28
- >> require 'init'
29
- >> Gowalla::User.find('andyatkinson')
30
- >> Gowalla::Stamp.find('andyatkinson')
29
+ Some real world usages
30
+ ---
31
+ Gowalla::User.find('andyatkinson').stamps_count # => 80
32
+ Gowalla::User.find('andyatkinson').last_checkins.first.spot.name => "Tea Garden"
33
+ "http://gowalla.com" + Gowalla::User.find('andyatkinson').last_checkins.first.spot.url # url to Tea Garden on Gowalla.com
31
34
 
32
35
  Testing
33
36
  ===
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('gowalla-ruby', '0.0.1') do |p|
5
+ Echoe.new('gowalla-ruby', '0.0.5') do |p|
6
6
  p.description = "Gowalla API wrapper for Ruby"
7
7
  p.url = "http://github.com/webandy/gowalla-ruby"
8
8
  p.author = "Andy Atkinson"
@@ -2,22 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gowalla-ruby}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Andy Atkinson"]
9
- s.date = %q{2010-02-21}
9
+ s.date = %q{2010-03-07}
10
10
  s.description = %q{Gowalla API wrapper for Ruby}
11
11
  s.email = %q{andy@webandy.com}
12
- s.extra_rdoc_files = ["LICENSE", "README.markdown", "lib/gowalla.rb", "lib/gowalla/address.rb", "lib/gowalla/base.rb", "lib/gowalla/checkin.rb", "lib/gowalla/spot.rb", "lib/gowalla/stamp.rb", "lib/gowalla/user.rb"]
13
- s.files = ["LICENSE", "README.markdown", "Rakefile", "init.rb", "lib/gowalla.rb", "lib/gowalla/address.rb", "lib/gowalla/base.rb", "lib/gowalla/checkin.rb", "lib/gowalla/spot.rb", "lib/gowalla/stamp.rb", "lib/gowalla/user.rb", "test/fixtures/stamps.json", "test/fixtures/user.json", "test/helper.rb", "test/test_stamp.rb", "test/test_user.rb", "Manifest", "gowalla-ruby.gemspec"]
12
+ s.extra_rdoc_files = ["LICENSE", "README.markdown", "lib/gowalla.rb", "lib/gowalla/activity.rb", "lib/gowalla/address.rb", "lib/gowalla/base.rb", "lib/gowalla/category.rb", "lib/gowalla/checkin.rb", "lib/gowalla/event.rb", "lib/gowalla/map_bound.rb", "lib/gowalla/spot.rb", "lib/gowalla/stamp.rb", "lib/gowalla/top_10.rb", "lib/gowalla/user.rb"]
13
+ s.files = ["LICENSE", "README.markdown", "Rakefile", "init.rb", "lib/gowalla.rb", "lib/gowalla/activity.rb", "lib/gowalla/address.rb", "lib/gowalla/base.rb", "lib/gowalla/category.rb", "lib/gowalla/checkin.rb", "lib/gowalla/event.rb", "lib/gowalla/map_bound.rb", "lib/gowalla/spot.rb", "lib/gowalla/stamp.rb", "lib/gowalla/top_10.rb", "lib/gowalla/user.rb", "test/fixtures/event.json", "test/fixtures/spot.json", "test/fixtures/spots.json", "test/fixtures/stamps.json", "test/fixtures/user.json", "test/helper.rb", "test/test_event.rb", "test/test_spot.rb", "test/test_stamp.rb", "test/test_user.rb", "Manifest", "gowalla-ruby.gemspec"]
14
14
  s.homepage = %q{http://github.com/webandy/gowalla-ruby}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gowalla-ruby", "--main", "README.markdown"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{gowalla-ruby}
18
18
  s.rubygems_version = %q{1.3.5}
19
19
  s.summary = %q{Gowalla API wrapper for Ruby}
20
- s.test_files = ["test/test_stamp.rb", "test/test_user.rb"]
20
+ s.test_files = ["test/test_event.rb", "test/test_spot.rb", "test/test_stamp.rb", "test/test_user.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
data/init.rb CHANGED
@@ -5,4 +5,9 @@ require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'user')
5
5
  require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'spot')
6
6
  require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'stamp')
7
7
  require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'checkin')
8
- require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'address')
8
+ require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'address')
9
+ require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'event')
10
+ require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'activity')
11
+ require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'category')
12
+ require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'map_bound')
13
+ require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'top_10')
@@ -0,0 +1,13 @@
1
+ module Gowalla
2
+ class Activity
3
+ attr_accessor :type, :message, :user, :created_at, :activity
4
+
5
+ def initialize(data={})
6
+ @type = data['type']
7
+ @message = data['message']
8
+ @user = User.new(data['user'])
9
+ @created_at = DateTime.parse(data['created_at'])
10
+ @activity = data['activity']
11
+ end
12
+ end
13
+ end
@@ -2,7 +2,7 @@ module Gowalla
2
2
  class Address
3
3
  attr_accessor :region, :locality
4
4
 
5
- def initialize(data)
5
+ def initialize(data={})
6
6
  @region = data['region']
7
7
  @locality = data['locality']
8
8
  end
@@ -0,0 +1,10 @@
1
+ module Gowalla
2
+ class Category
3
+ attr_accessor :name, :url
4
+
5
+ def initialize(data={})
6
+ @name = data['name']
7
+ @url = data['url']
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module Gowalla
2
+ # Retrieve a list of check-ins at a particular spot. Shows only the activity that is visible to a given user.
3
+ # model is singular. activities is an array for a given event.
4
+ class Event < Base
5
+ attr_accessor :url, :activity
6
+
7
+ def initialize(data={})
8
+ @url = data['url']
9
+ @activity = data['activity'].map{|activity| Activity.new(activity)}
10
+ end
11
+
12
+ protected
13
+ def self.fetch(id)
14
+ get("/spots/#{id}/events", :headers => {'Accept' => 'application/json'})
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ module Gowalla
2
+ class MapBound
3
+ attr_accessor :north, :south, :east, :west
4
+
5
+ def initialize(data={})
6
+ @north = data['north']
7
+ @south = data['south']
8
+ @east = data['east']
9
+ @west = data['west']
10
+ end
11
+ end
12
+ end
@@ -1,13 +1,51 @@
1
1
  module Gowalla
2
2
  class Spot < Base
3
- attr_accessor :name, :address, :url, :image_url
3
+ attr_accessor :name, :address, :url, :image_url, :activity_url, :radius_meters, :remove_bookmark_url, :checkins_url, :checkins_count, :items_count, :facebook_url, :websites, :founders, :created_at, :description, :bookmarks_url, :max_items_count, :trending_level, :lat, :lng, :users_count, :twitter_username, :creator, :list_image_url_320, :spot_categories, :items_url, :strict_radius, :map_bounds, :phone_number, :address, :top_10
4
4
 
5
- def initialize(data)
5
+ def initialize(data={})
6
6
  @name = data['name']
7
7
  @address = Address.new(data['address']) if !data['address'].blank?
8
8
  @url = data['url']
9
9
  @image_url = data['image_url']
10
+ @activity_url = data['activity_url']
11
+ @radius_meters = data['radius_meters']
12
+ @remove_bookmark_url = data['remove_bookmark_url']
13
+ @checkins_url = data['checkins_url']
14
+ @checkins_count = data['checkins_count']
15
+ @items_count = data['items_count']
16
+ @facebook_url = data['facebook_url']
17
+ @websites = data['websites']
18
+ @founders = data['founders'].map{|user| User.new(user)} unless data['founders'].blank?
19
+ @created_at = data['created_at']
20
+ @description = data['description']
21
+ @bookmarks_url = data['bookmarks_url']
22
+ @max_items_count = data['max_items_count']
23
+ @trending_level = data['trending_level']
24
+ @lat = data['lat']
25
+ @lng = data['lng']
26
+ @users_count = data['users_count']
27
+ @twitter_username = data['twitter_username']
28
+ @creator = User.new(data['creator']) unless data['creator'].blank?
29
+ @list_image_url_320 = data['list_image_url_320']
30
+ @items_url = data['items_url']
31
+ @spot_categories = data['spot_categories'].map{|c| Category.new(c)} unless data['spot_categories'].blank?
32
+ @strict_radius = data['strict_radius']
33
+ @map_bounds = MapBound.new(data['map_bounds']) unless data['map_bounds'].blank?
34
+ @phone_number = data['phone_number']
35
+ @top_10 = data['top_10'].map{|top_10| Top10.new(top_10)} unless data['top_10'].blank?
10
36
  end
37
+ def self.find(id)
38
+ Spot.new(self.fetch(id))
39
+ end
40
+ def events
41
+ event_id = self.activity_url.split("/")[2] # TODO probably better way
42
+ Event.new(Event.fetch(event_id))
43
+ end
44
+
45
+ protected
46
+ def self.fetch(id)
47
+ get("/spots/#{id}", :headers => {'Accept' => 'application/json'})
48
+ end
11
49
 
12
50
  end
13
51
  end
@@ -2,7 +2,7 @@ module Gowalla
2
2
  class Stamp < Base
3
3
  attr_accessor :spot, :checkins_count, :first_checkin_at, :last_checkin_at
4
4
 
5
- def initialize(data)
5
+ def initialize(data={})
6
6
  @spot = Spot.new(data['spot'])
7
7
  @checkins_count = data['checkins_count']
8
8
  @first_checkin_at = DateTime.parse(data['first_checkin_at'])
@@ -0,0 +1,17 @@
1
+ module Gowalla
2
+ class Top10
3
+ attr_accessor :checkins_count, :first_name, :last_name, :url, :image_url
4
+
5
+ def initialize(data={})
6
+ @checkins_count = data['checkins_count']
7
+ @first_name = data['first_name']
8
+ @last_name = data['last_name']
9
+ @url = data['url']
10
+ @image_url = data['image_url']
11
+ end
12
+
13
+ def user
14
+ User.find(self.url.split("/users/").last) # grab the user id
15
+ end
16
+ end
17
+ end
@@ -24,7 +24,7 @@ module Gowalla
24
24
  @add_friend_url = data['add_friend_url']
25
25
  @friends_url = data['friends_url']
26
26
  @_is_friend = data['_is_friend']
27
- @last_checkins = data['last_checkins'].map{|checkin| Checkin.new(checkin)}
27
+ @last_checkins = data['last_checkins'].map{|checkin| Checkin.new(checkin)} unless data['last_checkins'].blank?
28
28
  @pins_count = data['pins_count']
29
29
  end
30
30
  def self.find(username)
@@ -0,0 +1,195 @@
1
+ {
2
+ "url": "/spots/18568",
3
+ "activity": [{
4
+ "type": "checkin",
5
+ "message": "Obligatacos",
6
+ "user": {
7
+ "first_name": "Phillip",
8
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/12-standard.jpg?1249405659",
9
+ "url": "/users/12",
10
+ "last_name": "Bowden"
11
+ },
12
+ "created_at": "2010-02-22T01:25:06+00:00",
13
+ "activity": []
14
+ },
15
+ {
16
+ "type": "checkin",
17
+ "message": "Best queso evvvvver.",
18
+ "user": {
19
+ "first_name": "MK ",
20
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/114792-standard.jpg?1265692718",
21
+ "url": "/users/114792",
22
+ "last_name": "Butler"
23
+ },
24
+ "created_at": "2010-02-20T03:38:06+00:00",
25
+ "activity": []
26
+ },
27
+ {
28
+ "type": "checkin",
29
+ "message": "",
30
+ "user": {
31
+ "first_name": "Tommy",
32
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/61820-standard.jpg?1261076899",
33
+ "url": "/users/61820",
34
+ "last_name": "Davis"
35
+ },
36
+ "created_at": "2010-02-20T03:35:36+00:00",
37
+ "activity": []
38
+ },
39
+ {
40
+ "type": "checkin",
41
+ "message": "",
42
+ "user": {
43
+ "first_name": "Rob",
44
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/3104-standard.jpg?1253304471",
45
+ "url": "/users/3104",
46
+ "last_name": "Mack"
47
+ },
48
+ "created_at": "2010-02-19T22:37:34+00:00",
49
+ "activity": []
50
+ },
51
+ {
52
+ "type": "checkin",
53
+ "message": "",
54
+ "user": {
55
+ "first_name": "Geoff",
56
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/6417-standard.jpg?1254429296",
57
+ "url": "/users/6417",
58
+ "last_name": "Lou"
59
+ },
60
+ "created_at": "2010-02-19T19:07:48+00:00",
61
+ "activity": []
62
+ },
63
+ {
64
+ "type": "checkin",
65
+ "message": "",
66
+ "user": {
67
+ "first_name": "Keegan",
68
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/5-standard.jpg?1253829277",
69
+ "url": "/users/5",
70
+ "last_name": "Jones"
71
+ },
72
+ "created_at": "2010-02-19T02:43:45+00:00",
73
+ "activity": []
74
+ },
75
+ {
76
+ "type": "checkin",
77
+ "message": "",
78
+ "user": {
79
+ "first_name": "Willy",
80
+ "image_url": "http://gowalla.com/images/default-user.jpg",
81
+ "url": "/users/122330",
82
+ "last_name": "Wonka"
83
+ },
84
+ "created_at": "2010-02-18T23:41:51+00:00",
85
+ "activity": []
86
+ },
87
+ {
88
+ "type": "checkin",
89
+ "message": "",
90
+ "user": {
91
+ "first_name": "Blake",
92
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/132-standard.jpg?1236965251",
93
+ "url": "/users/132",
94
+ "last_name": "Burris"
95
+ },
96
+ "created_at": "2010-02-18T18:45:51+00:00",
97
+ "activity": []
98
+ },
99
+ {
100
+ "type": "checkin",
101
+ "message": "",
102
+ "user": {
103
+ "first_name": "Amy",
104
+ "image_url": "http://gowalla.com/images/default-user.jpg",
105
+ "url": "/users/53327",
106
+ "last_name": "Delk"
107
+ },
108
+ "created_at": "2010-02-18T02:20:12+00:00",
109
+ "activity": []
110
+ },
111
+ {
112
+ "type": "checkin",
113
+ "message": "",
114
+ "user": {
115
+ "first_name": "Weston",
116
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/97465-standard.jpg?1264027703",
117
+ "url": "/users/97465",
118
+ "last_name": "Sewell"
119
+ },
120
+ "created_at": "2010-02-18T01:31:23+00:00",
121
+ "activity": []
122
+ },
123
+ {
124
+ "type": "checkin",
125
+ "message": "",
126
+ "user": {
127
+ "first_name": "Back",
128
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/57629-standard.jpg?1264621883",
129
+ "url": "/users/57629",
130
+ "last_name": "Hand"
131
+ },
132
+ "created_at": "2010-02-17T18:18:25+00:00",
133
+ "activity": []
134
+ },
135
+ {
136
+ "type": "checkin",
137
+ "message": "Refueling",
138
+ "user": {
139
+ "first_name": "Susan",
140
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/38153-standard.jpg?1261953895",
141
+ "url": "/users/38153",
142
+ "last_name": "Pevovar"
143
+ },
144
+ "created_at": "2010-02-14T19:38:15+00:00",
145
+ "activity": []
146
+ },
147
+ {
148
+ "type": "checkin",
149
+ "message": "",
150
+ "user": {
151
+ "first_name": "Cynthia Ruth",
152
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/62151-standard.jpg?1264486348",
153
+ "url": "/users/62151",
154
+ "last_name": "Nava"
155
+ },
156
+ "created_at": "2010-02-14T01:48:11+00:00",
157
+ "activity": []
158
+ },
159
+ {
160
+ "type": "checkin",
161
+ "message": "",
162
+ "user": {
163
+ "first_name": "Joe",
164
+ "image_url": "http://gowalla.com/images/default-user.jpg",
165
+ "url": "/users/84619",
166
+ "last_name": "Liemandr"
167
+ },
168
+ "created_at": "2010-02-13T23:40:53+00:00",
169
+ "activity": []
170
+ },
171
+ {
172
+ "type": "checkin",
173
+ "message": "my wife's favorite ... it's been a long time!",
174
+ "user": {
175
+ "first_name": "Kye S.",
176
+ "image_url": "http://s3.amazonaws.com/static.gowalla.com/users/4758-standard.jpg?1261603239",
177
+ "url": "/users/4758",
178
+ "last_name": "Chung"
179
+ },
180
+ "created_at": "2010-02-13T00:36:03+00:00",
181
+ "activity": []
182
+ },
183
+ {
184
+ "type": "checkin",
185
+ "message": "",
186
+ "user": {
187
+ "first_name": "Adam",
188
+ "image_url": "http://gowalla.com/images/default-user.jpg",
189
+ "url": "/users/102739",
190
+ "last_name": "LaRue"
191
+ },
192
+ "created_at": "2010-02-12T17:34:49+00:00",
193
+ "activity": []
194
+ }]
195
+ }