fleakr 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +27 -7
- data/Rakefile +1 -0
- data/lib/fleakr.rb +2 -1
- data/lib/fleakr/api/method_request.rb +5 -1
- data/lib/fleakr/api/upload_request.rb +5 -0
- data/lib/fleakr/objects/photo.rb +1 -1
- data/lib/fleakr/version.rb +1 -1
- metadata +12 -2
data/README.rdoc
CHANGED
@@ -186,19 +186,39 @@ Once this is set, you'll see your Authentication URL on the key details page (it
|
|
186
186
|
something like http://www.flickr.com/auth-534525246245). Paste this URL into your browser and
|
187
187
|
confirm access to get your mini-token. Now you're ready to make authenticated requests:
|
188
188
|
|
189
|
-
|
190
|
-
|
189
|
+
require 'rubygems'
|
190
|
+
require 'fleakr'
|
191
191
|
|
192
|
-
|
193
|
-
|
194
|
-
|
192
|
+
Fleakr.api_key = 'ABC123'
|
193
|
+
Fleakr.shared_secret = 'sekrit' # Available with your key details on the Flickr site
|
194
|
+
Fleakr.mini_token = '362-133-214'
|
195
195
|
|
196
|
-
|
197
|
-
|
196
|
+
Fleakr.upload('/path/to/my/photo.jpg')
|
197
|
+
Fleakr.token.value # => "34132412341235-12341234ef34"
|
198
198
|
|
199
199
|
Once you use the mini-token once, it is no longer available. To use the generated auth_token
|
200
200
|
for future requests, just set Fleakr.auth_token to the generated value.
|
201
201
|
|
202
|
+
=== What Went Wrong?
|
203
|
+
|
204
|
+
Because so much of the underlying API is hidden under the covers, it's often tough to know
|
205
|
+
what's really going on when you run into unexpected behavior. To make things easier, you can
|
206
|
+
have Fleakr log all of the API traffic. Here's how:
|
207
|
+
|
208
|
+
Fleakr.logger = Logger.new('/tmp/fleakr.log')
|
209
|
+
|
210
|
+
Now any calls to the API will log both their request and response data to that file. But be
|
211
|
+
warned, this can be pretty verbose by default (especially if you're doing file uploads). To see
|
212
|
+
just the requests you need to tune the log level:
|
213
|
+
|
214
|
+
logger = Logger.new('/tmp/fleakr.log')
|
215
|
+
logger.level = Logger::INFO
|
216
|
+
|
217
|
+
Fleakr.logger = logger
|
218
|
+
|
219
|
+
Even if something doesn't go wrong, this is a good way to get a sense for when you're making
|
220
|
+
API requests.
|
221
|
+
|
202
222
|
== Roadmap / TODO
|
203
223
|
|
204
224
|
=== 0.4.x
|
data/Rakefile
CHANGED
data/lib/fleakr.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__))
|
2
|
+
require 'rubygems'
|
2
3
|
|
3
4
|
require 'uri'
|
4
5
|
require 'cgi'
|
5
6
|
require 'net/http'
|
6
|
-
require 'rubygems'
|
7
7
|
require 'hpricot'
|
8
8
|
require 'activesupport'
|
9
9
|
require 'md5'
|
10
|
+
require 'loggable'
|
10
11
|
|
11
12
|
require 'fleakr/api'
|
12
13
|
require 'fleakr/core_ext'
|
@@ -41,7 +41,11 @@ module Fleakr
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def send # :nodoc:
|
44
|
-
|
44
|
+
logger.info("Sending request to: #{endpoint_uri}")
|
45
|
+
response_xml = Net::HTTP.get(endpoint_uri)
|
46
|
+
logger.debug("Response data:\n#{response_xml}")
|
47
|
+
|
48
|
+
Response.new(response_xml)
|
45
49
|
end
|
46
50
|
|
47
51
|
private
|
@@ -49,8 +49,13 @@ module Fleakr
|
|
49
49
|
|
50
50
|
def send # :nodoc:
|
51
51
|
response = Net::HTTP.start(endpoint_uri.host, endpoint_uri.port) do |http|
|
52
|
+
logger.info("Sending upload request to: #{endpoint_uri}")
|
53
|
+
logger.debug("Request data:\n#{self.parameters.to_form}")
|
54
|
+
logger.debug("Request headers:\n#{self.headers.inspect}")
|
55
|
+
|
52
56
|
http.post(endpoint_uri.path, self.parameters.to_form, self.headers)
|
53
57
|
end
|
58
|
+
logger.debug("Response data:\n#{response.body}")
|
54
59
|
Response.new(response.body)
|
55
60
|
end
|
56
61
|
|
data/lib/fleakr/objects/photo.rb
CHANGED
@@ -53,7 +53,7 @@ module Fleakr
|
|
53
53
|
find_all :by_user_id, :call => 'people.getPublicPhotos', :path => 'photos/photo'
|
54
54
|
find_all :by_group_id, :call => 'groups.pools.getPhotos', :path => 'photos/photo'
|
55
55
|
|
56
|
-
find_one :by_id, :using => :photo_id, :call => 'photos.getInfo'
|
56
|
+
find_one :by_id, :using => :photo_id, :call => 'photos.getInfo'
|
57
57
|
|
58
58
|
lazily_load :posted, :taken, :updated, :comment_count, :url, :description, :with => :load_info
|
59
59
|
|
data/lib/fleakr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fleakr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Reagan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,16 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.2.0
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: loggable
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.2.0
|
44
|
+
version:
|
35
45
|
description:
|
36
46
|
email: reaganpr@gmail.com
|
37
47
|
executables: []
|