tomk32-flickr_fu 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/flickr/base.rb +1 -1
- data/lib/flickr/photo.rb +41 -70
- data/tomk32-flickr_fu.gemspec +2 -2
- metadata +3 -3
data/VERSION.yml
CHANGED
data/lib/flickr/base.rb
CHANGED
data/lib/flickr/photo.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
class Flickr::Photos::Photo
|
3
3
|
attr_accessor :id, :owner, :secret, :server, :farm, :title, :is_public, :is_friend, :is_family # standard attributes
|
4
4
|
attr_accessor :license_id, :uploaded_at, :taken_at, :owner_name, :icon_server, :original_format, :updated_at, :geo, :tags, :machine_tags, :o_dims, :views, :media # extra attributes
|
5
|
-
attr_accessor :info_added, :description, :original_secret, :owner_username, :owner_realname, :url_photopage, :notes # info attributes
|
6
5
|
attr_accessor :comments # comment attributes
|
7
6
|
|
8
7
|
# create a new instance of a flickr photo.
|
@@ -24,11 +23,6 @@ class Flickr::Photos::Photo
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
# Alias to image_url method
|
28
|
-
def url(size = :medium)
|
29
|
-
image_url(size)
|
30
|
-
end
|
31
|
-
|
32
26
|
# returns an instance of Flickr::Photos::Size for the required size
|
33
27
|
#
|
34
28
|
# Params
|
@@ -60,23 +54,24 @@ class Flickr::Photos::Photo
|
|
60
54
|
# :original - original image, either a jpg, gif or png, depending on source format
|
61
55
|
#
|
62
56
|
def image_url(size = :medium)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
57
|
+
# It turns out that flickr always stores all the sizes of the picture even when getSizes call returns otherwise.
|
58
|
+
# Not calling getSizes is also very important for performance reasons.
|
59
|
+
# Retrieving 30 search results means calling the API 31 times if you call getSizes every time.
|
60
|
+
# Mind that you still need to call getSizes if you go out for the original image.
|
61
|
+
if size == :original
|
62
|
+
return original_url if respond_to?(:original_url) and !original_url.blank?
|
63
|
+
size_hash[size.to_s].source if size_hash.has_key? size.to_s
|
64
|
+
else
|
65
|
+
key = "_#{size_key(size.to_sym)}"
|
66
|
+
key = "" if key == "_"
|
67
|
+
"http://farm#{farm}.static.flickr.com/#{server}/#{id}_#{secret}#{key}.jpg"
|
68
|
+
end
|
75
69
|
end
|
70
|
+
alias :url :image_url
|
76
71
|
|
77
72
|
def photopage_url
|
78
|
-
|
79
|
-
|
73
|
+
# Keeping the same convention as image_url (foo_url)
|
74
|
+
url_photopage
|
80
75
|
end
|
81
76
|
|
82
77
|
def video_url
|
@@ -203,16 +198,6 @@ class Flickr::Photos::Photo
|
|
203
198
|
@flickr.send_request('flickr.photos.licenses.setLicense', {:photo_id => self.id, :license_id => license_id}, :post)
|
204
199
|
true
|
205
200
|
end
|
206
|
-
|
207
|
-
def description # :nodoc:
|
208
|
-
attach_info
|
209
|
-
@description
|
210
|
-
end
|
211
|
-
|
212
|
-
def original_secret # :nodoc:
|
213
|
-
attach_info
|
214
|
-
@original_secret
|
215
|
-
end
|
216
201
|
|
217
202
|
def public?
|
218
203
|
is_public == "1"
|
@@ -225,21 +210,6 @@ class Flickr::Photos::Photo
|
|
225
210
|
def family?
|
226
211
|
is_family == "1"
|
227
212
|
end
|
228
|
-
|
229
|
-
def owner_username # :nodoc:
|
230
|
-
attach_info
|
231
|
-
@owner_username
|
232
|
-
end
|
233
|
-
|
234
|
-
def owner_realname # :nodoc:
|
235
|
-
attach_info
|
236
|
-
@owner_realname
|
237
|
-
end
|
238
|
-
|
239
|
-
def url_photopage # :nodoc:
|
240
|
-
attach_info
|
241
|
-
@url_photopage
|
242
|
-
end
|
243
213
|
|
244
214
|
def comments # :nodoc:
|
245
215
|
@comments ||= begin
|
@@ -277,9 +247,11 @@ class Flickr::Photos::Photo
|
|
277
247
|
end
|
278
248
|
end
|
279
249
|
|
280
|
-
def
|
281
|
-
|
282
|
-
|
250
|
+
def method_missing(method, *args, &block)
|
251
|
+
if [:description, :original_secret, :owner_username, :owner_realname, :url_photopage, :notes].include?(method.to_sym)
|
252
|
+
@attach_info ||= attach_info
|
253
|
+
return @attach_info[method.to_sym]
|
254
|
+
end
|
283
255
|
end
|
284
256
|
|
285
257
|
protected
|
@@ -311,29 +283,28 @@ class Flickr::Photos::Photo
|
|
311
283
|
|
312
284
|
# loads photo info when a field is requested that requires additional info
|
313
285
|
def attach_info
|
314
|
-
|
315
|
-
rsp = @flickr.send_request('flickr.photos.getInfo', :photo_id => self.id, :secret => self.secret)
|
316
|
-
|
317
|
-
self.info_added = true
|
318
|
-
self.description = rsp.photo.description.to_s.strip
|
319
|
-
self.original_secret = rsp.photo[:originalsecret]
|
320
|
-
self.owner_username = rsp.photo.owner[:username]
|
321
|
-
self.owner_realname = rsp.photo.owner[:realname]
|
322
|
-
self.url_photopage = rsp.photo.urls.url.to_s
|
323
|
-
self.comment_count = rsp.photo.comments.to_s.to_i
|
286
|
+
rsp = @flickr.send_request('flickr.photos.getInfo', :photo_id => self.id, :secret => self.secret)
|
324
287
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
end if rsp.photo.notes.note
|
288
|
+
if rsp.photo.notes.note
|
289
|
+
notes = rsp.photo.notes.note.collect do |note|
|
290
|
+
Flickr::Photos::Note.new(:id => note[:id],
|
291
|
+
:note => note.to_s,
|
292
|
+
:author => note[:author],
|
293
|
+
:author_name => note[:authorname],
|
294
|
+
:x => note[:x],
|
295
|
+
:y => note[:y],
|
296
|
+
:width => note[:w],
|
297
|
+
:height => note[:h])
|
298
|
+
end
|
337
299
|
end
|
300
|
+
return {
|
301
|
+
:description => rsp.photo.description.to_s.strip,
|
302
|
+
:original_secret => rsp.photo[:originalsecret],
|
303
|
+
:owner_username => rsp.photo.owner[:username],
|
304
|
+
:owner_realname => rsp.photo.owner[:realname],
|
305
|
+
:url_photopage => rsp.photo.urls.url.to_s,
|
306
|
+
:comment_count => rsp.photo.comments.to_s.to_i,
|
307
|
+
:notes => notes
|
308
|
+
}
|
338
309
|
end
|
339
310
|
end
|
data/tomk32-flickr_fu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tomk32-flickr_fu}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Wyrosdick", "Maciej Bilas", "Thomas R. Koll"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-22}
|
13
13
|
s.description = %q{Provides a ruby interface to flickr via the REST api}
|
14
14
|
s.email = %q{tomk32@gmx.de}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben Wyrosdick
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-04-
|
19
|
+
date: 2010-04-22 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|