paperclip_montage 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +4 -0
- data/.travis.yml +55 -0
- data/Gemfile +38 -0
- data/Guardfile +14 -0
- data/LICENSE +674 -0
- data/README.md +67 -0
- data/Rakefile +50 -0
- data/config/Guardfile +14 -0
- data/lib/generators/paperclip_montage/USAGE +8 -0
- data/lib/generators/paperclip_montage/paperclip_montage_generator.rb +3 -0
- data/lib/paperclip/montage.rb +94 -0
- data/lib/paperclip/myversion.rb +11 -0
- data/lib/paperclip_montage.rb +5 -0
- data/paperclip_montage.gemspec +154 -0
- data/spec/fixtures/valid.jpg +0 -0
- data/spec/fixtures/valid1.png +0 -0
- data/spec/fixtures/valid2.png +0 -0
- data/spec/fixtures/valid3.png +0 -0
- data/spec/fixtures/valid4.png +0 -0
- data/spec/paperclip/montage_spec.rb +56 -0
- data/spec/rails-app/.gitignore +17 -0
- data/spec/rails-app/.rspec +2 -0
- data/spec/rails-app/Gemfile +32 -0
- data/spec/rails-app/Guardfile +76 -0
- data/spec/rails-app/README.rdoc +28 -0
- data/spec/rails-app/Rakefile +6 -0
- data/spec/rails-app/app/assets/images/.keep +0 -0
- data/spec/rails-app/app/assets/javascripts/application.js +16 -0
- data/spec/rails-app/app/assets/stylesheets/application.css +15 -0
- data/spec/rails-app/app/controllers/application_controller.rb +5 -0
- data/spec/rails-app/app/controllers/concerns/.keep +0 -0
- data/spec/rails-app/app/helpers/application_helper.rb +2 -0
- data/spec/rails-app/app/models/.keep +0 -0
- data/spec/rails-app/app/models/avatar.rb +5 -0
- data/spec/rails-app/app/models/avatars_meta.rb +4 -0
- data/spec/rails-app/app/models/concerns/.keep +0 -0
- data/spec/rails-app/app/models/meta.rb +16 -0
- data/spec/rails-app/app/views/layouts/application.html.erb +14 -0
- data/spec/rails-app/bin/bundle +3 -0
- data/spec/rails-app/bin/rails +8 -0
- data/spec/rails-app/bin/rake +8 -0
- data/spec/rails-app/bin/spring +18 -0
- data/spec/rails-app/config.ru +4 -0
- data/spec/rails-app/config/Guardfile +76 -0
- data/spec/rails-app/config/application.rb +23 -0
- data/spec/rails-app/config/boot.rb +4 -0
- data/spec/rails-app/config/database.yml +25 -0
- data/spec/rails-app/config/environment.rb +5 -0
- data/spec/rails-app/config/environments/development.rb +37 -0
- data/spec/rails-app/config/environments/production.rb +78 -0
- data/spec/rails-app/config/environments/test.rb +39 -0
- data/spec/rails-app/config/initializers/assets.rb +8 -0
- data/spec/rails-app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails-app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/rails-app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/rails-app/config/initializers/inflections.rb +16 -0
- data/spec/rails-app/config/initializers/mime_types.rb +4 -0
- data/spec/rails-app/config/initializers/session_store.rb +3 -0
- data/spec/rails-app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails-app/config/locales/en.yml +23 -0
- data/spec/rails-app/config/routes.rb +56 -0
- data/spec/rails-app/config/secrets.yml +22 -0
- data/spec/rails-app/db/migrate/20141212000615_create_avatars.rb +9 -0
- data/spec/rails-app/db/migrate/20141212000731_create_meta.rb +9 -0
- data/spec/rails-app/db/migrate/20141214193102_create_avatars_meta.rb +10 -0
- data/spec/rails-app/db/schema.rb +44 -0
- data/spec/rails-app/db/seeds.rb +7 -0
- data/spec/rails-app/public/404.html +67 -0
- data/spec/rails-app/public/422.html +67 -0
- data/spec/rails-app/public/500.html +66 -0
- data/spec/rails-app/public/favicon.ico +0 -0
- data/spec/rails-app/public/robots.txt +5 -0
- data/spec/rails-app/spec/models/avatar_spec.rb +9 -0
- data/spec/rails-app/spec/models/avatars_meta_spec.rb +5 -0
- data/spec/rails-app/spec/models/meta_spec.rb +48 -0
- data/spec/rails-app/spec/rails_helper.rb +50 -0
- data/spec/rails-app/spec/spec_helper.rb +12 -0
- data/spec/spec_helper.rb +112 -0
- metadata +306 -0
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
Paperclip Montage
|
3
|
+
=================
|
4
|
+
|
5
|
+
Paperclip Montages aim is to make it easier to create Paperclip avatars for meta models. It is a wrapper for ImageMagick's `montage` tool.
|
6
|
+
|
7
|
+
This was build for [Oplerno](http://www.oplerno.com/)'s online education platform for combining course avatars so they can be displayed as certificate avatars.
|
8
|
+
|
9
|
+
[![Build Status](https://travis-ci.org/webhat/paperclip_montage.svg)](https://travis-ci.org/webhat/paperclip_montage)
|
10
|
+
|
11
|
+
Installation
|
12
|
+
============
|
13
|
+
|
14
|
+
```
|
15
|
+
gem 'paperclip_montage'
|
16
|
+
```
|
17
|
+
|
18
|
+
```
|
19
|
+
gem install paperclip_montage
|
20
|
+
```
|
21
|
+
|
22
|
+
Example
|
23
|
+
=======
|
24
|
+
|
25
|
+
This is a simple example in which `Meta` creates a combined avatar.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
class Avatar < ActiveRecord::Base
|
29
|
+
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
|
30
|
+
|
31
|
+
has_and_belongs_to_many :metas
|
32
|
+
|
33
|
+
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
class Meta < ActiveRecord::Base
|
39
|
+
#after_update :reprocess_montage
|
40
|
+
|
41
|
+
has_and_belongs_to_many :avatars
|
42
|
+
|
43
|
+
has_attached_file :montage,
|
44
|
+
processors: [:montage],
|
45
|
+
:styles => { medium: { geometry: "300x300>", source: :avatars} , thumb: { geometry: "100x100>" } }
|
46
|
+
|
47
|
+
validates_attachment :montage, :attachment_presence => true,
|
48
|
+
:content_type => { :content_type => "image/jpeg" }
|
49
|
+
|
50
|
+
def reprocess_montage
|
51
|
+
montage.reprocess!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
After any changes to the icon for an `Avatar` the method `reprocess_montage` must be called on the `Meta` object.
|
57
|
+
|
58
|
+
|
59
|
+
Acknowledgements
|
60
|
+
================
|
61
|
+
Test image by Matthias Georg - https://www.flickr.com/photos/114805503@N05/15811868778/
|
62
|
+
|
63
|
+
Help from these sources:
|
64
|
+
* https://github.com/janfoeh/paperclip-optimizer
|
65
|
+
* https://github.com/thoughtbot/paperclip
|
66
|
+
* https://gist.github.com/laurynas/708077
|
67
|
+
* http://matthewhutchinson.net/2010/10/25/editing-file-uploads-with-a-paperclip-processor
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
require './lib/paperclip/myversion.rb'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
gem.name = "paperclip_montage"
|
18
|
+
gem.homepage = "http://github.com/webhat/paperclip_montage"
|
19
|
+
gem.license = "LGPLv2"
|
20
|
+
gem.summary = "Paperclip Montage"
|
21
|
+
gem.description = "This module stores the image files in Redis"
|
22
|
+
gem.authors = ["Daniel W. Crompton"]
|
23
|
+
gem.email = ['paperclip+montage@specialbrands.net']
|
24
|
+
gem.version = Paperclip::Version::STRING
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/{models,paperclip}/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Code coverage detail"
|
35
|
+
task :simplecov do
|
36
|
+
ENV['COVERAGE'] = "true"
|
37
|
+
Rake::Task['spec'].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "paperclip_montage #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/config/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
3
|
+
watch(%r{^spec/.+_spec\.rb$})
|
4
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
+
watch('spec/spec_helper.rb') { "spec" }
|
6
|
+
watch ("config/Guardfile") { UI.info "Exiting guard because config changed"; exit 0 }
|
7
|
+
|
8
|
+
# Ignore
|
9
|
+
ignore %r{^spec/rails-app/}
|
10
|
+
end
|
11
|
+
|
12
|
+
guard 'yard' do
|
13
|
+
watch(%r{lib/.+\.rb})
|
14
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Using https://gist.github.com/laurynas/708077 as a guide
|
2
|
+
module Paperclip
|
3
|
+
class Montage < Processor
|
4
|
+
attr_accessor :whiny
|
5
|
+
|
6
|
+
def initialize file, options = {}, attachment = nil
|
7
|
+
super
|
8
|
+
@file = file
|
9
|
+
@format = options[:format]
|
10
|
+
@source = options[:source]
|
11
|
+
setup_montage_sources @source
|
12
|
+
setup_geometry options[:geometry]
|
13
|
+
@current_format = File.extname(@file.path)
|
14
|
+
@basename = File.basename(@file.path, @current_format)
|
15
|
+
@whiny = options[:whiny].nil? ? true : options[:whiny]
|
16
|
+
@attachment = attachment
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_geometry geometry
|
20
|
+
@height, @width = '100', '100'
|
21
|
+
@height, @width = geometry.split('x') unless geometry.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
def setup_montage_sources source
|
25
|
+
source_instance_vars
|
26
|
+
|
27
|
+
if source.is_a?(Symbol)
|
28
|
+
return if @attachment.instance.nil?
|
29
|
+
source = @attachment.instance.send(source).map { |f| File.open(f.avatar.path( :original )) }
|
30
|
+
end
|
31
|
+
|
32
|
+
return if source.nil? || source.empty?
|
33
|
+
|
34
|
+
source_instance_vars source, source.length
|
35
|
+
end
|
36
|
+
|
37
|
+
def source_instance_vars files = nil, imgs = 4
|
38
|
+
@files = files
|
39
|
+
@num_of_imgs = imgs
|
40
|
+
end
|
41
|
+
|
42
|
+
def make
|
43
|
+
command = 'montage'
|
44
|
+
|
45
|
+
dst = Tempfile.new([@basename, @format].compact.join("."))
|
46
|
+
dst.binmode
|
47
|
+
|
48
|
+
# -title 'Certificate'
|
49
|
+
args = "-background '#ffffff' -geometry #{height}x#{width}+#{grid} #{input_files_text} #{output_file dst}"
|
50
|
+
|
51
|
+
Paperclip.run(command, args)
|
52
|
+
|
53
|
+
dst
|
54
|
+
end
|
55
|
+
|
56
|
+
def width
|
57
|
+
@width.gsub(/[^0-9]/,'').to_i/side
|
58
|
+
end
|
59
|
+
|
60
|
+
def height
|
61
|
+
@height.gsub(/[^0-9]/,'').to_i/side
|
62
|
+
end
|
63
|
+
|
64
|
+
def side
|
65
|
+
input_files.length/2
|
66
|
+
end
|
67
|
+
|
68
|
+
def grid
|
69
|
+
"#{side}+#{side}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def input_files_text
|
73
|
+
input_files.join(' ')
|
74
|
+
end
|
75
|
+
|
76
|
+
def input_files
|
77
|
+
(0..@num_of_imgs-1).collect do |i|
|
78
|
+
if @files.nil?
|
79
|
+
absolute_file( @file )
|
80
|
+
else
|
81
|
+
absolute_file( @files[i] )
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def output_file dst
|
87
|
+
absolute_file dst
|
88
|
+
end
|
89
|
+
|
90
|
+
def absolute_file file
|
91
|
+
"#{ File.expand_path(file.path) }"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: paperclip_montage 0.1.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "paperclip_montage"
|
9
|
+
s.version = "0.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Daniel W. Crompton"]
|
14
|
+
s.date = "2014-12-14"
|
15
|
+
s.description = "This module stores the image files in Redis"
|
16
|
+
s.email = ["paperclip+montage@specialbrands.net"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".rspec",
|
23
|
+
".travis.yml",
|
24
|
+
"Gemfile",
|
25
|
+
"Guardfile",
|
26
|
+
"LICENSE",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"config/Guardfile",
|
30
|
+
"lib/generators/paperclip_montage/USAGE",
|
31
|
+
"lib/generators/paperclip_montage/paperclip_montage_generator.rb",
|
32
|
+
"lib/paperclip/montage.rb",
|
33
|
+
"lib/paperclip/myversion.rb",
|
34
|
+
"lib/paperclip_montage.rb",
|
35
|
+
"paperclip_montage.gemspec",
|
36
|
+
"spec/fixtures/valid.jpg",
|
37
|
+
"spec/fixtures/valid1.png",
|
38
|
+
"spec/fixtures/valid2.png",
|
39
|
+
"spec/fixtures/valid3.png",
|
40
|
+
"spec/fixtures/valid4.png",
|
41
|
+
"spec/paperclip/montage_spec.rb",
|
42
|
+
"spec/rails-app/.gitignore",
|
43
|
+
"spec/rails-app/.rspec",
|
44
|
+
"spec/rails-app/Gemfile",
|
45
|
+
"spec/rails-app/Guardfile",
|
46
|
+
"spec/rails-app/README.rdoc",
|
47
|
+
"spec/rails-app/Rakefile",
|
48
|
+
"spec/rails-app/app/assets/images/.keep",
|
49
|
+
"spec/rails-app/app/assets/javascripts/application.js",
|
50
|
+
"spec/rails-app/app/assets/stylesheets/application.css",
|
51
|
+
"spec/rails-app/app/controllers/application_controller.rb",
|
52
|
+
"spec/rails-app/app/controllers/concerns/.keep",
|
53
|
+
"spec/rails-app/app/helpers/application_helper.rb",
|
54
|
+
"spec/rails-app/app/models/.keep",
|
55
|
+
"spec/rails-app/app/models/avatar.rb",
|
56
|
+
"spec/rails-app/app/models/avatars_meta.rb",
|
57
|
+
"spec/rails-app/app/models/concerns/.keep",
|
58
|
+
"spec/rails-app/app/models/meta.rb",
|
59
|
+
"spec/rails-app/app/views/layouts/application.html.erb",
|
60
|
+
"spec/rails-app/bin/bundle",
|
61
|
+
"spec/rails-app/bin/rails",
|
62
|
+
"spec/rails-app/bin/rake",
|
63
|
+
"spec/rails-app/bin/spring",
|
64
|
+
"spec/rails-app/config.ru",
|
65
|
+
"spec/rails-app/config/Guardfile",
|
66
|
+
"spec/rails-app/config/application.rb",
|
67
|
+
"spec/rails-app/config/boot.rb",
|
68
|
+
"spec/rails-app/config/database.yml",
|
69
|
+
"spec/rails-app/config/environment.rb",
|
70
|
+
"spec/rails-app/config/environments/development.rb",
|
71
|
+
"spec/rails-app/config/environments/production.rb",
|
72
|
+
"spec/rails-app/config/environments/test.rb",
|
73
|
+
"spec/rails-app/config/initializers/assets.rb",
|
74
|
+
"spec/rails-app/config/initializers/backtrace_silencers.rb",
|
75
|
+
"spec/rails-app/config/initializers/cookies_serializer.rb",
|
76
|
+
"spec/rails-app/config/initializers/filter_parameter_logging.rb",
|
77
|
+
"spec/rails-app/config/initializers/inflections.rb",
|
78
|
+
"spec/rails-app/config/initializers/mime_types.rb",
|
79
|
+
"spec/rails-app/config/initializers/session_store.rb",
|
80
|
+
"spec/rails-app/config/initializers/wrap_parameters.rb",
|
81
|
+
"spec/rails-app/config/locales/en.yml",
|
82
|
+
"spec/rails-app/config/routes.rb",
|
83
|
+
"spec/rails-app/config/secrets.yml",
|
84
|
+
"spec/rails-app/db/migrate/20141212000615_create_avatars.rb",
|
85
|
+
"spec/rails-app/db/migrate/20141212000731_create_meta.rb",
|
86
|
+
"spec/rails-app/db/migrate/20141214193102_create_avatars_meta.rb",
|
87
|
+
"spec/rails-app/db/schema.rb",
|
88
|
+
"spec/rails-app/db/seeds.rb",
|
89
|
+
"spec/rails-app/public/404.html",
|
90
|
+
"spec/rails-app/public/422.html",
|
91
|
+
"spec/rails-app/public/500.html",
|
92
|
+
"spec/rails-app/public/favicon.ico",
|
93
|
+
"spec/rails-app/public/robots.txt",
|
94
|
+
"spec/rails-app/spec/models/avatar_spec.rb",
|
95
|
+
"spec/rails-app/spec/models/avatars_meta_spec.rb",
|
96
|
+
"spec/rails-app/spec/models/meta_spec.rb",
|
97
|
+
"spec/rails-app/spec/rails_helper.rb",
|
98
|
+
"spec/rails-app/spec/spec_helper.rb",
|
99
|
+
"spec/spec_helper.rb"
|
100
|
+
]
|
101
|
+
s.homepage = "http://github.com/webhat/paperclip_montage"
|
102
|
+
s.licenses = ["LGPLv2"]
|
103
|
+
s.rubygems_version = "2.2.2"
|
104
|
+
s.summary = "Paperclip Montage"
|
105
|
+
|
106
|
+
if s.respond_to? :specification_version then
|
107
|
+
s.specification_version = 4
|
108
|
+
|
109
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
110
|
+
s.add_runtime_dependency(%q<paperclip>, [">= 0"])
|
111
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
112
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
113
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
114
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
115
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
116
|
+
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
117
|
+
s.add_development_dependency(%q<guard-yard>, [">= 0"])
|
118
|
+
s.add_development_dependency(%q<rails>, [">= 3.1.0"])
|
119
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
120
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
121
|
+
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
|
122
|
+
s.add_development_dependency(%q<coveralls>, [">= 0"])
|
123
|
+
else
|
124
|
+
s.add_dependency(%q<paperclip>, [">= 0"])
|
125
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
126
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
127
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
128
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
129
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
130
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
131
|
+
s.add_dependency(%q<guard-yard>, [">= 0"])
|
132
|
+
s.add_dependency(%q<rails>, [">= 3.1.0"])
|
133
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
134
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
135
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
136
|
+
s.add_dependency(%q<coveralls>, [">= 0"])
|
137
|
+
end
|
138
|
+
else
|
139
|
+
s.add_dependency(%q<paperclip>, [">= 0"])
|
140
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
141
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
142
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
143
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
144
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
145
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
146
|
+
s.add_dependency(%q<guard-yard>, [">= 0"])
|
147
|
+
s.add_dependency(%q<rails>, [">= 3.1.0"])
|
148
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
149
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
150
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
151
|
+
s.add_dependency(%q<coveralls>, [">= 0"])
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Paperclip::Montage do
|
4
|
+
before(:all) do
|
5
|
+
@file = get_fixture(:jpg)
|
6
|
+
end
|
7
|
+
after(:all) do
|
8
|
+
@file.close
|
9
|
+
end
|
10
|
+
it '#initialize' do
|
11
|
+
expect(described_class.new @file).to_not be_nil
|
12
|
+
end
|
13
|
+
it '#initialize nil' do
|
14
|
+
expect{
|
15
|
+
described_class.new nil
|
16
|
+
}.to raise_error
|
17
|
+
end
|
18
|
+
it '#make' do
|
19
|
+
expect(described_class.new(@file).make).to be_kind_of(Tempfile)
|
20
|
+
end
|
21
|
+
it '.make' do
|
22
|
+
expect(described_class.make(@file)).to be_kind_of(Tempfile)
|
23
|
+
end
|
24
|
+
context 'multiple files' do
|
25
|
+
before do
|
26
|
+
@file1 = get_fixture(:png, 'valid1')
|
27
|
+
@file2 = get_fixture(:png, 'valid2')
|
28
|
+
@file3 = get_fixture(:png, 'valid3')
|
29
|
+
@file4 = get_fixture(:png, 'valid4')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'creates a montage' do
|
33
|
+
options = {geometry: '200x200', source: [@file1, @file2, @file3, @file4]}
|
34
|
+
montage = described_class.new @file, options
|
35
|
+
tempfile = montage.make
|
36
|
+
expect(tempfile).to be_kind_of(Tempfile)
|
37
|
+
#ObjectSpace.undefine_finalizer(tempfile)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'creates a montage with source nil' do
|
41
|
+
options = {geometry: '200x200', source: nil}
|
42
|
+
montage = described_class.new @file, options
|
43
|
+
tempfile = montage.make
|
44
|
+
expect(tempfile).to be_kind_of(Tempfile)
|
45
|
+
#ObjectSpace.undefine_finalizer(tempfile)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'creates a montage with source empty' do
|
49
|
+
options = {geometry: '200x200', source: []}
|
50
|
+
montage = described_class.new @file, options
|
51
|
+
tempfile = montage.make
|
52
|
+
expect(tempfile).to be_kind_of(Tempfile)
|
53
|
+
#ObjectSpace.undefine_finalizer(tempfile)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|