foursquare-oauth 0.2.2 → 0.2.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/Rakefile +44 -36
- data/lib/foursquare.rb +92 -54
- metadata +12 -11
data/Rakefile
CHANGED
@@ -4,49 +4,57 @@ require 'rubygems/specification'
|
|
4
4
|
require 'date'
|
5
5
|
require 'spec/rake/spectask'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
s.add_dependency('oauth', '0.3.6')
|
26
|
-
s.add_dependency('hashie', '0.1.5')
|
27
|
-
end
|
7
|
+
begin
|
8
|
+
require 'jeweler'
|
9
|
+
Jeweler::Tasks.new do |s|
|
10
|
+
s.name = "foursquare-oauth"
|
11
|
+
s.version = '0.2.3'
|
12
|
+
s.authors = ['Jeremy Welch', 'Thomas Hanley', 'Elise Wood']
|
13
|
+
s.email = "hello@jeremyrwelch.com"
|
14
|
+
s.homepage = "http://github.com/glytch/Foursquare"
|
15
|
+
s.description = s.summary = "A simple Ruby wrapper for the Foursquare API"
|
16
|
+
s.post_install_message = "NOTE: This version of the Foursquare Gem has significant changes to the way methods are called. Please review the examples in the README"
|
17
|
+
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.extra_rdoc_files = ["README.rdoc", "History"]
|
21
|
+
|
22
|
+
s.require_path = 'lib'
|
23
|
+
s.autorequire = 'foursquare'
|
24
|
+
s.files = %w(README.rdoc Rakefile History) + Dir.glob("{lib,spec,script,examples}/**/*")
|
28
25
|
|
29
|
-
|
26
|
+
s.add_dependency('httparty', '0.5.0')
|
27
|
+
s.add_dependency('oauth', '0.3.6')
|
28
|
+
s.add_dependency('hashie', '0.1.5')
|
29
|
+
end
|
30
|
+
rescue LoadError
|
31
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
32
|
+
end
|
30
33
|
|
31
|
-
desc "Run specs"
|
32
34
|
Spec::Rake::SpecTask.new do |t|
|
33
35
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
34
|
-
t.spec_opts = %w(-fs --color)
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
-
Rake::
|
39
|
-
|
38
|
+
desc "Run all examples with RCov"
|
39
|
+
Spec::Rake::SpecTask.new('rcov') do |t|
|
40
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
41
|
+
t.rcov = true
|
40
42
|
end
|
41
43
|
|
42
|
-
desc
|
43
|
-
task :
|
44
|
-
|
44
|
+
desc 'Confirm that gemspec is $SAFE'
|
45
|
+
task :safe do
|
46
|
+
require 'yaml'
|
47
|
+
require 'rubygems/specification'
|
48
|
+
data = File.read('rack-oauth.gemspec')
|
49
|
+
spec = nil
|
50
|
+
if data !~ %r{!ruby/object:Gem::Specification}
|
51
|
+
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
52
|
+
else
|
53
|
+
spec = YAML.load(data)
|
54
|
+
end
|
55
|
+
spec.validate
|
56
|
+
puts spec
|
57
|
+
puts "OK"
|
45
58
|
end
|
46
59
|
|
47
|
-
|
48
|
-
task :make_spec do
|
49
|
-
File.open("foursquare.gemspec", "w") do |file|
|
50
|
-
file.puts spec.to_ruby
|
51
|
-
end
|
52
|
-
end
|
60
|
+
task :default => :spec
|
data/lib/foursquare.rb
CHANGED
@@ -3,10 +3,6 @@ require 'httparty'
|
|
3
3
|
require 'hashie'
|
4
4
|
require 'oauth'
|
5
5
|
|
6
|
-
Hash.send :include, Hashie::HashExtensions
|
7
|
-
|
8
|
-
|
9
|
-
|
10
6
|
module Foursquare
|
11
7
|
class OAuth
|
12
8
|
def initialize(ctoken, csecret, options={})
|
@@ -84,23 +80,23 @@ module Foursquare
|
|
84
80
|
# the right side of the assignment operator. So there are some wrapper methods below
|
85
81
|
# for POSTs that make sure it gets turned into a hashie
|
86
82
|
#
|
87
|
-
def method_missing(method_symbol, params = {})
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
def api(method_symbol, params = {})
|
101
|
-
|
102
|
-
end
|
103
|
-
|
83
|
+
# def method_missing(method_symbol, params = {})
|
84
|
+
# method_name = method_symbol.to_s.split(/\.|_/).join('/')
|
85
|
+
#
|
86
|
+
# if (method_name[-1,1]) == '='
|
87
|
+
# method = method_name[0..-2]
|
88
|
+
# result = post(api_url(method), params)
|
89
|
+
# params.replace(result[method] || result)
|
90
|
+
# else
|
91
|
+
# result = get(api_url(method_name, params))
|
92
|
+
# result[method_name] || result
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
#
|
96
|
+
# def api(method_symbol, params = {})
|
97
|
+
# Hashie::Mash.new(method_missing(method_symbol, params))
|
98
|
+
# end
|
99
|
+
#
|
104
100
|
def api_url(method_name, options = nil)
|
105
101
|
params = options.is_a?(Hash) ? to_query_params(options) : options
|
106
102
|
params = nil if params and params.blank?
|
@@ -112,89 +108,131 @@ module Foursquare
|
|
112
108
|
|
113
109
|
def parse_response(response)
|
114
110
|
raise_errors(response)
|
115
|
-
|
111
|
+
|
112
|
+
Hashie::Mash.new(Yajl::Parser.parse(response.body))
|
116
113
|
end
|
117
114
|
|
118
115
|
def to_query_params(options)
|
119
|
-
options.
|
116
|
+
options.map{|key, value| "#{key}=#{value}"}.join('&')
|
120
117
|
end
|
121
118
|
|
122
|
-
def get(url)
|
123
|
-
parse_response(@oauth.access_token.get(url))
|
119
|
+
def get(url, params)
|
120
|
+
parse_response(@oauth.access_token.get(api_url(url, params)))
|
124
121
|
end
|
125
122
|
|
126
123
|
def post(url, body)
|
127
|
-
parse_response(@oauth.access_token.post(url, body))
|
124
|
+
parse_response(@oauth.access_token.post(api_url(url), body))
|
128
125
|
end
|
129
126
|
|
130
127
|
# API method wrappers
|
131
128
|
|
129
|
+
# Check in methods
|
130
|
+
|
131
|
+
def checkins(params = {})
|
132
|
+
get('/checkins', params).checkins
|
133
|
+
end
|
134
|
+
|
132
135
|
def checkin(params = {})
|
133
|
-
|
136
|
+
post('/checkin', params).checkin
|
134
137
|
end
|
135
138
|
|
136
139
|
def history(params = {})
|
137
|
-
|
140
|
+
get('/history', params).checkins
|
141
|
+
end
|
142
|
+
|
143
|
+
# User methods
|
144
|
+
|
145
|
+
def user(params = {})
|
146
|
+
get('/user', params).user
|
138
147
|
end
|
139
148
|
|
140
|
-
def
|
141
|
-
|
149
|
+
def friends(params = {})
|
150
|
+
get('/friends', params).friends
|
142
151
|
end
|
143
152
|
|
144
|
-
|
145
|
-
|
153
|
+
# Venue methods
|
154
|
+
|
155
|
+
def venues(params = {})
|
156
|
+
get('/venues', params).venues
|
157
|
+
end
|
158
|
+
|
159
|
+
def venue(params = P)
|
160
|
+
get('/venue', params).venue
|
161
|
+
end
|
162
|
+
|
163
|
+
def categories
|
164
|
+
get('/categories', params).categories
|
165
|
+
end
|
166
|
+
|
167
|
+
def add_venue(params = {})
|
168
|
+
post('/addvenue', params).venue
|
169
|
+
end
|
170
|
+
|
171
|
+
def venue_propose_edit(params = {})
|
172
|
+
post('/venue/proposeedit', params)
|
173
|
+
end
|
174
|
+
|
175
|
+
def venue_flag_closed(params = {})
|
176
|
+
post('/venue/flagclosed', params)
|
146
177
|
end
|
147
178
|
|
148
|
-
|
149
|
-
|
179
|
+
# Tip methods
|
180
|
+
|
181
|
+
def tips(params = {})
|
182
|
+
get('/tips', params).tips
|
150
183
|
end
|
151
184
|
|
152
|
-
def
|
153
|
-
|
185
|
+
def add_tip(params = {})
|
186
|
+
post('/addtip', params).tip
|
154
187
|
end
|
155
188
|
|
156
|
-
def
|
157
|
-
|
189
|
+
def tip_mark_todo(params = {})
|
190
|
+
post('/tip/marktodo', params).tip
|
158
191
|
end
|
159
192
|
|
160
|
-
def
|
161
|
-
|
193
|
+
def tip_mark_done(params = {})
|
194
|
+
post('/tip/markdone', params).tip
|
162
195
|
end
|
163
196
|
|
197
|
+
# Friend methods
|
198
|
+
|
164
199
|
def friend_requests
|
165
|
-
|
200
|
+
get('/friend/requests').requests
|
166
201
|
end
|
167
202
|
|
168
203
|
def friend_approve(params = {})
|
169
|
-
|
204
|
+
post('/friend/approve', params).user
|
170
205
|
end
|
171
206
|
|
172
207
|
def friend_deny(params = {})
|
173
|
-
|
208
|
+
post('/friend/deny', params).user
|
174
209
|
end
|
175
210
|
|
176
|
-
def
|
177
|
-
|
211
|
+
def friend_send_request(params = {})
|
212
|
+
post('/friend/sendrequest', params).user
|
178
213
|
end
|
179
214
|
|
180
|
-
def
|
181
|
-
|
215
|
+
def friends_by_name(params = {})
|
216
|
+
post('/findfriends/byname', params).users
|
182
217
|
end
|
183
218
|
|
184
|
-
def
|
185
|
-
|
219
|
+
def friends_by_phone(params = {})
|
220
|
+
get('/findfriends/byphone', params).users
|
186
221
|
end
|
187
222
|
|
188
|
-
def
|
189
|
-
|
223
|
+
def friends_by_twitter(params = {})
|
224
|
+
get('/findfriends/bytwitter', params).users
|
190
225
|
end
|
191
226
|
|
192
|
-
def
|
193
|
-
|
227
|
+
def settings_set_pings(params = {})
|
228
|
+
post('/settings/setpings', params).settings
|
194
229
|
end
|
195
230
|
|
196
|
-
|
231
|
+
def test(params = {})
|
232
|
+
get('/test', params)
|
233
|
+
end
|
197
234
|
|
235
|
+
private
|
198
236
|
|
199
237
|
def raise_errors(response)
|
200
238
|
message = "(#{response.code}): #{response.message} - #{response.inspect} - #{response.body}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foursquare-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Welch
|
@@ -11,7 +11,7 @@ autorequire: foursquare
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2010-03-
|
14
|
+
date: 2010-03-09 00:00:00 -06:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
requirements:
|
23
23
|
- - "="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 0.
|
25
|
+
version: 0.5.0
|
26
26
|
version:
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: oauth
|
@@ -51,24 +51,24 @@ executables: []
|
|
51
51
|
extensions: []
|
52
52
|
|
53
53
|
extra_rdoc_files:
|
54
|
-
- README.rdoc
|
55
54
|
- History
|
55
|
+
- README.rdoc
|
56
56
|
files:
|
57
|
+
- History
|
57
58
|
- README.rdoc
|
58
59
|
- Rakefile
|
59
|
-
- History
|
60
60
|
- lib/foursquare.rb
|
61
|
-
- spec/foursquare_spec.rb
|
62
|
-
- spec/spec_helper.rb
|
63
61
|
- script/destroy
|
64
62
|
- script/generate
|
63
|
+
- spec/foursquare_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
65
|
has_rdoc: true
|
66
66
|
homepage: http://github.com/glytch/Foursquare
|
67
67
|
licenses: []
|
68
68
|
|
69
69
|
post_install_message: "NOTE: This version of the Foursquare Gem has significant changes to the way methods are called. Please review the examples in the README"
|
70
|
-
rdoc_options:
|
71
|
-
|
70
|
+
rdoc_options:
|
71
|
+
- --charset=UTF-8
|
72
72
|
require_paths:
|
73
73
|
- lib
|
74
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -90,5 +90,6 @@ rubygems_version: 1.3.5
|
|
90
90
|
signing_key:
|
91
91
|
specification_version: 3
|
92
92
|
summary: A simple Ruby wrapper for the Foursquare API
|
93
|
-
test_files:
|
94
|
-
|
93
|
+
test_files:
|
94
|
+
- spec/foursquare_spec.rb
|
95
|
+
- spec/spec_helper.rb
|