Module: Squarepusher
- Defined in:
- lib/squarepusher/core.rb,
lib/squarepusher/cli.rb,
lib/squarepusher/version.rb
Overview
TODO: keep track of failures
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.0.8"
Class Method Summary collapse
- .describe_photoset(pset) ⇒ Object
- .normalize(name) ⇒ Object
- .owner_page_url(p) ⇒ Object
- .photo_page_url(p) ⇒ Object
- .sizes ⇒ Object
- .url_for(photo, size) ⇒ Object
Class Method Details
.describe_photoset(pset) ⇒ Object
19 20 21 |
# File 'lib/squarepusher/core.rb', line 19 def describe_photoset(pset) "#{pset.id} '#{pset.title}'" end |
.normalize(name) ⇒ Object
23 24 25 |
# File 'lib/squarepusher/core.rb', line 23 def normalize(name) name.gsub(/[^a-zA-Z0-9_+\.=-]+/, '-') end |
.owner_page_url(p) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/squarepusher/core.rb', line 27 def owner_page_url(p) # TODO: maybe abstract this to allow ownername to be passed in as a parameter if p.respond_to?(:owner) owner = p.owner if owner.respond_to?(:username) ownername = p.owner.username else ownername = owner end elsif p.respond_to?(:ownername) # I want to remove this since the ownername is the human readable form and not the owner id, # so isn't always safe to build a URL with. but for photoset.getList the only way to get the owner name # is by specifying the extra "owner_name" - need to find a way to get the owner id ownername = p.ownername else raise Exception.new("photo does not contain 'owner' attribute: #{p.inspect}") end "http://flickr.com/photos/#{ownername}" end |
.photo_page_url(p) ⇒ Object
48 49 50 51 |
# File 'lib/squarepusher/core.rb', line 48 def photo_page_url(p) owner_page_url = Squarepusher::owner_page_url(p) "#{owner_page_url}/#{p.id}" end |
.sizes ⇒ Object
53 54 55 |
# File 'lib/squarepusher/core.rb', line 53 def sizes return [:original, :large, :medium_640, :medium_500, :small, :thumb, :small_square] end |
.url_for(photo, size) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/squarepusher/core.rb', line 57 def url_for(photo, size) case size when :original FlickRaw.url_o(photo) when :large FlickRaw.url_b(photo) when :medium_640 FlickRaw.url_z(photo) when :medium_500 FlickRaw.url(photo) when :small FlickRaw.url_m(photo) when :thumb FlickRaw.url_t(photo) when :small_square FlickRaw.url_s(photo) end end |