wideopenspaces-flickry 0.1.2

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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,13 @@
1
+ Flickry
2
+ =======
3
+
4
+ Introduction goes here.
5
+
6
+
7
+ Example
8
+ =======
9
+
10
+ Example goes here.
11
+
12
+
13
+ Copyright (c) 2008 [name of plugin creator], released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the flickry plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the flickry plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'Flickry'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
data/flickry.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "flickry"
3
+ s.version = "0.1.2"
4
+ s.date = "2008-11-16"
5
+ s.summary = "Friendlier interface to flickr API, uses flickraw underneath"
6
+ s.email = "jake@wideopenspac.es"
7
+ s.homepage = "http://github.com/wideopenspaces/flickry"
8
+ s.rubyforge_project = "flickry"
9
+ s.description = "Interface to Flickr API to make working with API responses safer and easier. DO NOT USE ME YET!"
10
+ s.has_rdoc = true
11
+ s.authors = ["Jacob Stetser"]
12
+ s.files = ["MIT-LICENSE",
13
+ "README",
14
+ "Rakefile",
15
+ "flickry.gemspec",
16
+ "init.rb",
17
+ "install.rb",
18
+ "lib/flickry",
19
+ "lib/flickry/base.rb",
20
+ "lib/flickry/location.rb",
21
+ "lib/flickry/person.rb",
22
+ "lib/flickry/photo.rb",
23
+ "lib/flickry/size.rb",
24
+ "lib/flickry/sizes.rb",
25
+ "lib/flickry.rb",
26
+ "lib/super_struct.rb",
27
+ "rails/init.rb",
28
+ "tasks/flickry_tasks.rake",
29
+ "uninstall.rb"]
30
+ s.test_files = ["test/flickry_test.rb",
31
+ "test/test_helper.rb"]
32
+ s.rdoc_options = []
33
+ s.extra_rdoc_files = []
34
+ s.add_dependency("flickraw", [" 0.4.5"])
35
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/rails/init"
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,35 @@
1
+ module Flickry
2
+ class Base < SuperStruct
3
+ def initialize(*args)
4
+ super(*args)
5
+ end
6
+
7
+ protected
8
+
9
+ def extract_attrs_into_substructs!(src, mapping, default = nil)
10
+ mapping.each do |obj, attr_names|
11
+ os = SuperStruct.new
12
+ attr_names.each do |name|
13
+ if src.respond_to?(obj) and sub = src.send(obj)
14
+ os[name] = (sub.respond_to?(name) ? sub.send(name) : default)
15
+ end
16
+ end
17
+ self[obj] = os
18
+ end
19
+ end
20
+
21
+ def extract_attrs!(src, attr_names, default = nil)
22
+ attr_names.each do |name|
23
+ self[name] = (src.respond_to?(name) ? src.send(name) : default)
24
+ end
25
+ end
26
+
27
+ def extract_attrs(src, attr_names, default = nil)
28
+ str = SuperStruct.new
29
+ attr_names.each do |name|
30
+ str[name] = (src.respond_to?(name) ? src.send(name) : default)
31
+ end
32
+ return str
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,8 @@
1
+ module Flickry
2
+ class Location < Flickry::Base
3
+ def initialize(locus)
4
+ super(nil)
5
+ extract_attrs!(locus, [:accuracy, :country, :county, :latitude, :locality, :longitude, :neighbourhood, :place_id, :region, :woeid])
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Flickry
2
+ class Person < Flickry::Base
3
+ def initialize(user)
4
+ super(nil)
5
+ extract_attrs!(user, [:location, :nsid, :realname, :username])
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,51 @@
1
+ module Flickry
2
+ class Photo < Flickry::Base
3
+ def initialize(flickr_id)
4
+ super(nil)
5
+ foto = flickr.photos.getInfo(:photo_id => flickr_id)
6
+ self.photo_id = flickr_id
7
+
8
+ extract_attrs!(foto, [:comments, :dateuploaded, :description, :farm, :id, :isfavorite, :license,
9
+ :media, :notes, :originalformat, :originalsecret, :rotation, :secret, :server, :tags,
10
+ :title, :urls])
11
+ extract_attrs_into_substructs!(foto, {
12
+ :dates => [:lastupdate, :posted, :taken, :takengranularity],
13
+ :editability => [:canaddmeta, :cancomment],
14
+ :geoperms => [:iscontact, :isfamily, :isfriend, :ispublic],
15
+ :usage => [:canblog, :candownload, :canprint],
16
+ :visibility => [:isfamily, :isfriend, :ispublic]
17
+ })
18
+ self.location = Flickry::Location.new(foto.respond_to?(:location) ? foto.location : nil)
19
+ self.owner = Flickry::Person.new(foto.respond_to?(:owner) ? foto.owner : nil)
20
+
21
+ self.sizes = Flickry::Sizes.new(flickr.photos.getSizes(:photo_id => self.photo_id))
22
+ end
23
+
24
+ def visible_to_family?
25
+ self.visibility.isfamily == 1
26
+ end
27
+
28
+ def visible_to_friends?
29
+ self.visibility.isfriend == 1
30
+ end
31
+
32
+ def visible_to_public?
33
+ self.visibility.ispublic == 1
34
+ end
35
+
36
+ def to_flickr_photo
37
+ { :secret => self.secret,
38
+ :originalsecret => self.originalsecret,
39
+ :farm => self.farm,
40
+ :server => self.server,
41
+ :content_type => self.originalformat,
42
+ :content => self.description,
43
+ :created_at => Time.parse(self.dates.taken) }
44
+ end
45
+
46
+ def to_story
47
+ return {:title => self.title, :slug => self.photo_id, :published_at => self.dates.taken }
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ module Flickry
2
+ class Size < Flickry::Base
3
+ def initialize(sz)
4
+ super(nil)
5
+ extract_attrs!(sz, [:height, :width, :media, :source, :url])
6
+ end
7
+
8
+ def to_url
9
+ clean(self.url)
10
+ end
11
+
12
+ def to_source
13
+ clean(self.source)
14
+ end
15
+
16
+ protected
17
+ def clean(text)
18
+ text.gsub(' ','').gsub("\\",'')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ module Flickry
2
+ class Sizes < Flickry::Base
3
+ def initialize(szs)
4
+ super(nil)
5
+ szs.each do |sz|
6
+ self[sz.label.downcase.to_sym] = Flickry::Size.new(sz)
7
+ end
8
+ end
9
+ end
10
+ end
data/lib/flickry.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'flickraw'
2
+ require 'super_struct'
3
+
4
+ require 'flickry/base'
5
+ require 'flickry/location'
6
+ require 'flickry/person'
7
+ require 'flickry/sizes'
8
+ require 'flickry/photo'
9
+
@@ -0,0 +1,31 @@
1
+ require 'ostruct'
2
+ # Code shamelessly stolen from http://errtheblog.com/post/30
3
+ class SuperStruct < OpenStruct
4
+ include Enumerable
5
+
6
+ def members
7
+ methods(false).grep(/=/).map { |m| m[0...-1] }
8
+ end
9
+
10
+ def each
11
+ members.each do |method|
12
+ yield send(method)
13
+ end
14
+ self
15
+ end
16
+
17
+ def each_pair
18
+ members.each do |method|
19
+ yield method, send(method)
20
+ end
21
+ self
22
+ end
23
+
24
+ def [](member)
25
+ send(member)
26
+ end
27
+
28
+ def []=(member, value)
29
+ send("#{member}=", value)
30
+ end
31
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2008 Jacob Stetser
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'flickry'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :flickry do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class FlickryTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wideopenspaces-flickry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Jacob Stetser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-16 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: flickraw
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.4.5
23
+ version:
24
+ description: Interface to Flickr API to make working with API responses safer and easier. DO NOT USE ME YET!
25
+ email: jake@wideopenspac.es
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - MIT-LICENSE
34
+ - README
35
+ - Rakefile
36
+ - flickry.gemspec
37
+ - init.rb
38
+ - install.rb
39
+ - lib/flickry
40
+ - lib/flickry/base.rb
41
+ - lib/flickry/location.rb
42
+ - lib/flickry/person.rb
43
+ - lib/flickry/photo.rb
44
+ - lib/flickry/size.rb
45
+ - lib/flickry/sizes.rb
46
+ - lib/flickry.rb
47
+ - lib/super_struct.rb
48
+ - rails/init.rb
49
+ - tasks/flickry_tasks.rake
50
+ - uninstall.rb
51
+ has_rdoc: true
52
+ homepage: http://github.com/wideopenspaces/flickry
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project: flickry
73
+ rubygems_version: 1.2.0
74
+ signing_key:
75
+ specification_version: 2
76
+ summary: Friendlier interface to flickr API, uses flickraw underneath
77
+ test_files:
78
+ - test/flickry_test.rb
79
+ - test/test_helper.rb