flickraw 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -25,6 +25,7 @@ This will recreate the documentation by fetching the methods descriptions from f
25
25
  * Photo upload
26
26
  * Proxy support
27
27
  * Delayed library loading (for rails users)
28
+ * Flickr URLs helpers
28
29
 
29
30
  = Usage
30
31
 
@@ -115,9 +116,56 @@ You can pass some options to modify flickraw behavior:
115
116
 
116
117
  require 'flickraw'
117
118
 
119
+ == Flickr URL Helpers
120
+
121
+ There are some helpers to build flickr urls :
122
+
123
+ === url, url_m, url_s, url_t, url_b, url_o
124
+
125
+ info = flickr.photos.getInfo(:photo_id => "3839885270")
126
+ FlickRaw.url_b(info) # => "http://farm3.static.flickr.com/2485/3839885270_6fb8b54e06_b.jpg"
127
+
128
+ === url_profile
129
+
130
+ info = flickr.photos.getInfo(:photo_id => "3839885270")
131
+ FlickRaw.url_profile(info) # => "http://www.flickr.com/people/41650587@N02/"
132
+
133
+ === url_photopage
134
+
135
+ info = flickr.photos.getInfo(:photo_id => "3839885270")
136
+ FlickRaw.url_photopage(photo) # => "http://www.flickr.com/photos/41650587@N02/3839885270"
137
+
138
+ === url_photoset, url_photosets
139
+
140
+ info = flickr.photos.getInfo(:photo_id => "3839885270")
141
+ FlickRaw.url_photosets(photo) # => "http://www.flickr.com/photos/41650587@N02/sets/"
142
+
143
+ === url_short
144
+
145
+ info = flickr.photos.getInfo(:photo_id => "3839885270")
146
+ FlickRaw.url_short(photo) # => "http://flic.kr/p/6Rjq7s"
147
+
148
+ === url_photostream
149
+
150
+ info = flickr.photos.getInfo(:photo_id => "3839885270")
151
+ FlickRaw.url_photostream(photo) # => "http://flic.kr/p/6Rjq7s"
152
+
118
153
 
119
154
  See the _examples_ directory to find more examples.
120
155
 
156
+ == Cached version
157
+
158
+ You can use
159
+
160
+ require 'flickraw-cached'
161
+
162
+ instead of
163
+
164
+ require 'flickraw'
165
+
166
+ This way it it doesn't fetch available flickr methods each time it is loaded.
167
+ The flickraw-cached gem is on rubyforge and should be up-to-date with regard to flickr api most of the time.
168
+
121
169
  = Notes
122
170
  If you want to use the api authenticated with several user at the same time, you must pass the authentication token explicitely each time.
123
171
  This is because it is keeping the authentication token internally.
data/flickraw_rdoc.rb CHANGED
@@ -23,6 +23,7 @@ module RDoc
23
23
 
24
24
  private
25
25
  def add_flickr_methods(obj, doc)
