gowalla 0.5.2 → 0.5.3
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/Gemfile.lock +11 -9
- data/README.md +12 -16
- data/changelog.md +2 -0
- data/gowalla.gemspec +18 -17
- data/lib/gowalla.rb +1 -1
- data/lib/gowalla/client.rb +1 -1
- data/lib/gowalla/version.rb +1 -1
- data/test/client_test.rb +2 -5
- data/test/fixtures/flag_created.json +1 -0
- data/test/flags_test.rb +2 -2
- data/test/helper.rb +10 -8
- data/test/spots_test.rb +1 -1
- data/test/users_test.rb +1 -1
- metadata +24 -8
data/Gemfile.lock
CHANGED
@@ -2,22 +2,22 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
gowalla (0.5.2)
|
5
|
-
faraday (~> 0.5.
|
6
|
-
faraday_middleware (~> 0.
|
5
|
+
faraday (~> 0.5.1)
|
6
|
+
faraday_middleware (~> 0.2.0)
|
7
7
|
hashie (~> 0.4.0)
|
8
8
|
oauth2 (~> 0.1.0)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: http://rubygems.org/
|
12
12
|
specs:
|
13
|
-
addressable (2.
|
13
|
+
addressable (2.2.2)
|
14
14
|
fakeweb (1.3.0)
|
15
|
-
faraday (0.5.
|
16
|
-
addressable (~> 2.
|
15
|
+
faraday (0.5.1)
|
16
|
+
addressable (~> 2.2.2)
|
17
17
|
multipart-post (~> 1.0.1)
|
18
18
|
rack (~> 1.2.1)
|
19
|
-
faraday_middleware (0.
|
20
|
-
faraday (~> 0.5.
|
19
|
+
faraday_middleware (0.2.0)
|
20
|
+
faraday (~> 0.5.1)
|
21
21
|
hashie (0.4.0)
|
22
22
|
jnunemaker-matchy (0.4.0)
|
23
23
|
json_pure (1.4.6)
|
@@ -29,6 +29,7 @@ GEM
|
|
29
29
|
rack (1.2.1)
|
30
30
|
rake (0.8.7)
|
31
31
|
shoulda (2.11.3)
|
32
|
+
test-unit (2.1.1)
|
32
33
|
|
33
34
|
PLATFORMS
|
34
35
|
ruby
|
@@ -36,8 +37,8 @@ PLATFORMS
|
|
36
37
|
DEPENDENCIES
|
37
38
|
bundler (~> 1.0)
|
38
39
|
fakeweb (~> 1.3)
|
39
|
-
faraday (~> 0.5.
|
40
|
-
faraday_middleware (~> 0.
|
40
|
+
faraday (~> 0.5.1)
|
41
|
+
faraday_middleware (~> 0.2.0)
|
41
42
|
gowalla!
|
42
43
|
hashie (~> 0.4.0)
|
43
44
|
jnunemaker-matchy (~> 0.4)
|
@@ -45,3 +46,4 @@ DEPENDENCIES
|
|
45
46
|
oauth2 (~> 0.1.0)
|
46
47
|
rake (~> 0.8)
|
47
48
|
shoulda (~> 2.11)
|
49
|
+
test-unit (~> 2.1)
|
data/README.md
CHANGED
@@ -2,21 +2,20 @@
|
|
2
2
|
|
3
3
|
Ruby wrapper for the [Gowalla API](http://gowalla.com/api/docs).
|
4
4
|
|
5
|
-
|
6
5
|
## Installation
|
7
6
|
|
8
7
|
sudo gem install gowalla
|
9
|
-
|
8
|
+
|
10
9
|
## Get your API key
|
11
10
|
|
12
11
|
Be sure and get your API key: [http://gowalla.com/api/keys](http://gowalla.com/api/keys)
|
13
|
-
|
12
|
+
|
14
13
|
## Usage
|
15
14
|
|
16
15
|
### Instantiate a client (Basic Auth)
|
17
16
|
|
18
17
|
gowalla = Gowalla::Client.new(:username => 'pengwynn', :password => 'somepassword', :api_key => 'your_api_key')
|
19
|
-
|
18
|
+
|
20
19
|
### or configure once
|
21
20
|
|
22
21
|
Gowalla.configure do |config|
|
@@ -25,7 +24,7 @@ Be sure and get your API key: [http://gowalla.com/api/keys](http://gowalla.com/a
|
|
25
24
|
config.password = 'somepassword'
|
26
25
|
end
|
27
26
|
gowalla = Gowalla::Client.new
|
28
|
-
|
27
|
+
|
29
28
|
### Instantiate a client (OAuth2)
|
30
29
|
|
31
30
|
For OAuth2, you'll need to specify a callback URL when you [set up your app and get your API keys](http://gowalla.com/api/keys).
|
@@ -33,7 +32,7 @@ For OAuth2, you'll need to specify a callback URL when you [set up your app and
|
|
33
32
|
Let's create the client in a protected method in our controller:
|
34
33
|
|
35
34
|
protected
|
36
|
-
def client
|
35
|
+
def client
|
37
36
|
Gowalla::Client.new (
|
38
37
|
:api_key => "your_api_key",
|
39
38
|
:api_secret => "your_api_secret",
|
@@ -42,46 +41,43 @@ Let's create the client in a protected method in our controller:
|
|
42
41
|
end
|
43
42
|
|
44
43
|
We need to get an access token. Perhaps in an a before filter where you need to access Gowalla:
|
45
|
-
|
44
|
+
|
46
45
|
redirect(@client.web_server.authorize_url(:redirect_uri => redirect_uri, :state => 1))
|
47
46
|
|
48
47
|
or if you need read-write access:
|
49
48
|
|
50
49
|
redirect(@client.web_server.authorize_url(:redirect_uri => redirect_uri, :state => 1, :scope => 'read-write))
|
51
|
-
|
50
|
+
|
52
51
|
You'll need a callback route to catch the code coming back from Gowalla after a user grants you access and this must match what you specified when you created your app on Gowalla:
|
53
52
|
|
54
53
|
get '/auth/gowalla/callback' do
|
55
54
|
session[:access_token] = client.web_server.get_access_token(params[:code], :redirect_uri => redirect_uri).token
|
56
|
-
|
55
|
+
|
57
56
|
if session[:access_token]
|
58
57
|
redirect '/auth/gowalla/test'
|
59
58
|
else
|
60
59
|
"Error retrieving access token."
|
61
60
|
end
|
62
61
|
end
|
63
|
-
|
62
|
+
|
64
63
|
Now that we have an access token we can use the client to make calls, just like we would with Basic Auth. You can checkout a basic [Sinatra example](http://gist.github.com/454283).
|
65
|
-
|
64
|
+
|
66
65
|
#### Examples
|
67
66
|
|
68
67
|
gowalla.user('pengwynn')
|
69
68
|
=> <#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">
|
70
|
-
|
71
69
|
|
72
70
|
Details for the current user
|
73
71
|
|
74
72
|
gowalla.user
|
75
|
-
|
73
|
+
|
76
74
|
Details for another user
|
77
75
|
|
78
76
|
gowalla.user('bradleyjoyce')
|
79
77
|
gowalla.user(1707)
|
80
|
-
|
81
|
-
|
82
78
|
|
83
79
|
## Note on Patches/Pull Requests
|
84
|
-
|
80
|
+
|
85
81
|
* Fork the project.
|
86
82
|
* Make your feature addition or bug fix.
|
87
83
|
* Add tests for it. This is important so I don't break it in a
|
data/changelog.md
CHANGED
data/gowalla.gemspec
CHANGED
@@ -1,31 +1,32 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path(
|
2
|
+
require File.expand_path('../lib/gowalla/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
5
|
+
s.name = 'gowalla'
|
6
6
|
s.version = Gowalla::VERSION
|
7
7
|
s.authors = ["Wynn Netherland", "Eric Hutzelman"]
|
8
|
-
s.email = [
|
8
|
+
s.email = ['wynn.netherland@gmail.com']
|
9
9
|
s.summary = %q{Wrapper for the Gowalla API}
|
10
10
|
s.description = %q{Ruby wrapper for the Gowalla API}
|
11
|
-
s.homepage =
|
11
|
+
s.homepage = 'http://wynnnetherland.com/projects/gowalla/'
|
12
12
|
|
13
|
-
s.add_runtime_dependency
|
14
|
-
s.add_runtime_dependency
|
15
|
-
s.add_runtime_dependency
|
16
|
-
s.add_runtime_dependency
|
13
|
+
s.add_runtime_dependency 'faraday', '~> 0.5.1'
|
14
|
+
s.add_runtime_dependency 'faraday_middleware', '~> 0.2.0'
|
15
|
+
s.add_runtime_dependency 'hashie', '~> 0.4.0'
|
16
|
+
s.add_runtime_dependency 'oauth2', '~> 0.1.0'
|
17
17
|
|
18
|
-
s.add_development_dependency
|
19
|
-
s.add_development_dependency
|
20
|
-
s.add_development_dependency
|
21
|
-
s.add_development_dependency
|
22
|
-
s.add_development_dependency
|
23
|
-
s.add_development_dependency
|
18
|
+
s.add_development_dependency 'bundler', '~> 1.0'
|
19
|
+
s.add_development_dependency 'fakeweb', '~> 1.3'
|
20
|
+
s.add_development_dependency 'jnunemaker-matchy', '~> 0.4'
|
21
|
+
s.add_development_dependency 'json_pure', '~> 1.4'
|
22
|
+
s.add_development_dependency 'rake', '~> 0.8'
|
23
|
+
s.add_development_dependency 'shoulda', '~> 2.11'
|
24
|
+
s.add_development_dependency 'test-unit', '~> 2.1'
|
24
25
|
|
25
|
-
s.required_rubygems_version =
|
26
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
|
26
27
|
s.platform = Gem::Platform::RUBY
|
27
|
-
s.
|
28
|
+
s.require_paths = ['lib']
|
28
29
|
s.files = `git ls-files`.split("\n")
|
29
30
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
30
|
-
s.executables = `git ls-files
|
31
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
31
32
|
end
|
data/lib/gowalla.rb
CHANGED
data/lib/gowalla/client.rb
CHANGED
@@ -40,7 +40,7 @@ module Gowalla
|
|
40
40
|
params[:access_token] = @access_token if @access_token
|
41
41
|
@connection ||= Faraday::Connection.new(:url => api_url, :params => params, :headers => default_headers) do |builder|
|
42
42
|
builder.adapter Faraday.default_adapter
|
43
|
-
builder.use Faraday::Response::
|
43
|
+
builder.use Faraday::Response::Parse
|
44
44
|
builder.use Faraday::Response::Mashify
|
45
45
|
end
|
46
46
|
|
data/lib/gowalla/version.rb
CHANGED
data/test/client_test.rb
CHANGED
@@ -6,8 +6,6 @@ class ClientTest < Test::Unit::TestCase
|
|
6
6
|
setup do
|
7
7
|
@client = gowalla_test_client
|
8
8
|
end
|
9
|
-
|
10
|
-
|
11
9
|
end
|
12
10
|
|
13
11
|
context "when accessing the API anonymously" do
|
@@ -34,7 +32,7 @@ class ClientTest < Test::Unit::TestCase
|
|
34
32
|
|
35
33
|
@client.username.should == 'username'
|
36
34
|
end
|
37
|
-
|
35
|
+
|
38
36
|
should "use HTTPS to avoid sending password in plain text" do
|
39
37
|
Gowalla.configure do |config|
|
40
38
|
config.api_key = 'api_key'
|
@@ -79,7 +77,7 @@ class ClientTest < Test::Unit::TestCase
|
|
79
77
|
should "use HTTPS to avoid sending credentials in plain text" do
|
80
78
|
@client.api_url.should == 'https://api.gowalla.com'
|
81
79
|
end
|
82
|
-
|
80
|
+
|
83
81
|
should "create an OAuth2 client" do
|
84
82
|
@client.oauth_client.class.to_s.should == "OAuth2::Client"
|
85
83
|
end
|
@@ -90,5 +88,4 @@ class ClientTest < Test::Unit::TestCase
|
|
90
88
|
|
91
89
|
end
|
92
90
|
|
93
|
-
|
94
91
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"result": "flag created"}
|
data/test/flags_test.rb
CHANGED
@@ -37,10 +37,10 @@ class FlagsTest < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
should "set a flag on a specific spot" do
|
39
39
|
url = "https://pengwynn:0U812@api.gowalla.com/spots/1/flags/invalid"
|
40
|
-
|
40
|
+
stub_post(url, "flag_created.json")
|
41
41
|
response = @client.flag_spot(1, 'invalid', 'my problem description')
|
42
42
|
response.result.should == 'flag created'
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
46
|
-
end
|
46
|
+
end
|
data/test/helper.rb
CHANGED
@@ -11,9 +11,6 @@ require 'gowalla'
|
|
11
11
|
|
12
12
|
FakeWeb.allow_net_connect = false
|
13
13
|
|
14
|
-
class Test::Unit::TestCase
|
15
|
-
end
|
16
|
-
|
17
14
|
def gowalla_test_client
|
18
15
|
Gowalla::Client.new(:username => 'pengwynn', :password => '0U812', :api_key => 'gowallawallabingbang')
|
19
16
|
end
|
@@ -29,12 +26,17 @@ def gowalla_url(url)
|
|
29
26
|
end
|
30
27
|
|
31
28
|
def stub_get(url, filename, options={})
|
32
|
-
opts = {
|
33
|
-
|
29
|
+
opts = {
|
30
|
+
:body => fixture_file(filename),
|
31
|
+
:content_type => 'application/json; charset=utf-8'
|
32
|
+
}.merge(options)
|
34
33
|
FakeWeb.register_uri(:get, gowalla_url(url), opts)
|
35
34
|
end
|
36
35
|
|
37
|
-
def stub_post(url, filename)
|
38
|
-
|
36
|
+
def stub_post(url, filename, options={})
|
37
|
+
opts = {
|
38
|
+
:body => fixture_file(filename),
|
39
|
+
:content_type => 'application/json; charset=utf-8'
|
40
|
+
}.merge(options)
|
41
|
+
FakeWeb.register_uri(:post, gowalla_url(url), opts)
|
39
42
|
end
|
40
|
-
|
data/test/spots_test.rb
CHANGED
data/test/users_test.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 3
|
9
|
+
version: 0.5.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Wynn Netherland
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-26 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -29,8 +29,8 @@ dependencies:
|
|
29
29
|
segments:
|
30
30
|
- 0
|
31
31
|
- 5
|
32
|
-
-
|
33
|
-
version: 0.5.
|
32
|
+
- 1
|
33
|
+
version: 0.5.1
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -43,9 +43,9 @@ dependencies:
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
segments:
|
45
45
|
- 0
|
46
|
-
-
|
47
|
-
-
|
48
|
-
version: 0.
|
46
|
+
- 2
|
47
|
+
- 0
|
48
|
+
version: 0.2.0
|
49
49
|
type: :runtime
|
50
50
|
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
@@ -162,6 +162,20 @@ dependencies:
|
|
162
162
|
version: "2.11"
|
163
163
|
type: :development
|
164
164
|
version_requirements: *id010
|
165
|
+
- !ruby/object:Gem::Dependency
|
166
|
+
name: test-unit
|
167
|
+
prerelease: false
|
168
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
segments:
|
174
|
+
- 2
|
175
|
+
- 1
|
176
|
+
version: "2.1"
|
177
|
+
type: :development
|
178
|
+
version_requirements: *id011
|
165
179
|
description: Ruby wrapper for the Gowalla API
|
166
180
|
email:
|
167
181
|
- wynn.netherland@gmail.com
|
@@ -199,6 +213,7 @@ files:
|
|
199
213
|
- test/fixtures/find_spots.json
|
200
214
|
- test/fixtures/find_trips.json
|
201
215
|
- test/fixtures/flag.json
|
216
|
+
- test/fixtures/flag_created.json
|
202
217
|
- test/fixtures/flags.json
|
203
218
|
- test/fixtures/friend_requests.json
|
204
219
|
- test/fixtures/friends.json
|
@@ -276,6 +291,7 @@ test_files:
|
|
276
291
|
- test/fixtures/find_spots.json
|
277
292
|
- test/fixtures/find_trips.json
|
278
293
|
- test/fixtures/flag.json
|
294
|
+
- test/fixtures/flag_created.json
|
279
295
|
- test/fixtures/flags.json
|
280
296
|
- test/fixtures/friend_requests.json
|
281
297
|
- test/fixtures/friends.json
|