gowalla 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Wynn Netherland
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Gowalla
2
+
3
+ Ruby wrapper for (most) of the (unreleased) Gowalla API.
4
+
5
+ *Note: The Gowalla API is unannounced. This wrapper consumes what I've been able to sniff out using [Charles Proxy](http://www.charlesproxy.com/) and my iPhone.*
6
+
7
+ ## Installation
8
+
9
+ sudo gem install gowalla
10
+
11
+ ## Usage
12
+
13
+ ### Public requests
14
+
15
+ >> Gowalla.user('pengwynn')
16
+ => <#Hashie::Mash accept_url="/friendships/accept?user_id=1707" activity_url="/users/1707/events" bio="Web designer and Ruby developer." events_url="/users/1707/events" fb_id=605681706 first_name="Wynn" friends_count=27 friends_only=false friends_url="/users/1707/friends" hometown="Aubrey, TX" image_url="http://s3.amazonaws.com/static.gowalla.com/users/1707-standard.jpg?1262011383" is_friend=false items_count=5 items_url="/users/1707/items" last_name="Netherland" last_visit=<#Hashie::Mash comment="Closing every account I have " created_at="2010/01/26 15:31:46 +0000" spot=<#Hashie::Mash image_url="http://static.gowalla.com/categories/186-standard.png" name="Bank Of America" small_image_url="http://static.gowalla.com/categories/186-small-standard.png" url="/spots/164052">> name="Wynn Netherland" pins_count=3 pins_url="/users/1707/pins" reject_url="/friendships/reject?user_id=1707" request_url="/friendships/request?user_id=1707" stamps_count=15 stamps_url="/users/1707/stamps" top_spots_url="/users/1707/top_spots" twitter_username="pengwynn" url="/users/1707" username="pengwynn" vaulted_kinds_count=0 visited_spots_count=15 website="http://wynnnetherland.com">
17
+
18
+ ### Authenticated requests
19
+
20
+ >> gowalla = Gowalla::Client.new('pengwynn', 'somepassword')
21
+
22
+ #### Details for the current user
23
+
24
+ >> gowalla.user
25
+
26
+ #### Details for another user
27
+
28
+ >> gowalla.user('bradleyjoyce')
29
+ >> gowalla.user(1707)
30
+
31
+ Docs to come once the API is released. For now check out the source.
32
+
33
+ TODO:
34
+
35
+ * Create spots
36
+ * Accept/reject friendship
37
+ * Drop/pickup items
38
+
39
+ ## Note on Patches/Pull Requests
40
+
41
+ * Fork the project.
42
+ * Make your feature addition or bug fix.
43
+ * Add tests for it. This is important so I don't break it in a
44
+ future version unintentionally.
45
+ * Commit, do not mess with rakefile, version, or history.
46
+ (if you want to have your own version, that is fine but
47
+ bump version in a commit by itself I can ignore when I pull)
48
+ * Send me a pull request. Bonus points for topic branches.
49
+
50
+ ## Copyright
51
+
52
+ Copyright (c) 2010 Wynn Netherland. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "gowalla"
8
+ gem.summary = %Q{Ruby wrapper for the Gowalla API}
9
+ gem.description = %Q{Ruby wrapper for the Gowalla API}
10
+ gem.email = "wynn.netherland@gmail.com"
11
+ gem.homepage = "http://github.com/pengwynn/gowalla"
12
+ gem.authors = ["Wynn Netherland"]
13
+
14
+ gem.add_dependency('hashie', '>= 0.1.3')
15
+ gem.add_dependency('httparty', '>= 0.5.0')
16
+
17
+ gem.add_development_dependency('thoughtbot-shoulda', '>= 2.10.1')
18
+ gem.add_development_dependency('jnunemaker-matchy', '0.4.0')
19
+ gem.add_development_dependency('fakeweb', '>= 1.2.5')
20
+ gem.add_development_dependency "yard", ">= 0"
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
25
+ end
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.libs << 'lib' << 'test'
30
+ test.pattern = 'test/**/test_*.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ begin
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ end
41
+ rescue LoadError
42
+ task :rcov do
43
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
44
+ end
45
+ end
46
+
47
+ task :test => :check_dependencies
48
+
49
+ task :default => :test
50
+
51
+ begin
52
+ require 'yard'
53
+ YARD::Rake::YardocTask.new
54
+ rescue LoadError
55
+ task :yardoc do
56
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
57
+ end
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/changelog.md ADDED
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1 January 28, 2010
4
+ * Initial version
data/lib/gowalla.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+
3
+ gem 'hashie', '>= 0.1.3'
4
+ require 'hashie'
5
+
6
+ gem 'httparty', '>= 0.5.0'
7
+ require 'httparty'
8
+
9
+ directory = File.expand_path(File.dirname(__FILE__))
10
+
11
+ Hash.send :include, Hashie::HashExtensions
12
+
13
+ module Gowalla
14
+
15
+ def self.user(user_id)
16
+ Gowalla::Client.new.user(user_id)
17
+ end
18
+
19
+ def self.events(user_id)
20
+ Gowalla::Client.new.events(user_id)
21
+ end
22
+
23
+ def self.trip(trip_id)
24
+ Gowalla::Client.new.trip(trip_id)
25
+ end
26
+
27
+ def self.spot(spot_id)
28
+ Gowalla::Client.new.spot(spot_id)
29
+ end
30
+
31
+ def self.spot_events(spot_id)
32
+ Gowalla::Client.new.spot_events(spot_id)
33
+ end
34
+
35
+ end
36
+
37
+ require File.join(directory, 'gowalla', 'client')
@@ -0,0 +1,87 @@
1
+ module Gowalla
2
+
3
+ class Client
4
+ include HTTParty
5
+ format :json
6
+ base_uri "http://api.gowalla.com"
7
+ headers({'Accept' => 'application/json', "User-Agent" => 'Ruby gem'})
8
+
9
+ attr_reader :username
10
+
11
+ def initialize(username=nil, password=nil)
12
+ @username = username
13
+ self.class.basic_auth(@username, password) unless @username.nil?
14
+ end
15
+
16
+ def user(user_id="me")
17
+ mashup(self.class.get("/users/#{user_id}"))
18
+ end
19
+
20
+ def events(user_id=self.username)
21
+ mashup(self.class.get("/users/#{user_id}/events")).events
22
+ end
23
+
24
+ def friends_events
25
+ mashup(self.class.get("/visits/recent")).events
26
+ end
27
+
28
+ def friend_requests(user_id=self.username)
29
+ mashup(self.class.get("/users/#{user_id}/friend_requests")).friends_needing_approval
30
+ end
31
+
32
+ def friends(user_id=self.username)
33
+ mashup(self.class.get("/users/#{user_id}/friends")).friends
34
+ end
35
+
36
+ def items(user_id=self.username)
37
+ mashup(self.class.get("/users/#{user_id}/items"))
38
+ end
39
+
40
+ def pins(user_id=self.username)
41
+ mashup(self.class.get("/users/#{user_id}/pins"))
42
+ end
43
+
44
+ def stamps(user_id=self.username)
45
+ mashup(self.class.get("/users/#{user_id}/stamps"))
46
+ end
47
+
48
+ def top_spots(user_id=self.username)
49
+ mashup(self.class.get("/users/#{user_id}/top_spots"))
50
+ end
51
+
52
+ def visited_spots(user_id=self.username)
53
+ mashup(self.class.get("/users/#{user_id}/visited_spots"))
54
+ end
55
+
56
+ def trip(trip_id)
57
+ mashup(self.class.get("/trips/#{trip_id}"))
58
+ end
59
+
60
+ def spot(spot_id)
61
+ mashup(self.class.get("/spots/#{spot_id}"))
62
+ end
63
+
64
+ def spot_events(spot_id)
65
+ mashup(self.class.get("/spots/#{spot_id}/events")).events
66
+ end
67
+
68
+ private
69
+
70
+ def mashup(response)
71
+ case response.code
72
+ when 200
73
+ if response.is_a?(Hash)
74
+ Hashie::Mash.new(response)
75
+ else
76
+ if response.first.is_a?(Hash)
77
+ response.map{|item| Hashie::Mash.new(item)}
78
+ else
79
+ response
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -0,0 +1,266 @@
1
+ {
2
+ "events": [
3
+ {
4
+ "comment": "Closing every account I have ",
5
+ "created_at": "2010/01/26 15:31:46 +0000",
6
+ "item": null,
7
+ "spot": {
8
+ "image_url": "http://static.gowalla.com/categories/186-standard.png",
9
+ "name": "Bank Of America",
10
+ "url": "/spots/164052"
11
+ },
12
+ "type": "visit"
13
+ },
14
+ {
15
+ "comment": "Grabbing breakfast with a good friend ",
16
+ "created_at": "2010/01/26 13:02:38 +0000",
17
+ "item": null,
18
+ "spot": {
19
+ "image_url": "http://static.gowalla.com/categories/16-standard.png",
20
+ "name": "Betty's Cafe",
21
+ "url": "/spots/455129"
22
+ },
23
+ "type": "visit"
24
+ },
25
+ {
26
+ "comment": null,
27
+ "created_at": "2010/01/26 13:01:19 +0000",
28
+ "item": null,
29
+ "spot": {
30
+ "image_url": "http://static.gowalla.com/categories/16-standard.png",
31
+ "name": "Betty's Cafe",
32
+ "url": "/spots/455129"
33
+ },
34
+ "type": "create_spot"
35
+ },
36
+ {
37
+ "comment": "Catching The Squeakquel with Reagan ",
38
+ "created_at": "2010/01/23 18:35:02 +0000",
39
+ "item": null,
40
+ "spot": {
41
+ "image_url": "http://static.gowalla.com/categories/30-standard.png",
42
+ "name": "AMC Stonebriar 24",
43
+ "url": "/spots/59817"
44
+ },
45
+ "type": "visit"
46
+ },
47
+ {
48
+ "comment": "Looking for some #JavaScript ninjas at Dallas.js ",
49
+ "created_at": "2010/01/12 00:55:59 +0000",
50
+ "item": null,
51
+ "spot": {
52
+ "image_url": "http://static.gowalla.com/categories/64-standard.png",
53
+ "name": "Londoner Restaurant",
54
+ "url": "/spots/366585"
55
+ },
56
+ "type": "visit"
57
+ },
58
+ {
59
+ "comment": null,
60
+ "created_at": "2010/01/12 00:54:27 +0000",
61
+ "item": null,
62
+ "spot": {
63
+ "image_url": "http://static.gowalla.com/categories/64-standard.png",
64
+ "name": "Londoner Restaurant",
65
+ "url": "/spots/366585"
66
+ },
67
+ "type": "create_spot"
68
+ },
69
+ {
70
+ "comment": "lunch with @curvezilla",
71
+ "created_at": "2010/01/11 17:05:14 +0000",
72
+ "item": null,
73
+ "spot": {
74
+ "image_url": "http://static.gowalla.com/categories/154-standard.png",
75
+ "name": "MOOYAH Burgers & Fries",
76
+ "url": "/spots/78953"
77
+ },
78
+ "type": "visit"
79
+ },
80
+ {
81
+ "comment": "Grabbing some coffee and wifi before heading to Dallas.rb",
82
+ "created_at": "2010/01/05 22:55:51 +0000",
83
+ "item": null,
84
+ "spot": {
85
+ "image_url": "http://static.gowalla.com/categories/96-standard.png",
86
+ "name": "Barnes and Noble",
87
+ "url": "/spots/11641"
88
+ },
89
+ "type": "visit"
90
+ },
91
+ {
92
+ "comment": null,
93
+ "created_at": "2009/12/30 23:32:51 +0000",
94
+ "item": {
95
+ "determiner": "a",
96
+ "image_url": "http://static.gowalla.com/kinds/1454-d888b87a4a427793a25f47b35c31bfb9.png",
97
+ "issue_number": 9775,
98
+ "issue_number_str": "9775",
99
+ "name": "Longneck",
100
+ "url": "/items/676687"
101
+ },
102
+ "spot": {
103
+ "image_url": "http://static.gowalla.com/categories/17-standard.png",
104
+ "name": "Rudy's",
105
+ "url": "/spots/43464"
106
+ },
107
+ "type": "pick_up"
108
+ },
109
+ {
110
+ "comment": null,
111
+ "created_at": "2009/12/30 23:32:50 +0000",
112
+ "item": {
113
+ "determiner": "some",
114
+ "image_url": "http://static.gowalla.com/kinds/1481-715ebdc408fb284eaaa58994db0e2395.png",
115
+ "issue_number": 669,
116
+ "issue_number_str": "669",
117
+ "name": "Ribs",
118
+ "url": "/items/86727"
119
+ },
120
+ "spot": {
121
+ "image_url": "http://static.gowalla.com/categories/17-standard.png",
122
+ "name": "Rudy's",
123
+ "url": "/spots/43464"
124
+ },
125
+ "type": "drop"
126
+ },
127
+ {
128
+ "comment": "Treating the in-laws to some Texas BBQ ",
129
+ "created_at": "2009/12/30 23:32:30 +0000",
130
+ "item": null,
131
+ "spot": {
132
+ "image_url": "http://static.gowalla.com/categories/17-standard.png",
133
+ "name": "Rudy's",
134
+ "url": "/spots/43464"
135
+ },
136
+ "type": "visit"
137
+ },
138
+ {
139
+ "comment": "Catching a matinee of Sherlock Holmes",
140
+ "created_at": "2009/12/29 18:39:20 +0000",
141
+ "item": null,
142
+ "spot": {
143
+ "image_url": "http://static.gowalla.com/categories/30-standard.png",
144
+ "name": "Stagecoach Theater",
145
+ "url": "/spots/136029"
146
+ },
147
+ "type": "visit"
148
+ },
149
+ {
150
+ "comment": null,
151
+ "created_at": "2009/12/29 15:33:34 +0000",
152
+ "item": {
153
+ "determiner": "a",
154
+ "image_url": "http://static.gowalla.com/kinds/1456-dea9fdef8416d6e8c880b4e3d4ef3a69.png",
155
+ "issue_number": 243,
156
+ "issue_number_str": "243",
157
+ "name": "Big Bag o' Swag",
158
+ "url": "/items/86728"
159
+ },
160
+ "spot": {
161
+ "image_url": "http://static.gowalla.com/categories/73-standard.png",
162
+ "name": "National Museum of the Pacific War",
163
+ "url": "/spots/11300"
164
+ },
165
+ "type": "drop"
166
+ },
167
+ {
168
+ "comment": "Learning about the Pacific War ",
169
+ "created_at": "2009/12/29 15:33:11 +0000",
170
+ "item": null,
171
+ "spot": {
172
+ "image_url": "http://static.gowalla.com/categories/73-standard.png",
173
+ "name": "National Museum of the Pacific War",
174
+ "url": "/spots/11300"
175
+ },
176
+ "type": "visit"
177
+ },
178
+ {
179
+ "comment": null,
180
+ "created_at": "2009/12/28 23:56:25 +0000",
181
+ "item": {
182
+ "determiner": "a",
183
+ "image_url": "http://static.gowalla.com/kinds/1480-c9d779a0f5be5f79756ed947fecff01c.png",
184
+ "issue_number": 3080,
185
+ "issue_number_str": "3080",
186
+ "name": "Rattlesnake",
187
+ "url": "/items/572465"
188
+ },
189
+ "spot": {
190
+ "image_url": "http://static.gowalla.com/categories/167-standard.png",
191
+ "name": "Fredericksburg Brewing Co.",
192
+ "url": "/spots/261180"
193
+ },
194
+ "type": "pick_up"
195
+ },
196
+ {
197
+ "comment": null,
198
+ "created_at": "2009/12/28 23:56:24 +0000",
199
+ "item": {
200
+ "determiner": "a",
201
+ "image_url": "http://static.gowalla.com/kinds/1494-52dd471bc3d8d89f26df3b2e174d02e6.png",
202
+ "issue_number": 987,
203
+ "issue_number_str": "987",
204
+ "name": "Koi Fish",
205
+ "url": "/items/86730"
206
+ },
207
+ "spot": {
208
+ "image_url": "http://static.gowalla.com/categories/167-standard.png",
209
+ "name": "Fredericksburg Brewing Co.",
210
+ "url": "/spots/261180"
211
+ },
212
+ "type": "drop"
213
+ },
214
+ {
215
+ "comment": "Dinner and a brew ",
216
+ "created_at": "2009/12/28 23:56:05 +0000",
217
+ "item": null,
218
+ "spot": {
219
+ "image_url": "http://static.gowalla.com/categories/167-standard.png",
220
+ "name": "Fredericksburg Brewing Co.",
221
+ "url": "/spots/261180"
222
+ },
223
+ "type": "visit"
224
+ },
225
+ {
226
+ "comment": "It's always wine:30 in Sisterdale. ",
227
+ "created_at": "2009/12/28 17:16:16 +0000",
228
+ "item": null,
229
+ "spot": {
230
+ "image_url": "http://static.gowalla.com/categories/157-standard.png",
231
+ "name": "Sister Creek Vineyards",
232
+ "url": "/spots/284084"
233
+ },
234
+ "type": "visit"
235
+ },
236
+ {
237
+ "comment": null,
238
+ "created_at": "2009/12/28 17:15:40 +0000",
239
+ "item": null,
240
+ "spot": {
241
+ "image_url": "http://static.gowalla.com/categories/157-standard.png",
242
+ "name": "Sister Creek Vineyards",
243
+ "url": "/spots/284084"
244
+ },
245
+ "type": "create_spot"
246
+ },
247
+ {
248
+ "comment": null,
249
+ "created_at": "2009/12/28 16:24:00 +0000",
250
+ "item": {
251
+ "determiner": "a",
252
+ "image_url": "http://static.gowalla.com/kinds/1490-b45e3f8247e134202bdf63551e54283d.png",
253
+ "issue_number": 991,
254
+ "issue_number_str": "991",
255
+ "name": "Bluebonnet",
256
+ "url": "/items/86729"
257
+ },
258
+ "spot": {
259
+ "image_url": "http://static.gowalla.com/categories/157-standard.png",
260
+ "name": "Grape Creek Vineyards",
261
+ "url": "/spots/142525"
262
+ },
263
+ "type": "drop"
264
+ }
265
+ ]
266
+ }