26
+ flickr # Force loading of methods if lazyloaded
26
27
  obj.constants.each { |const_name|
27
28
  const = obj.const_get const_name
28
29
  if const.is_a?(Class) && const < FlickRaw::Request
data/lib/flickraw.rb CHANGED
@@ -33,7 +33,7 @@ if ENV['http_proxy'] and not FlickRawOptions['proxy_host']
33
33
  end
34
34
 
35
35
  module FlickRaw
36
- VERSION='0.8.1'
36
+ VERSION='0.8.2'
37
37
 
38
38
  FLICKR_HOST='api.flickr.com'.freeze
39
39
  REST_PATH='/services/rest/?'.freeze
@@ -44,7 +44,7 @@ module FlickRaw
44
44
  PHOTO_SOURCE_URL='http://farm%s.static.flickr.com/%s/%s_%s%s.%s'.freeze
45
45
  URL_PROFILE='http://www.flickr.com/people/'.freeze
46
46
  URL_PHOTOSTREAM='http://www.flickr.com/photos/'.freeze
47
- URL_SHORT="http://flic.kr/p/".freeze
47
+ URL_SHORT='http://flic.kr/p/'.freeze
48
48
 
49
49
  class Response
50
50
  def self.build(h, type) # :nodoc:
@@ -292,6 +292,9 @@ module FlickRaw
292
292
  def url_photosets(r); url_photostream(r) + "sets/" end
293
293
  def url_photoset(r); url_photosets(r) + r.id end
294
294
  def url_short(r); URL_SHORT + base58(r.id) end
295
+ def url_short_m(r); URL_SHORT + "img/" + base58(r.id) + "_m.jpg" end
296
+ def url_short_s(r); URL_SHORT + "img/" + base58(r.id) + ".jpg" end
297
+ def url_short_t(r); URL_SHORT + "img/" + base58(r.id) + "_t.jpg" end
295
298
  def url_photostream(r)
296
299
  URL_PHOTOSTREAM +
297
300
  if r.respond_to?(:pathalias) and r.pathalias
@@ -313,4 +316,7 @@ end
313
316
  def flickr; $flickraw ||= FlickRaw::Flickr.new end
314
317
 
315
318
  # Load the methods if the option lazyload is not specified
316
- flickr if not FlickRawOptions['lazyload']
319
+ begin
320
+ flickr
321
+ rescue
322
+ end if not FlickRawOptions['lazyload']
data/rakefile CHANGED
@@ -1,8 +1,10 @@
1
+ require 'rake/clean'
1
2
  require 'rake/rdoctask'
2
3
  require 'rake/packagetask'
3
4
  require 'rake/gempackagetask'
4
5
  require 'rake/testtask'
5
6
 
7
+ FlickRawOptions = {'lazyload' => true}
6
8
  require 'lib/flickraw'
7
9
  require 'flickraw_rdoc' if RUBY_VERSION >= "1.9"
8
10
 
@@ -14,27 +16,91 @@ spec = Gem::Specification.new do |s|
14
16
  s.author = "Mael Clerambault"
15
17
  s.email = "maelclerambault@yahoo.fr"
16
18
  s.homepage = "http://hanklords.github.com/flickraw/"
17
- s.rubyforge_project = "flickraw"
18
19
  s.version = FlickRaw::VERSION
19
20
  s.files = PKG_FILES
20
- s.test_files = FileList["test/*.rb"].to_a
21
21
  s.add_dependency 'json', '>= 1.1.1'
22
22
  end
23
23
 
24
+ Rake::GemPackageTask.new(spec).define
25
+
26
+ desc "Create default gemspec file"
27
+ file "flickraw.gemspec" do
28
+ open("flickraw.gemspec", "w") {|g| g.puts spec.to_ruby }
29
+ end
30
+ task :gem => ["flickraw.gemspec"]
31
+ CLOBBER.add "flickraw.gemspec"
32
+
24
33
  Rake::RDocTask.new do |rd|
25
34
  rd.rdoc_files.include "README.rdoc", "lib/flickraw.rb"
26
35
  rd.options << "--inline-source"
27
36
  end
28
37
 
29
- Rake::GemPackageTask.new spec do |p|
30
- p.need_tar_gz = true
38
+ Rake::TestTask.new
39
+
40
+
41
+ # Freezed version tasks
42
+ file "flickraw-cached.rb" do |t|
43
+ open(t.name, "w") {|f|
44
+ f.puts %{FlickRawOptions = {'lazyload' => true}}
45
+ f.puts %{require 'flickraw'}
46
+ f.puts %{FlickRaw::VERSION << '.#{Time.now.strftime("%Y%m%d")}-cached'}
47
+ f.puts 'ms = %w{' + flickr.reflection.getMethods.to_a.join(' ') + '}'
48
+ f.puts %{FlickRaw::Flickr.build(ms)}
49
+ }
31
50
  end
51
+ CLOBBER.add "flickraw-cached.rb"
32
52
 
33
- Rake::TestTask.new
53
+ spec_cached = Gem::Specification.new do |s|
54
+ s.name = 'flickraw-cached'
55
+ s.summary = "Cached version of Flickraw"
56
+ s.author = "Mael Clerambault"
57
+ s.email = "maelclerambault@yahoo.fr"
58
+ s.homepage = "http://hanklords.github.com/flickraw/"
59
+ s.version = Time.now.strftime("%Y%m%d")
60
+ s.files = ["flickraw-cached.rb"]
61
+ s.require_path = '.'
62
+ s.add_dependency 'flickraw'
63
+ end
64
+ Rake::GemPackageTask.new(spec_cached).define
65
+ task :gem => ["flickraw-cached.rb"]
66
+
67
+ desc "Create cached gemspec file"
68
+ file "flickraw-cached.gemspec" do
69
+ open("flickraw-cached.gemspec", "w") {|g| g.puts spec.to_ruby }
70
+ end
71
+ task :gem => ["flickraw-cached.gemspec"]
72
+ CLOBBER.add "flickraw-cached.gemspec"
73
+
74
+ FREEZED_CACHE_FILE = ENV['HOME'] + '/.flickraw_cached'
75
+ task :sync_cached do
76
+ require 'mail'
77
+ Mail.defaults {delivery_method :sendmail}
78
+
79
+ local_list = File.read(FREEZED_CACHE_FILE).split.sort
80
+ remote_list = flickr.reflection.getMethods.to_a.sort
81
+
82
+ if remote_list != local_list
83
+ # Flickr API has been updated
84
+ Mail.deliver do
85
+ from 'flickraw-cached-updater'
86
+ to ENV['MAILTO'] || ENV['LOGNAME']
87
+ subject "[flickraw-cached-updater'] flickraw-cached.gem updated"
88
+ body %|
89
+ flickraw-cached.gem has been updated.
90
+
91
+ New Flickr API methods :
92
+ - #{(remote_list-local_list).join("\n- ")}
93
+ |
94
+ end
95
+
96
+ # Build gem
97
+ Rake.application[:gem].invoke
98
+
99
+ # Upload gem
100
+ sh "gem push pkg/flickraw-cached-*.gem"
34
101
 
35
- desc "Create a gemspec file"
36
- task :spec do
37
- spec_clone = spec.clone
38
- spec_clone.test_files = nil
39
- open("flickraw.gemspec", "w") {|g| g.puts spec_clone.to_ruby }
102
+ # Update cache and clean gem files
103
+ open(FREEZED_CACHE_FILE, 'w') {|f| remote_list.each {|m| f.puts m} }
104
+ Rake.application[:clobber_package].invoke
105
+ end
40
106
  end
data/test/test.rb CHANGED
@@ -61,6 +61,7 @@ class Basic < Test::Unit::TestCase
61
61
  flickr.people.findByEmail
62
62
  flickr.people.findByUsername
63
63
  flickr.people.getInfo
64
+ flickr.people.getPhotosOf
64
65
  flickr.people.getPublicGroups
65
66
  flickr.people.getPublicPhotos
66
67
  flickr.people.getUploadStatus
@@ -100,6 +101,11 @@ class Basic < Test::Unit::TestCase
100
101
  flickr.photos.notes.add
101
102
  flickr.photos.notes.delete
102
103
  flickr.photos.notes.edit
104
+ flickr.photos.people.add
105
+ flickr.photos.people.delete
106
+ flickr.photos.people.deleteCoords
107
+ flickr.photos.people.editCoords
108
+ flickr.photos.people.getList
103
109
  flickr.photos.recentlyUpdated
104
110
  flickr.photos.removeTag
105
111
  flickr.photos.search
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickraw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mael Clerambault
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-11 00:00:00 +01:00
12
+ date: 2010-05-05 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  version:
66
66
  requirements: []
67
67
 
68
- rubyforge_project: flickraw
68
+ rubyforge_project:
69
69
  rubygems_version: 1.3.5
70
70
  signing_key:
71
71
  specification_version: 3