gowalla-ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/Manifest +17 -0
- data/README.markdown +43 -0
- data/Rakefile +13 -0
- data/gowalla-ruby.gemspec +40 -0
- data/init.rb +8 -0
- data/lib/gowalla/address.rb +10 -0
- data/lib/gowalla/base.rb +10 -0
- data/lib/gowalla/checkin.rb +13 -0
- data/lib/gowalla/spot.rb +13 -0
- data/lib/gowalla/stamp.rb +20 -0
- data/lib/gowalla/user.rb +45 -0
- data/lib/gowalla.rb +8 -0
- data/test/fixtures/stamps.json +282 -0
- data/test/fixtures/user.json +34 -0
- data/test/helper.rb +12 -0
- data/test/test_stamp.rb +36 -0
- data/test/test_user.rb +108 -0
- metadata +115 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Andy Atkinson
|
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/Manifest
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
LICENSE
|
2
|
+
README.markdown
|
3
|
+
Rakefile
|
4
|
+
init.rb
|
5
|
+
lib/gowalla.rb
|
6
|
+
lib/gowalla/address.rb
|
7
|
+
lib/gowalla/base.rb
|
8
|
+
lib/gowalla/checkin.rb
|
9
|
+
lib/gowalla/spot.rb
|
10
|
+
lib/gowalla/stamp.rb
|
11
|
+
lib/gowalla/user.rb
|
12
|
+
test/fixtures/stamps.json
|
13
|
+
test/fixtures/user.json
|
14
|
+
test/helper.rb
|
15
|
+
test/test_stamp.rb
|
16
|
+
test/test_user.rb
|
17
|
+
Manifest
|
data/README.markdown
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
gowalla-ruby
|
2
|
+
===
|
3
|
+
|
4
|
+
Gowalla API wrapper for Ruby.
|
5
|
+
|
6
|
+
Install
|
7
|
+
===
|
8
|
+
gem install gowalla-ruby
|
9
|
+
|
10
|
+
Usage
|
11
|
+
===
|
12
|
+
|
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
|
+
|
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
|
+
|
26
|
+
# for Ruby
|
27
|
+
>> irb -r rubygems
|
28
|
+
>> require 'init'
|
29
|
+
>> Gowalla::User.find('andyatkinson')
|
30
|
+
>> Gowalla::Stamp.find('andyatkinson')
|
31
|
+
|
32
|
+
Testing
|
33
|
+
===
|
34
|
+
Tests use fixture files of API responses as JSON data. API responses are stubbed with Mocha. Tests use the Shoulda framework.
|
35
|
+
|
36
|
+
Copyright
|
37
|
+
---
|
38
|
+
|
39
|
+
Copyright (c) 2009 Andy Atkinson. See LICENSE for details.
|
40
|
+
|
41
|
+
Thanks
|
42
|
+
---
|
43
|
+
Thanks to [John Nunemaker](http://railstips.org) for the [HTTParty](http://httparty.rubyforge.org/rdoc/) gem. Much of the code for this gem was based on the [foursquare](http://github.com/cmdrkeene/foursquare) gem by [Brandon Keene](http://github.com/cmdrkeene).
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('gowalla-ruby', '0.0.1') do |p|
|
6
|
+
p.description = "Gowalla API wrapper for Ruby"
|
7
|
+
p.url = "http://github.com/webandy/gowalla-ruby"
|
8
|
+
p.author = "Andy Atkinson"
|
9
|
+
p.email = "andy@webandy.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.runtime_dependencies = ['httparty >=0.5.0']
|
12
|
+
p.development_dependencies = ['shoulda >=2.10.3', 'mocha >=0.9.7']
|
13
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{gowalla-ruby}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Andy Atkinson"]
|
9
|
+
s.date = %q{2010-02-21}
|
10
|
+
s.description = %q{Gowalla API wrapper for Ruby}
|
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"]
|
14
|
+
s.homepage = %q{http://github.com/webandy/gowalla-ruby}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gowalla-ruby", "--main", "README.markdown"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{gowalla-ruby}
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
|
+
s.summary = %q{Gowalla API wrapper for Ruby}
|
20
|
+
s.test_files = ["test/test_stamp.rb", "test/test_user.rb"]
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 3
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
|
28
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
|
29
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
32
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
33
|
+
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
34
|
+
end
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
37
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
38
|
+
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
39
|
+
end
|
40
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require File.join(File.dirname(__FILE__), 'lib', 'gowalla')
|
3
|
+
require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'base')
|
4
|
+
require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'user')
|
5
|
+
require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'spot')
|
6
|
+
require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'stamp')
|
7
|
+
require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'checkin')
|
8
|
+
require File.join(File.dirname(__FILE__), 'lib', 'gowalla', 'address')
|
data/lib/gowalla/base.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gowalla
|
2
|
+
class Checkin
|
3
|
+
attr_accessor :type, :message, :url, :spot, :created_at
|
4
|
+
|
5
|
+
def initialize(data={})
|
6
|
+
@type = data['type']
|
7
|
+
@message = data['message']
|
8
|
+
@url = data['url']
|
9
|
+
@spot = Spot.new(data['spot'])
|
10
|
+
@created_at = data['created_at']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/gowalla/spot.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gowalla
|
2
|
+
class Spot < Base
|
3
|
+
attr_accessor :name, :address, :url, :image_url
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
@name = data['name']
|
7
|
+
@address = Address.new(data['address']) if !data['address'].blank?
|
8
|
+
@url = data['url']
|
9
|
+
@image_url = data['image_url']
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Gowalla
|
2
|
+
class Stamp < Base
|
3
|
+
attr_accessor :spot, :checkins_count, :first_checkin_at, :last_checkin_at
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
@spot = Spot.new(data['spot'])
|
7
|
+
@checkins_count = data['checkins_count']
|
8
|
+
@first_checkin_at = DateTime.parse(data['first_checkin_at'])
|
9
|
+
@last_checkin_at = DateTime.parse(data['last_checkin_at'])
|
10
|
+
end
|
11
|
+
def self.find(username)
|
12
|
+
self.fetch(username)["stamps"].map{|stamp| Stamp.new(stamp)}
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def self.fetch(username)
|
17
|
+
get("/users/#{username}/stamps?limit=20", :headers => {'Accept' => 'application/json'})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/gowalla/user.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Gowalla
|
2
|
+
class User < Base
|
3
|
+
attr_accessor :first_name, :last_name, :top_spots_url, :image_url, :url, :activity_url, :bio, :stamps_count, :stamps_url, :items_count, :items_url, :friends_count, :hometown, :pins_url, :website, :twitter_username, :facebook_id, :add_friend_url, :friends_url, :_is_friend, :last_checkins, :pins_count
|
4
|
+
|
5
|
+
def initialize(data={})
|
6
|
+
@first_name = data['first_name']
|
7
|
+
@last_name = data['last_name']
|
8
|
+
@top_spots_url = data['top_spots_url']
|
9
|
+
@image_url = data['image_url']
|
10
|
+
@url = data['url']
|
11
|
+
@activity_url = data['activity_url']
|
12
|
+
@bio = data['bio']
|
13
|
+
@stamps_count = data['stamps_count']
|
14
|
+
@stamps_url = data['stamps_url']
|
15
|
+
@items_count = data['items_count']
|
16
|
+
@items_url = data['items_url']
|
17
|
+
@friends_count = data['friends_count']
|
18
|
+
@icons_count = data['icons_count']
|
19
|
+
@hometown = data['hometown']
|
20
|
+
@pins_url = data['pins_url']
|
21
|
+
@website = data['website']
|
22
|
+
@twitter_username = data['twitter_username']
|
23
|
+
@facebook_id = data['facebook_id']
|
24
|
+
@add_friend_url = data['add_friend_url']
|
25
|
+
@friends_url = data['friends_url']
|
26
|
+
@_is_friend = data['_is_friend']
|
27
|
+
@last_checkins = data['last_checkins'].map{|checkin| Checkin.new(checkin)}
|
28
|
+
@pins_count = data['pins_count']
|
29
|
+
end
|
30
|
+
def self.find(username)
|
31
|
+
User.new(self.fetch(username))
|
32
|
+
end
|
33
|
+
def stamps
|
34
|
+
# TODO is there a better way to extract the user ID?
|
35
|
+
user_id = self.add_friend_url.split("user_id=").last
|
36
|
+
Stamp.find(user_id)
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
def self.fetch(username)
|
41
|
+
get("/users/#{username}", :headers => {'Accept' => 'application/json'})
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
data/lib/gowalla.rb
ADDED
@@ -0,0 +1,282 @@
|
|
1
|
+
{
|
2
|
+
"stamps": [{
|
3
|
+
"spot": {
|
4
|
+
"name": "Roosevelt High School",
|
5
|
+
"address": {
|
6
|
+
"region": "MN",
|
7
|
+
"locality": "Minneapolis"
|
8
|
+
},
|
9
|
+
"url": "/spots/456547",
|
10
|
+
"image_url": "http://static.gowalla.com/categories/152-standard.png"
|
11
|
+
},
|
12
|
+
"checkins_count": 2,
|
13
|
+
"first_checkin_at": "2010-01-26T23:24:13+00:00",
|
14
|
+
"last_checkin_at": "2010-02-17T01:00:27+00:00"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"spot": {
|
18
|
+
"name": "Taste Of Thailand",
|
19
|
+
"address": {
|
20
|
+
"region": "MN",
|
21
|
+
"locality": "St. Paul"
|
22
|
+
},
|
23
|
+
"url": "/spots/383138",
|
24
|
+
"image_url": "http://static.gowalla.com/categories/18-standard.png"
|
25
|
+
},
|
26
|
+
"checkins_count": 1,
|
27
|
+
"first_checkin_at": "2010-02-15T02:06:40+00:00",
|
28
|
+
"last_checkin_at": "2010-02-15T02:06:40+00:00"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"spot": {
|
32
|
+
"name": "James J. Hill House",
|
33
|
+
"address": {
|
34
|
+
"region": "MN",
|
35
|
+
"locality": "St. Paul"
|
36
|
+
},
|
37
|
+
"url": "/spots/259214",
|
38
|
+
"image_url": "http://static.gowalla.com/categories/166-standard.png"
|
39
|
+
},
|
40
|
+
"checkins_count": 1,
|
41
|
+
"first_checkin_at": "2010-02-15T00:18:22+00:00",
|
42
|
+
"last_checkin_at": "2010-02-15T00:18:22+00:00"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"spot": {
|
46
|
+
"name": "Longfellow Grill",
|
47
|
+
"address": {
|
48
|
+
"region": "MN",
|
49
|
+
"locality": "Minneapolis"
|
50
|
+
},
|
51
|
+
"url": "/spots/70840",
|
52
|
+
"image_url": "http://static.gowalla.com/categories/124-standard.png"
|
53
|
+
},
|
54
|
+
"checkins_count": 1,
|
55
|
+
"first_checkin_at": "2010-02-07T01:34:11+00:00",
|
56
|
+
"last_checkin_at": "2010-02-07T01:34:11+00:00"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"spot": {
|
60
|
+
"name": "Intermedia Arts",
|
61
|
+
"address": {
|
62
|
+
"region": "MN",
|
63
|
+
"locality": "Minneapolis"
|
64
|
+
},
|
65
|
+
"url": "/spots/512777",
|
66
|
+
"image_url": "http://static.gowalla.com/categories/188-standard.png"
|
67
|
+
},
|
68
|
+
"checkins_count": 1,
|
69
|
+
"first_checkin_at": "2010-02-06T00:48:26+00:00",
|
70
|
+
"last_checkin_at": "2010-02-06T00:48:26+00:00"
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"spot": {
|
74
|
+
"name": "Herkimer Pub",
|
75
|
+
"address": {
|
76
|
+
"region": "MN",
|
77
|
+
"locality": "Minneapolis"
|
78
|
+
},
|
79
|
+
"url": "/spots/98671",
|
80
|
+
"image_url": "http://static.gowalla.com/categories/167-standard.png"
|
81
|
+
},
|
82
|
+
"checkins_count": 1,
|
83
|
+
"first_checkin_at": "2010-02-05T23:50:45+00:00",
|
84
|
+
"last_checkin_at": "2010-02-05T23:50:45+00:00"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"spot": {
|
88
|
+
"name": "Gandhi Mahal",
|
89
|
+
"address": {
|
90
|
+
"region": "MN",
|
91
|
+
"locality": "Minneapolis"
|
92
|
+
},
|
93
|
+
"url": "/spots/305762",
|
94
|
+
"image_url": "http://static.gowalla.com/categories/160-standard.png"
|
95
|
+
},
|
96
|
+
"checkins_count": 2,
|
97
|
+
"first_checkin_at": "2010-01-01T02:20:56+00:00",
|
98
|
+
"last_checkin_at": "2010-02-05T00:36:52+00:00"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"spot": {
|
102
|
+
"name": "Midtown Global Market",
|
103
|
+
"address": {
|
104
|
+
"region": "MN",
|
105
|
+
"locality": "Minneapolis"
|
106
|
+
},
|
107
|
+
"url": "/spots/169177",
|
108
|
+
"image_url": "http://static.gowalla.com/categories/11-standard.png"
|
109
|
+
},
|
110
|
+
"checkins_count": 2,
|
111
|
+
"first_checkin_at": "2010-01-08T00:49:14+00:00",
|
112
|
+
"last_checkin_at": "2010-01-21T23:56:35+00:00"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"spot": {
|
116
|
+
"name": "MEM Memphis International Airport",
|
117
|
+
"address": {
|
118
|
+
"region": "TN",
|
119
|
+
"locality": "Memphis"
|
120
|
+
},
|
121
|
+
"url": "/spots/9789",
|
122
|
+
"image_url": "http://static.gowalla.com/categories/45-standard.png"
|
123
|
+
},
|
124
|
+
"checkins_count": 1,
|
125
|
+
"first_checkin_at": "2010-01-16T19:13:32+00:00",
|
126
|
+
"last_checkin_at": "2010-01-16T19:13:32+00:00"
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"spot": {
|
130
|
+
"name": "Tennessee",
|
131
|
+
"address": {
|
132
|
+
"region": "TN",
|
133
|
+
"locality": null
|
134
|
+
},
|
135
|
+
"url": "/spots/18319",
|
136
|
+
"image_url": "http://static.gowalla.com/spots/18319-64c3343eb66fc42104086345c7138c87.png"
|
137
|
+
},
|
138
|
+
"checkins_count": 1,
|
139
|
+
"first_checkin_at": "2010-01-16T19:13:32+00:00",
|
140
|
+
"last_checkin_at": "2010-01-16T19:13:32+00:00"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"spot": {
|
144
|
+
"name": "RDU Raleigh-Durham International",
|
145
|
+
"address": {
|
146
|
+
"region": "NC",
|
147
|
+
"locality": "Cary"
|
148
|
+
},
|
149
|
+
"url": "/spots/26880",
|
150
|
+
"image_url": "http://static.gowalla.com/categories/45-standard.png"
|
151
|
+
},
|
152
|
+
"checkins_count": 2,
|
153
|
+
"first_checkin_at": "2010-01-12T21:39:24+00:00",
|
154
|
+
"last_checkin_at": "2010-01-16T15:22:43+00:00"
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"spot": {
|
158
|
+
"name": "SuperTarget",
|
159
|
+
"address": {
|
160
|
+
"region": "NC",
|
161
|
+
"locality": "Durham"
|
162
|
+
},
|
163
|
+
"url": "/spots/31559",
|
164
|
+
"image_url": "http://static.gowalla.com/categories/202-standard.png"
|
165
|
+
},
|
166
|
+
"checkins_count": 1,
|
167
|
+
"first_checkin_at": "2010-01-16T02:37:15+00:00",
|
168
|
+
"last_checkin_at": "2010-01-16T02:37:15+00:00"
|
169
|
+
},
|
170
|
+
{
|
171
|
+
"spot": {
|
172
|
+
"name": "Starbucks",
|
173
|
+
"address": {
|
174
|
+
"region": null,
|
175
|
+
"locality": null
|
176
|
+
},
|
177
|
+
"url": "/spots/26499",
|
178
|
+
"image_url": "http://static.gowalla.com/categories/1-standard.png"
|
179
|
+
},
|
180
|
+
"checkins_count": 1,
|
181
|
+
"first_checkin_at": "2010-01-15T18:23:40+00:00",
|
182
|
+
"last_checkin_at": "2010-01-15T18:23:40+00:00"
|
183
|
+
},
|
184
|
+
{
|
185
|
+
"spot": {
|
186
|
+
"name": "411 West",
|
187
|
+
"address": {
|
188
|
+
"region": "NC",
|
189
|
+
"locality": "Chapel Hill"
|
190
|
+
},
|
191
|
+
"url": "/spots/23014",
|
192
|
+
"image_url": "http://static.gowalla.com/categories/19-standard.png"
|
193
|
+
},
|
194
|
+
"checkins_count": 1,
|
195
|
+
"first_checkin_at": "2010-01-14T23:17:15+00:00",
|
196
|
+
"last_checkin_at": "2010-01-14T23:17:15+00:00"
|
197
|
+
},
|
198
|
+
{
|
199
|
+
"spot": {
|
200
|
+
"name": "Bean Traders",
|
201
|
+
"address": {
|
202
|
+
"region": null,
|
203
|
+
"locality": null
|
204
|
+
},
|
205
|
+
"url": "/spots/20834",
|
206
|
+
"image_url": "http://static.gowalla.com/categories/1-standard.png"
|
207
|
+
},
|
208
|
+
"checkins_count": 1,
|
209
|
+
"first_checkin_at": "2010-01-14T19:26:47+00:00",
|
210
|
+
"last_checkin_at": "2010-01-14T19:26:47+00:00"
|
211
|
+
},
|
212
|
+
{
|
213
|
+
"spot": {
|
214
|
+
"name": "Duke Chapel",
|
215
|
+
"address": {
|
216
|
+
"region": null,
|
217
|
+
"locality": null
|
218
|
+
},
|
219
|
+
"url": "/spots/35647",
|
220
|
+
"image_url": "http://static.gowalla.com/categories/22-standard.png"
|
221
|
+
},
|
222
|
+
"checkins_count": 1,
|
223
|
+
"first_checkin_at": "2010-01-14T18:10:54+00:00",
|
224
|
+
"last_checkin_at": "2010-01-14T18:10:54+00:00"
|
225
|
+
},
|
226
|
+
{
|
227
|
+
"spot": {
|
228
|
+
"name": "Dos Perros",
|
229
|
+
"address": {
|
230
|
+
"region": "NC",
|
231
|
+
"locality": "Durham"
|
232
|
+
},
|
233
|
+
"url": "/spots/28376",
|
234
|
+
"image_url": "http://static.gowalla.com/categories/15-standard.png"
|
235
|
+
},
|
236
|
+
"checkins_count": 1,
|
237
|
+
"first_checkin_at": "2010-01-14T01:43:34+00:00",
|
238
|
+
"last_checkin_at": "2010-01-14T01:43:34+00:00"
|
239
|
+
},
|
240
|
+
{
|
241
|
+
"spot": {
|
242
|
+
"name": "Chik-fil-a",
|
243
|
+
"address": {
|
244
|
+
"region": "NC",
|
245
|
+
"locality": "Durham"
|
246
|
+
},
|
247
|
+
"url": "/spots/34401",
|
248
|
+
"image_url": "http://static.gowalla.com/categories/64-standard.png"
|
249
|
+
},
|
250
|
+
"checkins_count": 1,
|
251
|
+
"first_checkin_at": "2010-01-13T19:10:19+00:00",
|
252
|
+
"last_checkin_at": "2010-01-13T19:10:19+00:00"
|
253
|
+
},
|
254
|
+
{
|
255
|
+
"spot": {
|
256
|
+
"name": "The Pit",
|
257
|
+
"address": {
|
258
|
+
"region": "NC",
|
259
|
+
"locality": "Raleigh"
|
260
|
+
},
|
261
|
+
"url": "/spots/40418",
|
262
|
+
"image_url": "http://static.gowalla.com/categories/17-standard.png"
|
263
|
+
},
|
264
|
+
"checkins_count": 1,
|
265
|
+
"first_checkin_at": "2010-01-13T00:38:04+00:00",
|
266
|
+
"last_checkin_at": "2010-01-13T00:38:04+00:00"
|
267
|
+
},
|
268
|
+
{
|
269
|
+
"spot": {
|
270
|
+
"name": "Four Points Sheraton",
|
271
|
+
"address": {
|
272
|
+
"region": "NC",
|
273
|
+
"locality": "Durham"
|
274
|
+
},
|
275
|
+
"url": "/spots/371276",
|
276
|
+
"image_url": "http://static.gowalla.com/categories/47-standard.png"
|
277
|
+
},
|
278
|
+
"checkins_count": 1,
|
279
|
+
"first_checkin_at": "2010-01-12T22:28:46+00:00",
|
280
|
+
"last_checkin_at": "2010-01-12T22:28:46+00:00"
|
281
|
+
}]
|
282
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"add_friend_url": "/friendships/request?user_id=19628",
|
3
|
+
"bio": "bio",
|
4
|
+
"friends_url": "/users/19628/friends",
|
5
|
+
"hometown": "Minneapolis, MN",
|
6
|
+
"friends_count": 13,
|
7
|
+
"stamps_url": "/users/19628/stamps",
|
8
|
+
"_is_friend": false,
|
9
|
+
"activity_url": "/users/19628/events",
|
10
|
+
"last_checkins": [{
|
11
|
+
"type": "checkin",
|
12
|
+
"message": "",
|
13
|
+
"url": "/checkins/3537914",
|
14
|
+
"spot": {
|
15
|
+
"name": "Roosevelt High School",
|
16
|
+
"url": "/spots/456547",
|
17
|
+
"image_url": "http://static.gowalla.com/categories/152-standard.png"
|
18
|
+
},
|
19
|
+
"created_at": "2010-02-17T01:00:27+00:00"
|
20
|
+
}],
|
21
|
+
"pins_url": "/users/19628/pins",
|
22
|
+
"first_name": "Andy",
|
23
|
+
"twitter_username": "webandy",
|
24
|
+
"items_url": "/users/19628/items",
|
25
|
+
"items_count": 9,
|
26
|
+
"url": "/users/19628",
|
27
|
+
"pins_count": 7,
|
28
|
+
"stamps_count": 69,
|
29
|
+
"facebook_id": 13902138,
|
30
|
+
"website": 'http://webandy.com',
|
31
|
+
"last_name": "Atkinson",
|
32
|
+
"top_spots_url": "/users/19628/top_spots",
|
33
|
+
"image_url": "http://s3.amazonaws.com/static.gowalla.com/users/19628-standard.jpg?1260860820"
|
34
|
+
}
|
data/test/helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
require 'init'
|
6
|
+
include Gowalla
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
10
|
+
|
11
|
+
class Test::Unit::TestCase
|
12
|
+
end
|
data/test/test_stamp.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestStamp < Test::Unit::TestCase
|
4
|
+
context 'Stamps' do
|
5
|
+
setup do
|
6
|
+
@username = 'andyatkinson'
|
7
|
+
@stamp_data = YAML::load_file(File.join(File.dirname(__FILE__), "fixtures", "stamps.json"))
|
8
|
+
Stamp.stubs(:fetch).with(@username).returns(@stamp_data)
|
9
|
+
@stamp = Stamp.find(@username).first
|
10
|
+
end
|
11
|
+
should "API response for stamp should match number of fields being stored" do
|
12
|
+
assert_equal @stamp_data["stamps"].first.size, (Stamp.public_instance_methods(false).size / 2)
|
13
|
+
end
|
14
|
+
should "should have a spot with all fields" do
|
15
|
+
assert_equal 'Roosevelt High School', @stamp.spot.name
|
16
|
+
assert_equal Address, @stamp.spot.address.class
|
17
|
+
assert_equal "MN", @stamp.spot.address.region
|
18
|
+
assert_equal "Minneapolis", @stamp.spot.address.locality
|
19
|
+
assert_equal "/spots/456547", @stamp.spot.url
|
20
|
+
assert_equal "http://static.gowalla.com/categories/152-standard.png", @stamp.spot.image_url
|
21
|
+
assert_equal Spot, @stamp.spot.class
|
22
|
+
end
|
23
|
+
should "have a checkins count" do
|
24
|
+
assert_equal 2, @stamp.checkins_count.to_i
|
25
|
+
end
|
26
|
+
should "have a first checkin at date and time" do
|
27
|
+
assert_equal DateTime, @stamp.first_checkin_at.class
|
28
|
+
assert_equal DateTime.parse("2010-01-26T23:24:13+00:00"), @stamp.first_checkin_at
|
29
|
+
end
|
30
|
+
should "have a last checkin at date and time" do
|
31
|
+
assert_equal DateTime, @stamp.last_checkin_at.class
|
32
|
+
assert_equal DateTime.parse("2010-02-17T01:00:27+00:00"), @stamp.last_checkin_at
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/test/test_user.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestUser < Test::Unit::TestCase
|
4
|
+
context 'A user' do
|
5
|
+
setup do
|
6
|
+
@username = 'andyatkinson'
|
7
|
+
@user_data = YAML::load_file File.join(File.dirname(__FILE__), "fixtures", "user.json")
|
8
|
+
User.stubs(:fetch).with(@username).returns(@user_data)
|
9
|
+
@user = User.find(@username)
|
10
|
+
end
|
11
|
+
should "have a specific amount of data" do
|
12
|
+
# ensure stub API response has all the User fields covered, divide in half for just the getters
|
13
|
+
assert_equal @user_data.size, (User.public_instance_methods(false).size / 2)
|
14
|
+
end
|
15
|
+
should "have a first name" do
|
16
|
+
assert_equal 'Andy', @user.first_name
|
17
|
+
assert_equal String, @user.first_name.class
|
18
|
+
end
|
19
|
+
should "have a last name" do
|
20
|
+
assert_equal 'Atkinson', @user.last_name
|
21
|
+
assert_equal String, @user.last_name.class
|
22
|
+
end
|
23
|
+
should "have a top spots URL" do
|
24
|
+
assert_equal "/users/19628/top_spots", @user.top_spots_url
|
25
|
+
assert_equal String, @user.top_spots_url.class
|
26
|
+
end
|
27
|
+
should "have a image url" do
|
28
|
+
assert_equal 'http://s3.amazonaws.com/static.gowalla.com/users/19628-standard.jpg?1260860820', @user.image_url
|
29
|
+
assert_equal String, @user.image_url.class
|
30
|
+
end
|
31
|
+
should "have a url" do
|
32
|
+
assert_equal '/users/19628', @user.url
|
33
|
+
assert_equal String, @user.url.class
|
34
|
+
end
|
35
|
+
should "have an activity url" do
|
36
|
+
assert_equal '/users/19628/events', @user.activity_url
|
37
|
+
assert_equal String, @user.activity_url.class
|
38
|
+
end
|
39
|
+
should "have a bio" do
|
40
|
+
assert_equal 'bio', @user.bio
|
41
|
+
assert_equal String, @user.bio.class
|
42
|
+
end
|
43
|
+
should "have a stamps count" do
|
44
|
+
assert_equal 69, @user.stamps_count
|
45
|
+
assert_equal Fixnum, @user.stamps_count.class
|
46
|
+
end
|
47
|
+
should "have a stamps URL" do
|
48
|
+
assert_equal '/users/19628/stamps', @user.stamps_url
|
49
|
+
assert_equal String, @user.stamps_url.class
|
50
|
+
end
|
51
|
+
should "have a items count" do
|
52
|
+
assert_equal 9, @user.items_count
|
53
|
+
assert_equal Fixnum, @user.items_count.class
|
54
|
+
end
|
55
|
+
should "have a items URL" do
|
56
|
+
assert_equal '/users/19628/items', @user.items_url
|
57
|
+
assert_equal String, @user.items_url.class
|
58
|
+
end
|
59
|
+
should "have a hometown" do
|
60
|
+
assert_equal 'Minneapolis, MN', @user.hometown
|
61
|
+
assert_equal String, @user.hometown.class
|
62
|
+
end
|
63
|
+
should "have a pins url" do
|
64
|
+
assert_equal '/users/19628/pins', @user.pins_url
|
65
|
+
assert_equal String, @user.pins_url.class
|
66
|
+
end
|
67
|
+
should "have a pins count" do
|
68
|
+
assert_equal 7, @user.pins_count.to_i
|
69
|
+
assert_equal Fixnum, @user.pins_count.class
|
70
|
+
end
|
71
|
+
should "have a friends count" do
|
72
|
+
assert_equal 13, @user.friends_count.to_i
|
73
|
+
assert_equal Fixnum, @user.friends_count.class
|
74
|
+
end
|
75
|
+
should "have a website" do
|
76
|
+
assert_equal 'http://webandy.com', @user.website
|
77
|
+
assert_equal String, @user.website.class
|
78
|
+
end
|
79
|
+
should "have a twitter username" do
|
80
|
+
assert_equal 'webandy', @user.twitter_username
|
81
|
+
assert_equal String, @user.twitter_username.class
|
82
|
+
end
|
83
|
+
should "have a facebook ID" do
|
84
|
+
assert_equal 13902138, @user.facebook_id.to_i
|
85
|
+
assert_equal Fixnum, @user.facebook_id.class
|
86
|
+
end
|
87
|
+
should "have an add friend URL" do
|
88
|
+
assert_equal '/friendships/request?user_id=19628', @user.add_friend_url
|
89
|
+
assert_equal String, @user.add_friend_url.class
|
90
|
+
end
|
91
|
+
should "have a friends URL" do
|
92
|
+
assert_equal '/users/19628/friends', @user.friends_url
|
93
|
+
assert_equal String, @user.friends_url.class
|
94
|
+
end
|
95
|
+
should "indicate whether is a friend of current user" do
|
96
|
+
assert_equal false, @user._is_friend
|
97
|
+
end
|
98
|
+
should "have last checkins" do
|
99
|
+
assert_equal Array, @user.last_checkins.class
|
100
|
+
assert_equal Checkin, @user.last_checkins.first.class
|
101
|
+
end
|
102
|
+
should "have stamps" do
|
103
|
+
assert_equal 20, @user.stamps.size
|
104
|
+
assert_equal Gowalla::Stamp, @user.stamps.first.class
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gowalla-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Atkinson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-21 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.5.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: shoulda
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.10.3
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mocha
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.9.7
|
44
|
+
version:
|
45
|
+
description: Gowalla API wrapper for Ruby
|
46
|
+
email: andy@webandy.com
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.markdown
|
54
|
+
- lib/gowalla.rb
|
55
|
+
- lib/gowalla/address.rb
|
56
|
+
- lib/gowalla/base.rb
|
57
|
+
- lib/gowalla/checkin.rb
|
58
|
+
- lib/gowalla/spot.rb
|
59
|
+
- lib/gowalla/stamp.rb
|
60
|
+
- lib/gowalla/user.rb
|
61
|
+
files:
|
62
|
+
- LICENSE
|
63
|
+
- README.markdown
|
64
|
+
- Rakefile
|
65
|
+
- init.rb
|
66
|
+
- lib/gowalla.rb
|
67
|
+
- lib/gowalla/address.rb
|
68
|
+
- lib/gowalla/base.rb
|
69
|
+
- lib/gowalla/checkin.rb
|
70
|
+
- lib/gowalla/spot.rb
|
71
|
+
- lib/gowalla/stamp.rb
|
72
|
+
- lib/gowalla/user.rb
|
73
|
+
- test/fixtures/stamps.json
|
74
|
+
- test/fixtures/user.json
|
75
|
+
- test/helper.rb
|
76
|
+
- test/test_stamp.rb
|
77
|
+
- test/test_user.rb
|
78
|
+
- Manifest
|
79
|
+
- gowalla-ruby.gemspec
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/webandy/gowalla-ruby
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options:
|
86
|
+
- --line-numbers
|
87
|
+
- --inline-source
|
88
|
+
- --title
|
89
|
+
- Gowalla-ruby
|
90
|
+
- --main
|
91
|
+
- README.markdown
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: "0"
|
99
|
+
version:
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "1.2"
|
105
|
+
version:
|
106
|
+
requirements: []
|
107
|
+
|
108
|
+
rubyforge_project: gowalla-ruby
|
109
|
+
rubygems_version: 1.3.5
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: Gowalla API wrapper for Ruby
|
113
|
+
test_files:
|
114
|
+
- test/test_stamp.rb
|
115
|
+
- test/test_user.rb
|