flickrmocks 0.8.5
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/.autotest +36 -0
- data/.document +5 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +76 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +1 -0
- data/flickrmocks.gemspec +155 -0
- data/lib/flickr_mocks/api/api.rb +42 -0
- data/lib/flickr_mocks/api/flickr.rb +27 -0
- data/lib/flickr_mocks/api/helpers.rb +19 -0
- data/lib/flickr_mocks/api/options.rb +55 -0
- data/lib/flickr_mocks/api/sanitize.rb +29 -0
- data/lib/flickr_mocks/fixtures.rb +35 -0
- data/lib/flickr_mocks/flickraw/custom_clone.rb +19 -0
- data/lib/flickr_mocks/flickraw/custom_compare.rb +25 -0
- data/lib/flickr_mocks/flickraw/custom_marshal.rb +39 -0
- data/lib/flickr_mocks/flickraw/flickraw.rb +14 -0
- data/lib/flickr_mocks/helpers.rb +52 -0
- data/lib/flickr_mocks/models/helpers.rb +14 -0
- data/lib/flickr_mocks/models/photo.rb +101 -0
- data/lib/flickr_mocks/models/photo_details.rb +86 -0
- data/lib/flickr_mocks/models/photo_dimensions.rb +103 -0
- data/lib/flickr_mocks/models/photo_search.rb +115 -0
- data/lib/flickr_mocks/models/photo_size.rb +60 -0
- data/lib/flickr_mocks/models/photo_sizes.rb +93 -0
- data/lib/flickr_mocks/models/photos.rb +133 -0
- data/lib/flickr_mocks/stubs.rb +103 -0
- data/lib/flickr_mocks/version.rb +4 -0
- data/lib/flickrmocks.rb +27 -0
- data/spec/api/api_spec.rb +84 -0
- data/spec/api/flickr_spec.rb +48 -0
- data/spec/api/helper_spec.rb +37 -0
- data/spec/api/options_spec.rb +152 -0
- data/spec/api/sanitize_spec.rb +90 -0
- data/spec/base/fixtures_spec.rb +89 -0
- data/spec/base/flickraw/custom_clone_spec.rb +70 -0
- data/spec/base/flickraw/custom_compare_spec.rb +98 -0
- data/spec/base/flickraw/custom_marshal_spec.rb +45 -0
- data/spec/base/helpers_spec.rb +63 -0
- data/spec/base/stubs_spec.rb +180 -0
- data/spec/base/version_spec.rb +15 -0
- data/spec/fixtures/author_photos.marshal +0 -0
- data/spec/fixtures/empty_photos.marshal +0 -0
- data/spec/fixtures/expected_methods.marshal +17 -0
- data/spec/fixtures/interesting_photos.marshal +0 -0
- data/spec/fixtures/photo.marshal +0 -0
- data/spec/fixtures/photo_details.marshal +0 -0
- data/spec/fixtures/photo_size.marshal +0 -0
- data/spec/fixtures/photo_sizes.marshal +0 -0
- data/spec/fixtures/photos.marshal +0 -0
- data/spec/models/helpers_spec.rb +25 -0
- data/spec/models/photo_details_spec.rb +224 -0
- data/spec/models/photo_dimensions_spec.rb +208 -0
- data/spec/models/photo_search_spec.rb +255 -0
- data/spec/models/photo_size_spec.rb +122 -0
- data/spec/models/photo_sizes_spec.rb +168 -0
- data/spec/models/photo_spec.rb +278 -0
- data/spec/models/photos_spec.rb +305 -0
- data/spec/shared_examples/array_accessor.rb +157 -0
- data/spec/shared_examples/collection.rb +49 -0
- data/spec/shared_examples/image_url_helpers.rb +56 -0
- data/spec/shared_examples/size_accessor.rb +13 -0
- data/spec/spec_helper.rb +24 -0
- data/tasks/fixtures.rb +164 -0
- metadata +259 -0
data/.autotest
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Example taken from: http://blog.davidchelimsky.net/category/autotest/
|
2
|
+
# January 15th, 2008 entry
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.add_mapping(%r%^plugins/acts_as_currency/lib/.*\.rb$%) {
|
7
|
+
# at.files_matching %r%^spec/models/product_spec\.rb$% +
|
8
|
+
# at.files_matching %r%^plugins/acts_as_currency/spec/.*_spec\.rb$%
|
9
|
+
# }
|
10
|
+
#end
|
11
|
+
#
|
12
|
+
# add_mapping: adds key/value pair to a hash that maps regexps to procs.
|
13
|
+
#
|
14
|
+
# Whenever autotest detects a file has changed it looks for a regexp that
|
15
|
+
# matches that file and runs ALL the files associated with the matching
|
16
|
+
# regular expression.
|
17
|
+
#
|
18
|
+
# In the example below any change to the plugins file directory will
|
19
|
+
# trigger all the specs in the plugin directory to run as well
|
20
|
+
# as the spec for the product model.
|
21
|
+
|
22
|
+
require 'autotest/timestamp'
|
23
|
+
require 'autotest/restart'
|
24
|
+
|
25
|
+
require 'test_notifier/runner/autotest'
|
26
|
+
|
27
|
+
Autotest.add_hook(:initialize) do |at|
|
28
|
+
%w{.git .svn .hg tmp log doc .DS_Store ._* vendor nbproject}.each { |exception| autotest.add_exception(exception) }
|
29
|
+
|
30
|
+
at.clear_mappings # take out the default (test/test*rb)
|
31
|
+
|
32
|
+
at.add_mappings %r%^lib/% do
|
33
|
+
at.files_matching %r%^spec/*/*_spec.rb%
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2004-2010 David Heinemeier Hansson
|
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.rdoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
== Welcome to FlickrMocks
|
2
|
+
|
3
|
+
FlickrMocks makes it possible to Marshal responses generated from the FLickRaw
|
4
|
+
gem. This is useful for Mocking/Stubbing the Flickr interface for testing
|
5
|
+
purposes.
|
6
|
+
|
7
|
+
The FlickRaw::Response and FlickRaw::ResponseList objects can not be Marshaled
|
8
|
+
because they contain singleton's.
|
9
|
+
|
10
|
+
== Getting Started
|
11
|
+
|
12
|
+
1. Install flickrmocks:
|
13
|
+
<tt>gem install flickrmocks</tt>
|
14
|
+
|
15
|
+
2. require 'flickrmocks'
|
16
|
+
|
17
|
+
3. You should be able to Marshal/Unmarshal FlickRaw::Response and FlickRaw::ResponseList
|
18
|
+
classes.
|
19
|
+
|
20
|
+
FlickRaw.api_key = 'xxx your flickr api key goes here'
|
21
|
+
a = flickr.photos.search :tags => 'dog'
|
22
|
+
b = Marshal.dump(a)
|
23
|
+
|
24
|
+
Marshal.load(b)
|
25
|
+
|
26
|
+
== Rails Installation (Test::Unit)
|
27
|
+
|
28
|
+
Specify the gem dependency in your config/environment.rb file:
|
29
|
+
|
30
|
+
Rails::Initializer.run do |config|
|
31
|
+
config.gem "flickrmocks", :lib => "flickrmocks"
|
32
|
+
end
|
33
|
+
|
34
|
+
Then:
|
35
|
+
|
36
|
+
$ rake gems:install
|
37
|
+
$ rake gems:unpack
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
== Note on Patches/Pull Requests
|
42
|
+
|
43
|
+
* Fork the project.
|
44
|
+
* Make your feature addition or bug fix.
|
45
|
+
* Add tests for it. This is important so I don't break it in a
|
46
|
+
future version unintentionally.
|
47
|
+
* Commit, do not mess with rakefile, version, or history.
|
48
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
49
|
+
* Send me a pull request. Bonus points for topic branches.
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
== License
|
54
|
+
|
55
|
+
FlickrMocks is released under the MIT license.
|
56
|
+
|
57
|
+
== Copyright
|
58
|
+
|
59
|
+
Copyright (c) 2010 Takaltoo.
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/flickrmocks')
|
4
|
+
|
5
|
+
# include all tasks
|
6
|
+
Dir.glob("tasks/*.rb").each do |file|
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + "/#{file}")
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
gem.name = "flickrmocks"
|
15
|
+
gem.summary = %Q{Enables FlickRaw responses to be Marshaled.}
|
16
|
+
gem.description = %Q{FlickrMocks makes it possible to Marshal responses
|
17
|
+
generated from the FLickRaw gem. This is useful for
|
18
|
+
Mocking/Stubbing the Flickr interface for testing purposes.
|
19
|
+
The FlickRaw::Response and FlickRaw::ResponseList objects can
|
20
|
+
not be Marshaled because they contain singleton's.}
|
21
|
+
gem.email = "pouya@lavabit.com"
|
22
|
+
gem.homepage = "http://github.com/takaltoo/flickrmocks"
|
23
|
+
gem.authors = ["Takaltoo"]
|
24
|
+
|
25
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 2.10"
|
26
|
+
gem.add_development_dependency "rspec", ">=2.0.0.beta.22"
|
27
|
+
gem.add_development_dependency "capybara"
|
28
|
+
#gem.add_development_dependency 'ruby-debug19', :require => 'ruby-debug'
|
29
|
+
gem.add_development_dependency 'factory_girl_rails', ">=1.0"
|
30
|
+
gem.add_development_dependency 'faker','>=0.3.1'
|
31
|
+
|
32
|
+
gem.add_dependency "flickraw", ">=0.8.2"
|
33
|
+
gem.add_dependency 'chronic'
|
34
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
35
|
+
end
|
36
|
+
Jeweler::GemcutterTasks.new
|
37
|
+
rescue LoadError
|
38
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
39
|
+
end
|
40
|
+
|
41
|
+
require 'rake/testtask'
|
42
|
+
Rake::TestTask.new(:test) do |test|
|
43
|
+
test.libs << 'lib' << 'test'
|
44
|
+
test.pattern = 'test/**/test_*.rb'
|
45
|
+
test.verbose = true
|
46
|
+
end
|
47
|
+
|
48
|
+
begin
|
49
|
+
require 'rcov/rcovtask'
|
50
|
+
Rcov::RcovTask.new do |test|
|
51
|
+
test.libs << 'test'
|
52
|
+
test.pattern = 'test/**/test_*.rb'
|
53
|
+
test.verbose = true
|
54
|
+
end
|
55
|
+
rescue LoadError
|
56
|
+
task :rcov do
|
57
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
task :test => :check_dependencies
|
62
|
+
|
63
|
+
task :default => :test
|
64
|
+
|
65
|
+
require 'rake/rdoctask'
|
66
|
+
Rake::RDocTask.new do |rdoc|
|
67
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
68
|
+
|
69
|
+
rdoc.rdoc_dir = 'rdoc'
|
70
|
+
rdoc.title = "flickrmocks #{version}"
|
71
|
+
rdoc.rdoc_files.include('README*')
|
72
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.8.5
|
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" }
|
data/flickrmocks.gemspec
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{flickrmocks}
|
8
|
+
s.version = "0.8.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Takaltoo"]
|
12
|
+
s.date = %q{2010-11-08}
|
13
|
+
s.description = %q{FlickrMocks makes it possible to Marshal responses
|
14
|
+
generated from the FLickRaw gem. This is useful for
|
15
|
+
Mocking/Stubbing the Flickr interface for testing purposes.
|
16
|
+
The FlickRaw::Response and FlickRaw::ResponseList objects can
|
17
|
+
not be Marshaled because they contain singleton's.}
|
18
|
+
s.email = %q{pouya@lavabit.com}
|
19
|
+
s.extra_rdoc_files = [
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".autotest",
|
24
|
+
".document",
|
25
|
+
".gitignore",
|
26
|
+
".rspec",
|
27
|
+
"MIT-LICENSE",
|
28
|
+
"README.rdoc",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"autotest/discover.rb",
|
32
|
+
"flickrmocks.gemspec",
|
33
|
+
"lib/flickr_mocks/api/api.rb",
|
34
|
+
"lib/flickr_mocks/api/flickr.rb",
|
35
|
+
"lib/flickr_mocks/api/helpers.rb",
|
36
|
+
"lib/flickr_mocks/api/options.rb",
|
37
|
+
"lib/flickr_mocks/api/sanitize.rb",
|
38
|
+
"lib/flickr_mocks/fixtures.rb",
|
39
|
+
"lib/flickr_mocks/flickraw/custom_clone.rb",
|
40
|
+
"lib/flickr_mocks/flickraw/custom_compare.rb",
|
41
|
+
"lib/flickr_mocks/flickraw/custom_marshal.rb",
|
42
|
+
"lib/flickr_mocks/flickraw/flickraw.rb",
|
43
|
+
"lib/flickr_mocks/helpers.rb",
|
44
|
+
"lib/flickr_mocks/models/helpers.rb",
|
45
|
+
"lib/flickr_mocks/models/photo.rb",
|
46
|
+
"lib/flickr_mocks/models/photo_details.rb",
|
47
|
+
"lib/flickr_mocks/models/photo_dimensions.rb",
|
48
|
+
"lib/flickr_mocks/models/photo_search.rb",
|
49
|
+
"lib/flickr_mocks/models/photo_size.rb",
|
50
|
+
"lib/flickr_mocks/models/photo_sizes.rb",
|
51
|
+
"lib/flickr_mocks/models/photos.rb",
|
52
|
+
"lib/flickr_mocks/stubs.rb",
|
53
|
+
"lib/flickr_mocks/version.rb",
|
54
|
+
"lib/flickrmocks.rb",
|
55
|
+
"spec/api/api_spec.rb",
|
56
|
+
"spec/api/flickr_spec.rb",
|
57
|
+
"spec/api/helper_spec.rb",
|
58
|
+
"spec/api/options_spec.rb",
|
59
|
+
"spec/api/sanitize_spec.rb",
|
60
|
+
"spec/base/fixtures_spec.rb",
|
61
|
+
"spec/base/flickraw/custom_clone_spec.rb",
|
62
|
+
"spec/base/flickraw/custom_compare_spec.rb",
|
63
|
+
"spec/base/flickraw/custom_marshal_spec.rb",
|
64
|
+
"spec/base/helpers_spec.rb",
|
65
|
+
"spec/base/stubs_spec.rb",
|
66
|
+
"spec/base/version_spec.rb",
|
67
|
+
"spec/fixtures/author_photos.marshal",
|
68
|
+
"spec/fixtures/empty_photos.marshal",
|
69
|
+
"spec/fixtures/expected_methods.marshal",
|
70
|
+
"spec/fixtures/interesting_photos.marshal",
|
71
|
+
"spec/fixtures/photo.marshal",
|
72
|
+
"spec/fixtures/photo_details.marshal",
|
73
|
+
"spec/fixtures/photo_size.marshal",
|
74
|
+
"spec/fixtures/photo_sizes.marshal",
|
75
|
+
"spec/fixtures/photos.marshal",
|
76
|
+
"spec/models/helpers_spec.rb",
|
77
|
+
"spec/models/photo_details_spec.rb",
|
78
|
+
"spec/models/photo_dimensions_spec.rb",
|
79
|
+
"spec/models/photo_search_spec.rb",
|
80
|
+
"spec/models/photo_size_spec.rb",
|
81
|
+
"spec/models/photo_sizes_spec.rb",
|
82
|
+
"spec/models/photo_spec.rb",
|
83
|
+
"spec/models/photos_spec.rb",
|
84
|
+
"spec/shared_examples/array_accessor.rb",
|
85
|
+
"spec/shared_examples/collection.rb",
|
86
|
+
"spec/shared_examples/image_url_helpers.rb",
|
87
|
+
"spec/shared_examples/size_accessor.rb",
|
88
|
+
"spec/spec_helper.rb",
|
89
|
+
"tasks/fixtures.rb"
|
90
|
+
]
|
91
|
+
s.homepage = %q{http://github.com/takaltoo/flickrmocks}
|
92
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
93
|
+
s.require_paths = ["lib"]
|
94
|
+
s.rubygems_version = %q{1.3.7}
|
95
|
+
s.summary = %q{Enables FlickRaw responses to be Marshaled.}
|
96
|
+
s.test_files = [
|
97
|
+
"spec/shared_examples/array_accessor.rb",
|
98
|
+
"spec/shared_examples/size_accessor.rb",
|
99
|
+
"spec/shared_examples/collection.rb",
|
100
|
+
"spec/shared_examples/image_url_helpers.rb",
|
101
|
+
"spec/models/helpers_spec.rb",
|
102
|
+
"spec/models/photo_details_spec.rb",
|
103
|
+
"spec/models/photo_size_spec.rb",
|
104
|
+
"spec/models/photo_sizes_spec.rb",
|
105
|
+
"spec/models/photos_spec.rb",
|
106
|
+
"spec/models/photo_dimensions_spec.rb",
|
107
|
+
"spec/models/photo_spec.rb",
|
108
|
+
"spec/models/photo_search_spec.rb",
|
109
|
+
"spec/api/api_spec.rb",
|
110
|
+
"spec/api/flickr_spec.rb",
|
111
|
+
"spec/api/options_spec.rb",
|
112
|
+
"spec/api/sanitize_spec.rb",
|
113
|
+
"spec/api/helper_spec.rb",
|
114
|
+
"spec/base/stubs_spec.rb",
|
115
|
+
"spec/base/helpers_spec.rb",
|
116
|
+
"spec/base/version_spec.rb",
|
117
|
+
"spec/base/flickraw/custom_clone_spec.rb",
|
118
|
+
"spec/base/flickraw/custom_compare_spec.rb",
|
119
|
+
"spec/base/flickraw/custom_marshal_spec.rb",
|
120
|
+
"spec/base/fixtures_spec.rb",
|
121
|
+
"spec/spec_helper.rb"
|
122
|
+
]
|
123
|
+
|
124
|
+
if s.respond_to? :specification_version then
|
125
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
126
|
+
s.specification_version = 3
|
127
|
+
|
128
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
129
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 2.10"])
|
130
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
|
131
|
+
s.add_development_dependency(%q<capybara>, [">= 0"])
|
132
|
+
s.add_development_dependency(%q<factory_girl_rails>, [">= 1.0"])
|
133
|
+
s.add_development_dependency(%q<faker>, [">= 0.3.1"])
|
134
|
+
s.add_runtime_dependency(%q<flickraw>, [">= 0.8.2"])
|
135
|
+
s.add_runtime_dependency(%q<chronic>, [">= 0"])
|
136
|
+
else
|
137
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 2.10"])
|
138
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
|
139
|
+
s.add_dependency(%q<capybara>, [">= 0"])
|
140
|
+
s.add_dependency(%q<factory_girl_rails>, [">= 1.0"])
|
141
|
+
s.add_dependency(%q<faker>, [">= 0.3.1"])
|
142
|
+
s.add_dependency(%q<flickraw>, [">= 0.8.2"])
|
143
|
+
s.add_dependency(%q<chronic>, [">= 0"])
|
144
|
+
end
|
145
|
+
else
|
146
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 2.10"])
|
147
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
|
148
|
+
s.add_dependency(%q<capybara>, [">= 0"])
|
149
|
+
s.add_dependency(%q<factory_girl_rails>, [">= 1.0"])
|
150
|
+
s.add_dependency(%q<faker>, [">= 0.3.1"])
|
151
|
+
s.add_dependency(%q<flickraw>, [">= 0.8.2"])
|
152
|
+
s.add_dependency(%q<chronic>, [">= 0"])
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module FlickrMocks
|
2
|
+
|
3
|
+
class Api
|
4
|
+
@defaults = {
|
5
|
+
:per_page => '200',
|
6
|
+
:license => '4,5,6,7',
|
7
|
+
:media => 'photos',
|
8
|
+
:extras => 'license',
|
9
|
+
:tag_mode => 'any',
|
10
|
+
:flickr_tag_modes => ['any','all']
|
11
|
+
}
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_accessor :defaults
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.photos(params)
|
18
|
+
photos = Api.flickr_photos(params)
|
19
|
+
PhotoSearch.new photos,Api.search_params(params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.photo_details(params)
|
23
|
+
photo = Api.flickr_photo(params)
|
24
|
+
sizes = Api.flickr_photo_sizes(params)
|
25
|
+
@this = @photo = PhotoDetails.new(photo,sizes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.photo(params)
|
29
|
+
Photo.new Api.flickr_photo(params)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.photo_sizes(params)
|
33
|
+
PhotoSizes.new Api.flickr_photo_sizes(params)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.interesting_photos(params)
|
37
|
+
photos = Api.flickr_interestingness(params)
|
38
|
+
PhotoSearch.new photos,Api.interesting_params(params)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module FlickrMocks
|
2
|
+
|
3
|
+
class Api
|
4
|
+
# Not required for testing, simple wrappers for flickr* methods
|
5
|
+
def self.flickr_photos(params)
|
6
|
+
flickr.photos.search self.search_options(params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.flickr_photo(params)
|
10
|
+
flickr.photos.getInfo self.photo_options(params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.flickr_photo_sizes(params)
|
14
|
+
flickr.photos.getSizes self.photo_options(params)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.flickr_interestingness(params)
|
18
|
+
flickr.interestingness.getList self.interesting_options(params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.flickr_author(params)
|
22
|
+
flickr.photos.search self.author_options(params)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FlickrMocks
|
2
|
+
class Api
|
3
|
+
# default control values
|
4
|
+
def self.default(value)
|
5
|
+
Api.defaults[value.to_sym]
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.time(date=nil)
|
9
|
+
begin
|
10
|
+
date = Chronic.parse(date).strftime('%Y-%m-%d')
|
11
|
+
date ? date : Chronic.parse('yesterday').strftime('%Y-%m-%d')
|
12
|
+
rescue
|
13
|
+
Chronic.parse('yesterday').strftime('%Y-%m-%d')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module FlickrMocks
|
2
|
+
class Api
|
3
|
+
def self.search_options(params)
|
4
|
+
return {
|
5
|
+
:tags => self.sanitize_tags(params[:search_terms]),
|
6
|
+
:user_id => params[:owner_id],
|
7
|
+
:per_page => self.sanitize_per_page(params),
|
8
|
+
:page => self.sanitize_page(params),
|
9
|
+
:license => self.default(:license),
|
10
|
+
:media => self.default(:media),
|
11
|
+
:extras => self.default(:extras),
|
12
|
+
:tag_mode => self.sanitize_tag_mode(params)
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.interesting_options(params)
|
17
|
+
return {
|
18
|
+
:date => self.sanitize_time(params),
|
19
|
+
:per_page => self.sanitize_per_page(params),
|
20
|
+
:page => self.sanitize_page(params),
|
21
|
+
:extras => self.default(:extras)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.photo_options(params)
|
26
|
+
{
|
27
|
+
:photo_id => params[:photo_id] || params[:id] || nil,
|
28
|
+
:secret => params[:photo_secret] || params[:secret] || nil
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.author_options(params)
|
33
|
+
options = self.search_options(params)
|
34
|
+
options.delete :tags
|
35
|
+
options
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.search_params(params)
|
39
|
+
return {
|
40
|
+
:search_terms => self.sanitize_tags(params[:search_terms]),
|
41
|
+
:owner_id => self.sanitize_tags(params[:owner_id]),
|
42
|
+
:base_url => params[:base_url]
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.interesting_params(params)
|
47
|
+
return {
|
48
|
+
:date => params[:date],
|
49
|
+
:base_url => params[:base_url]
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module FlickrMocks
|
2
|
+
class Api
|
3
|
+
def self.sanitize_tags(value=nil)
|
4
|
+
value.nil? ? value : value.downcase.split(',').map.each do |v| v.strip end.join(',')
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.sanitize_per_page(params={})
|
8
|
+
params[:per_page] || params[:perpage] || self.default(:per_page)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.sanitize_page(params={})
|
12
|
+
[nil,0,'0'].include?(params[:page]) ? '1' : params[:page].to_i.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.sanitize_tag_mode(params={})
|
16
|
+
self.default(:flickr_tag_modes).include?(params[:tag_mode].to_s.downcase.strip) ?
|
17
|
+
params[:tag_mode].to_s.downcase.strip : self.default(:tag_mode)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.sanitize_time(params={})
|
21
|
+
date = params[:date]
|
22
|
+
case date
|
23
|
+
when Time then date.strftime('%Y-%m-%d')
|
24
|
+
when String then self.time(date)
|
25
|
+
else self.time('yesterday')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module FlickrMocks
|
4
|
+
class Fixtures
|
5
|
+
attr_accessor :photos,:interesting_photos,:author_photos,:photo,:photo_details,
|
6
|
+
:photo_sizes,:photo_size,:expected_methods,:empty_photos
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@photos = load_fixture(:photos)
|
10
|
+
@interesting_photos = load_fixture(:interesting_photos)
|
11
|
+
@author_photos = load_fixture(:author_photos)
|
12
|
+
|
13
|
+
@photo = load_fixture(:photo)
|
14
|
+
@photo_details= load_fixture(:photo_details)
|
15
|
+
|
16
|
+
@photo_sizes = load_fixture(:photo_sizes)
|
17
|
+
@photo_size = load_fixture(:photo_size)
|
18
|
+
|
19
|
+
@empty_photos = load_fixture(:empty_photos)
|
20
|
+
|
21
|
+
@expected_methods = load_fixture(:expected_methods)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.repository
|
25
|
+
File.expand_path(File.dirname(__FILE__) + '/../../spec/fixtures') + '/'
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def load_fixture(file)
|
30
|
+
fname = Fixtures.repository + file.to_s + '.marshal'
|
31
|
+
FlickrMocks::Helpers.load fname
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FlickrMocks
|
2
|
+
|
3
|
+
module CustomClone
|
4
|
+
|
5
|
+
def initialize_copy(orig)
|
6
|
+
super
|
7
|
+
cloned = @h.clone
|
8
|
+
@h = cloned.each_pair do |key,value|
|
9
|
+
case value
|
10
|
+
when Fixnum then next
|
11
|
+
when String then cloned[key] = value.clone
|
12
|
+
when Array then cloned[key] = value.clone.map do |elem| elem.clone end
|
13
|
+
when FlickRaw::Response then cloned[key] = value.clone
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FlickrMocks
|
2
|
+
|
3
|
+
module CustomCompare
|
4
|
+
def ==(other)
|
5
|
+
return false if other.nil?
|
6
|
+
return false unless other.is_a?(self.class)
|
7
|
+
case other
|
8
|
+
when FlickRaw::Response then compare_response(other)
|
9
|
+
else self == other
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def compare_response(other)
|
15
|
+
self.methods(false).map do |method|
|
16
|
+
return false unless other.respond_to?(method)
|
17
|
+
self.send(method) == other.send(method)
|
18
|
+
end.inject(true) do |previous,current|
|
19
|
+
previous && current
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|