dragonfly 0.8.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dragonfly might be problematic. Click here for more details.
- data/{.specopts → .rspec} +0 -1
- data/.yardopts +6 -2
- data/Gemfile +14 -13
- data/History.md +47 -9
- data/README.md +25 -5
- data/Rakefile +37 -79
- data/VERSION +1 -1
- data/dragonfly.gemspec +140 -89
- data/extra_docs/Analysers.md +8 -48
- data/extra_docs/Configuration.md +40 -25
- data/extra_docs/Couch.md +49 -0
- data/extra_docs/DataStorage.md +94 -24
- data/extra_docs/Encoding.md +6 -35
- data/extra_docs/ExampleUseCases.md +113 -0
- data/extra_docs/GeneralUsage.md +7 -23
- data/extra_docs/Generators.md +15 -49
- data/extra_docs/Heroku.md +7 -8
- data/extra_docs/ImageMagick.md +126 -0
- data/extra_docs/MimeTypes.md +3 -3
- data/extra_docs/Models.md +163 -0
- data/extra_docs/Mongo.md +1 -4
- data/extra_docs/Processing.md +7 -60
- data/extra_docs/Rails2.md +3 -1
- data/extra_docs/Rails3.md +2 -10
- data/extra_docs/ServingRemotely.md +83 -0
- data/extra_docs/Sinatra.md +3 -3
- data/extra_docs/URLs.md +60 -33
- data/features/rails_3.0.5.feature +8 -0
- data/features/steps/rails_steps.rb +7 -18
- data/features/support/env.rb +10 -37
- data/features/support/setup.rb +32 -0
- data/fixtures/rails_3.0.5/files/app/models/album.rb +5 -0
- data/fixtures/rails_3.0.5/files/app/views/albums/new.html.erb +7 -0
- data/fixtures/{files → rails_3.0.5/files}/app/views/albums/show.html.erb +2 -0
- data/fixtures/{files → rails_3.0.5/files}/config/initializers/dragonfly.rb +0 -0
- data/fixtures/rails_3.0.5/files/features/manage_album_images.feature +38 -0
- data/fixtures/rails_3.0.5/files/features/step_definitions/helper_steps.rb +7 -0
- data/fixtures/{files → rails_3.0.5/files}/features/step_definitions/image_steps.rb +11 -1
- data/fixtures/{files → rails_3.0.5/files}/features/support/paths.rb +2 -0
- data/fixtures/{files → rails_3.0.5/files}/features/text_images.feature +0 -0
- data/fixtures/{rails_3.0.3 → rails_3.0.5}/template.rb +2 -2
- data/irbrc.rb +2 -1
- data/lib/dragonfly.rb +7 -0
- data/lib/dragonfly/active_model_extensions/attachment.rb +134 -46
- data/lib/dragonfly/active_model_extensions/attachment_class_methods.rb +144 -0
- data/lib/dragonfly/active_model_extensions/class_methods.rb +62 -9
- data/lib/dragonfly/active_model_extensions/instance_methods.rb +2 -2
- data/lib/dragonfly/active_model_extensions/validations.rb +10 -6
- data/lib/dragonfly/analyser.rb +0 -1
- data/lib/dragonfly/analysis/file_command_analyser.rb +1 -1
- data/lib/dragonfly/analysis/image_magick_analyser.rb +2 -43
- data/lib/dragonfly/app.rb +64 -55
- data/lib/dragonfly/config/heroku.rb +1 -1
- data/lib/dragonfly/config/image_magick.rb +2 -37
- data/lib/dragonfly/config/rails.rb +5 -2
- data/lib/dragonfly/configurable.rb +115 -35
- data/lib/dragonfly/core_ext/object.rb +1 -1
- data/lib/dragonfly/core_ext/string.rb +1 -1
- data/lib/dragonfly/data_storage/couch_data_store.rb +84 -0
- data/lib/dragonfly/data_storage/file_data_store.rb +43 -18
- data/lib/dragonfly/data_storage/mongo_data_store.rb +8 -4
- data/lib/dragonfly/data_storage/s3data_store.rb +82 -38
- data/lib/dragonfly/encoding/image_magick_encoder.rb +2 -53
- data/lib/dragonfly/function_manager.rb +4 -2
- data/lib/dragonfly/generation/image_magick_generator.rb +2 -136
- data/lib/dragonfly/hash_with_css_style_keys.rb +21 -0
- data/lib/dragonfly/image_magick/analyser.rb +51 -0
- data/lib/dragonfly/image_magick/config.rb +44 -0
- data/lib/dragonfly/{encoding/r_magick_encoder.rb → image_magick/encoder.rb} +10 -14
- data/lib/dragonfly/image_magick/generator.rb +145 -0
- data/lib/dragonfly/image_magick/processor.rb +104 -0
- data/lib/dragonfly/image_magick/utils.rb +72 -0
- data/lib/dragonfly/image_magick_utils.rb +2 -79
- data/lib/dragonfly/job.rb +152 -90
- data/lib/dragonfly/middleware.rb +5 -19
- data/lib/dragonfly/processing/image_magick_processor.rb +2 -95
- data/lib/dragonfly/rails/images.rb +15 -10
- data/lib/dragonfly/response.rb +26 -12
- data/lib/dragonfly/serializer.rb +1 -4
- data/lib/dragonfly/server.rb +103 -0
- data/lib/dragonfly/temp_object.rb +56 -101
- data/lib/dragonfly/url_mapper.rb +78 -0
- data/spec/dragonfly/active_model_extensions/model_spec.rb +772 -65
- data/spec/dragonfly/active_model_extensions/spec_helper.rb +90 -10
- data/spec/dragonfly/analyser_spec.rb +1 -1
- data/spec/dragonfly/analysis/file_command_analyser_spec.rb +5 -14
- data/spec/dragonfly/app_spec.rb +35 -180
- data/spec/dragonfly/configurable_spec.rb +259 -18
- data/spec/dragonfly/core_ext/string_spec.rb +2 -2
- data/spec/dragonfly/core_ext/symbol_spec.rb +1 -1
- data/spec/dragonfly/data_storage/couch_data_store_spec.rb +84 -0
- data/spec/dragonfly/data_storage/file_data_store_spec.rb +149 -22
- data/spec/dragonfly/data_storage/mongo_data_store_spec.rb +21 -2
- data/spec/dragonfly/data_storage/s3_data_store_spec.rb +207 -43
- data/spec/dragonfly/data_storage/{data_store_spec.rb → shared_data_store_examples.rb} +16 -15
- data/spec/dragonfly/function_manager_spec.rb +2 -2
- data/spec/dragonfly/{generation/hash_with_css_style_keys_spec.rb → hash_with_css_style_keys_spec.rb} +2 -2
- data/spec/dragonfly/{analysis/shared_analyser_spec.rb → image_magick/analyser_spec.rb} +19 -6
- data/spec/dragonfly/{encoding/image_magick_encoder_spec.rb → image_magick/encoder_spec.rb} +2 -2
- data/spec/dragonfly/image_magick/generator_spec.rb +172 -0
- data/spec/dragonfly/{processing/shared_processing_spec.rb → image_magick/processor_spec.rb} +55 -6
- data/spec/dragonfly/image_magick/utils_spec.rb +18 -0
- data/spec/dragonfly/job_builder_spec.rb +1 -1
- data/spec/dragonfly/job_definitions_spec.rb +1 -1
- data/spec/dragonfly/job_endpoint_spec.rb +26 -3
- data/spec/dragonfly/job_spec.rb +426 -208
- data/spec/dragonfly/loggable_spec.rb +2 -2
- data/spec/dragonfly/middleware_spec.rb +5 -26
- data/spec/dragonfly/routed_endpoint_spec.rb +1 -1
- data/spec/dragonfly/serializer_spec.rb +1 -14
- data/spec/dragonfly/server_spec.rb +261 -0
- data/spec/dragonfly/simple_cache_spec.rb +1 -1
- data/spec/dragonfly/temp_object_spec.rb +84 -130
- data/spec/dragonfly/url_mapper_spec.rb +130 -0
- data/spec/functional/deprecations_spec.rb +51 -0
- data/spec/functional/image_magick_app_spec.rb +27 -0
- data/spec/functional/model_urls_spec.rb +85 -0
- data/spec/functional/remote_on_the_fly_spec.rb +51 -0
- data/spec/functional/to_response_spec.rb +31 -0
- data/spec/spec_helper.rb +12 -22
- data/spec/{argument_matchers.rb → support/argument_matchers.rb} +0 -0
- data/spec/{image_matchers.rb → support/image_matchers.rb} +4 -4
- data/spec/support/simple_matchers.rb +53 -0
- data/yard/handlers/configurable_attr_handler.rb +2 -2
- data/yard/templates/default/fulldoc/html/css/common.css +12 -10
- data/yard/templates/default/layout/html/layout.erb +6 -0
- metadata +267 -308
- data/Gemfile.rails.2.3.5 +0 -20
- data/features/3.0.3.feature +0 -8
- data/features/rails_2.3.5.feature +0 -7
- data/fixtures/files/app/models/album.rb +0 -3
- data/fixtures/files/app/views/albums/new.html.erb +0 -4
- data/fixtures/files/features/manage_album_images.feature +0 -12
- data/fixtures/rails_2.3.5/template.rb +0 -10
- data/lib/dragonfly/analysis/r_magick_analyser.rb +0 -63
- data/lib/dragonfly/config/r_magick.rb +0 -46
- data/lib/dragonfly/generation/hash_with_css_style_keys.rb +0 -23
- data/lib/dragonfly/generation/r_magick_generator.rb +0 -155
- data/lib/dragonfly/processing/r_magick_processor.rb +0 -126
- data/lib/dragonfly/r_magick_utils.rb +0 -48
- data/lib/dragonfly/simple_endpoint.rb +0 -76
- data/spec/dragonfly/active_model_extensions/active_model_setup.rb +0 -97
- data/spec/dragonfly/active_model_extensions/active_record_setup.rb +0 -85
- data/spec/dragonfly/analysis/image_magick_analyser_spec.rb +0 -15
- data/spec/dragonfly/analysis/r_magick_analyser_spec.rb +0 -31
- data/spec/dragonfly/config/r_magick_spec.rb +0 -29
- data/spec/dragonfly/encoding/r_magick_encoder_spec.rb +0 -41
- data/spec/dragonfly/generation/image_magick_generator_spec.rb +0 -12
- data/spec/dragonfly/generation/r_magick_generator_spec.rb +0 -28
- data/spec/dragonfly/generation/shared_generator_spec.rb +0 -91
- data/spec/dragonfly/image_magick_utils_spec.rb +0 -16
- data/spec/dragonfly/processing/image_magick_processor_spec.rb +0 -29
- data/spec/dragonfly/processing/r_magick_processor_spec.rb +0 -30
- data/spec/dragonfly/simple_endpoint_spec.rb +0 -97
- data/spec/simple_matchers.rb +0 -44
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
|
3
|
-
module Dragonfly
|
4
|
-
module RMagickUtils
|
5
|
-
|
6
|
-
include Loggable
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
# Requires the extended object to respond to 'use_filesystem'
|
11
|
-
def rmagick_image(temp_object, &block)
|
12
|
-
imagelist = use_filesystem ? Magick::Image.read(temp_object.path) : Magick::Image.from_blob(temp_object.data)
|
13
|
-
image = imagelist.first
|
14
|
-
result = block.call(image)
|
15
|
-
case result
|
16
|
-
when Magick::Image, Magick::ImageList
|
17
|
-
content = use_filesystem ? write_to_tempfile(result) : result.to_blob
|
18
|
-
result.destroy!
|
19
|
-
else
|
20
|
-
content = result
|
21
|
-
end
|
22
|
-
image.destroy!
|
23
|
-
content
|
24
|
-
rescue Magick::ImageMagickError => e
|
25
|
-
log.warn("Unable to handle content in #{self.class} - got:\n#{e}")
|
26
|
-
throw :unable_to_handle
|
27
|
-
end
|
28
|
-
|
29
|
-
def ping_rmagick_image(temp_object, &block)
|
30
|
-
imagelist = use_filesystem ? Magick::Image.ping(temp_object.path) : Magick::Image.from_blob(temp_object.data)
|
31
|
-
image = imagelist.first
|
32
|
-
result = block.call(image)
|
33
|
-
image.destroy!
|
34
|
-
result
|
35
|
-
rescue Magick::ImageMagickError => e
|
36
|
-
log.warn("Unable to handle content in #{self.class} - got:\n#{e}")
|
37
|
-
throw :unable_to_handle
|
38
|
-
end
|
39
|
-
|
40
|
-
def write_to_tempfile(rmagick_image)
|
41
|
-
tempfile = Tempfile.new('dragonfly')
|
42
|
-
tempfile.close
|
43
|
-
rmagick_image.write(tempfile.path)
|
44
|
-
tempfile
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module Dragonfly
|
2
|
-
class SimpleEndpoint
|
3
|
-
|
4
|
-
# Exceptions
|
5
|
-
class JobNotAllowed < RuntimeError; end
|
6
|
-
|
7
|
-
include Loggable
|
8
|
-
|
9
|
-
# Instance methods
|
10
|
-
|
11
|
-
def initialize(app)
|
12
|
-
@app = app
|
13
|
-
use_same_log_as(app)
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(env)
|
17
|
-
request = Rack::Request.new(env)
|
18
|
-
|
19
|
-
case request.path_info
|
20
|
-
when '', '/', app.url_path_prefix
|
21
|
-
dragonfly_response
|
22
|
-
else
|
23
|
-
job = Job.from_path(request.path_info, app)
|
24
|
-
validate_job!(job)
|
25
|
-
job.validate_sha!(request['s']) if app.protect_from_dos_attacks
|
26
|
-
Response.new(job, env).to_response
|
27
|
-
end
|
28
|
-
rescue Serializer::BadString, Job::InvalidArray => e
|
29
|
-
log.warn(e.message)
|
30
|
-
[404, {'Content-Type' => 'text/plain'}, ['Not found']]
|
31
|
-
rescue Job::NoSHAGiven => e
|
32
|
-
[400, {"Content-Type" => 'text/plain'}, ["You need to give a SHA parameter"]]
|
33
|
-
rescue Job::IncorrectSHA => e
|
34
|
-
[400, {"Content-Type" => 'text/plain'}, ["The SHA parameter you gave (#{e}) is incorrect"]]
|
35
|
-
rescue JobNotAllowed => e
|
36
|
-
log.warn(e.message)
|
37
|
-
[403, {"Content-Type" => 'text/plain'}, ["Forbidden"]]
|
38
|
-
end
|
39
|
-
|
40
|
-
def required_params_for(job)
|
41
|
-
{'s' => job.sha}
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
attr_reader :app
|
47
|
-
|
48
|
-
def dragonfly_response
|
49
|
-
body = <<-DRAGONFLY
|
50
|
-
_o|o_
|
51
|
-
_~~---._( )_.---~~_
|
52
|
-
( . \\ / . )
|
53
|
-
`-.~--' |=| '--~.-'
|
54
|
-
_~-.~'" /|=|\\ "'~.-~_
|
55
|
-
( ./ |=| \\. )
|
56
|
-
`~~`"` |=| `"'ME"
|
57
|
-
|-|
|
58
|
-
<->
|
59
|
-
V
|
60
|
-
DRAGONFLY
|
61
|
-
[200, {
|
62
|
-
'Content-Type' => 'text/plain',
|
63
|
-
'Content-Size' => body.bytesize.to_s
|
64
|
-
},
|
65
|
-
[body]
|
66
|
-
]
|
67
|
-
end
|
68
|
-
|
69
|
-
def validate_job!(job)
|
70
|
-
if job.fetch_file_step
|
71
|
-
raise JobNotAllowed, "Dragonfly Server doesn't allow requesting job with steps #{job.steps.inspect}"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
# --------------------------------------------------------------- #
|
2
|
-
# MODELS
|
3
|
-
# --------------------------------------------------------------- #
|
4
|
-
class MyModel
|
5
|
-
|
6
|
-
# Callbacks
|
7
|
-
extend ActiveModel::Callbacks
|
8
|
-
define_model_callbacks :save, :destroy
|
9
|
-
|
10
|
-
include ActiveModel::Validations
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def create!(attrs={})
|
14
|
-
new(attrs).save!
|
15
|
-
end
|
16
|
-
|
17
|
-
def find(id)
|
18
|
-
new(instances[id])
|
19
|
-
end
|
20
|
-
|
21
|
-
def instances
|
22
|
-
@instances ||= {}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def initialize(attrs={})
|
27
|
-
attrs.each do |key, value|
|
28
|
-
send("#{key}=", value)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
attr_accessor :id
|
33
|
-
|
34
|
-
def to_hash
|
35
|
-
self.class::ATTRIBUTES.inject({}) do |hash, attr|
|
36
|
-
hash[attr] = send(attr)
|
37
|
-
hash
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def save
|
42
|
-
_run_save_callbacks {
|
43
|
-
self.id ||= rand(1000)
|
44
|
-
self.class.instances[id] = self.to_hash
|
45
|
-
}
|
46
|
-
end
|
47
|
-
def save!
|
48
|
-
save
|
49
|
-
self
|
50
|
-
end
|
51
|
-
|
52
|
-
def destroy
|
53
|
-
_run_destroy_callbacks {}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class Item < MyModel
|
58
|
-
|
59
|
-
ATTRIBUTES = [
|
60
|
-
:title,
|
61
|
-
:preview_image_uid,
|
62
|
-
:preview_image_some_analyser_method,
|
63
|
-
:preview_image_size,
|
64
|
-
:preview_image_name,
|
65
|
-
:preview_image_ext,
|
66
|
-
:preview_image_blah_blah,
|
67
|
-
:other_image_uid,
|
68
|
-
:yet_another_image_uid,
|
69
|
-
:otra_imagen_uid,
|
70
|
-
:trailer_video_uid,
|
71
|
-
:created_at,
|
72
|
-
:updated_at
|
73
|
-
]
|
74
|
-
attr_accessor *ATTRIBUTES
|
75
|
-
end
|
76
|
-
|
77
|
-
class Car < MyModel
|
78
|
-
ATTRIBUTES = [
|
79
|
-
:image_uid,
|
80
|
-
:reliant_image_uid,
|
81
|
-
:type
|
82
|
-
]
|
83
|
-
attr_accessor *ATTRIBUTES
|
84
|
-
end
|
85
|
-
|
86
|
-
class Photo < MyModel
|
87
|
-
ATTRIBUTES = [:image_uid]
|
88
|
-
attr_accessor *ATTRIBUTES
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
# --------------------------------------------------------------- #
|
93
|
-
# HELPER METHODS
|
94
|
-
# --------------------------------------------------------------- #
|
95
|
-
def model_class
|
96
|
-
MyModel
|
97
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# Seems to blow up on Rails 3 without this - only need temporarily
|
2
|
-
begin
|
3
|
-
require 'active_support/all'
|
4
|
-
rescue LoadError => e
|
5
|
-
puts "Couldn't load activesupport: #{e}"
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'active_record'
|
9
|
-
|
10
|
-
# --------------------------------------------------------------- #
|
11
|
-
# MIGRATION
|
12
|
-
# --------------------------------------------------------------- #
|
13
|
-
class MigrationForTest < ActiveRecord::Migration
|
14
|
-
|
15
|
-
def self.up
|
16
|
-
create_table :items, :force => true do |t|
|
17
|
-
t.string :title
|
18
|
-
t.string :preview_image_uid
|
19
|
-
t.string :preview_image_some_analyser_method
|
20
|
-
t.integer :preview_image_size
|
21
|
-
t.string :preview_image_name
|
22
|
-
t.string :preview_image_ext
|
23
|
-
t.string :preview_image_blah_blah
|
24
|
-
t.string :other_image_uid
|
25
|
-
t.string :yet_another_image_uid
|
26
|
-
t.string :otra_imagen_uid
|
27
|
-
t.string :trailer_video_uid
|
28
|
-
t.timestamps
|
29
|
-
end
|
30
|
-
|
31
|
-
create_table :cars do |t|
|
32
|
-
t.string :image_uid
|
33
|
-
t.string :reliant_image_uid
|
34
|
-
t.string :type
|
35
|
-
end
|
36
|
-
|
37
|
-
create_table :photos do |t|
|
38
|
-
t.string :image_uid
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.down
|
44
|
-
drop_table :items
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
# --------------------------------------------------------------- #
|
51
|
-
# MODELS
|
52
|
-
# --------------------------------------------------------------- #
|
53
|
-
class Item < ActiveRecord::Base
|
54
|
-
end
|
55
|
-
class Car < ActiveRecord::Base
|
56
|
-
end
|
57
|
-
class Photo < ActiveRecord::Base
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
# --------------------------------------------------------------- #
|
62
|
-
# SPEC CONFIG
|
63
|
-
# --------------------------------------------------------------- #
|
64
|
-
DB_FILE = File.expand_path(File.dirname(__FILE__)+'/db.sqlite3')
|
65
|
-
|
66
|
-
Spec::Runner.configure do |config|
|
67
|
-
|
68
|
-
config.before(:all) do
|
69
|
-
FileUtils.rm_f(DB_FILE)
|
70
|
-
ActiveRecord::Base.establish_connection(
|
71
|
-
:adapter => "sqlite3",
|
72
|
-
:database => DB_FILE
|
73
|
-
)
|
74
|
-
MigrationForTest.verbose = false
|
75
|
-
MigrationForTest.up
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
# --------------------------------------------------------------- #
|
81
|
-
# HELPER METHODS
|
82
|
-
# --------------------------------------------------------------- #
|
83
|
-
def model_class
|
84
|
-
ActiveRecord::Base
|
85
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'dragonfly/analysis/shared_analyser_spec'
|
3
|
-
|
4
|
-
describe Dragonfly::Analysis::ImageMagickAnalyser do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
image_path = File.dirname(__FILE__) + '/../../../samples/beach.png'
|
8
|
-
@image = Dragonfly::TempObject.new(File.new(image_path))
|
9
|
-
@analyser = Dragonfly::Analysis::ImageMagickAnalyser.new
|
10
|
-
@analyser.log = Logger.new(LOG_FILE)
|
11
|
-
end
|
12
|
-
|
13
|
-
it_should_behave_like "image analyser methods"
|
14
|
-
|
15
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
unless ENV['IGNORE_RMAGICK']
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'dragonfly/analysis/shared_analyser_spec'
|
5
|
-
|
6
|
-
describe Dragonfly::Analysis::RMagickAnalyser do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
image_path = File.dirname(__FILE__) + '/../../../samples/beach.png'
|
10
|
-
@image = Dragonfly::TempObject.new(File.new(image_path))
|
11
|
-
@analyser = Dragonfly::Analysis::RMagickAnalyser.new
|
12
|
-
@analyser.log = Logger.new(LOG_FILE)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "when using the filesystem" do
|
16
|
-
before(:each) do
|
17
|
-
@analyser.use_filesystem = true
|
18
|
-
end
|
19
|
-
it_should_behave_like "image analyser methods"
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "when not using the filesystem" do
|
23
|
-
before(:each) do
|
24
|
-
@analyser.use_filesystem = false
|
25
|
-
end
|
26
|
-
it_should_behave_like "image analyser methods"
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
unless ENV['IGNORE_RMAGICK']
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
|
-
|
5
|
-
describe Dragonfly::Config::RMagick do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@app = test_app
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should configure all to use the filesystem by default" do
|
12
|
-
@app.configure_with(Dragonfly::Config::RMagick)
|
13
|
-
@app.analyser.get_registered(Dragonfly::Analysis::RMagickAnalyser).use_filesystem.should be_true
|
14
|
-
@app.processor.get_registered(Dragonfly::Processing::RMagickProcessor).use_filesystem.should be_true
|
15
|
-
@app.encoder.get_registered(Dragonfly::Encoding::RMagickEncoder).use_filesystem.should be_true
|
16
|
-
@app.generator.get_registered(Dragonfly::Generation::RMagickGenerator).use_filesystem.should be_true
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should configure all not to use the filesystem if requested" do
|
20
|
-
@app.configure_with(Dragonfly::Config::RMagick, :use_filesystem => false)
|
21
|
-
@app.analyser.get_registered(Dragonfly::Analysis::RMagickAnalyser).use_filesystem.should be_false
|
22
|
-
@app.processor.get_registered(Dragonfly::Processing::RMagickProcessor).use_filesystem.should be_false
|
23
|
-
@app.encoder.get_registered(Dragonfly::Encoding::RMagickEncoder).use_filesystem.should be_false
|
24
|
-
@app.generator.get_registered(Dragonfly::Generation::RMagickGenerator).use_filesystem.should be_false
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
unless ENV['IGNORE_RMAGICK']
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Dragonfly::Encoding::RMagickEncoder do
|
6
|
-
|
7
|
-
before(:all) do
|
8
|
-
sample_file = File.dirname(__FILE__) + '/../../../samples/beach.png' # 280x355
|
9
|
-
@image = Dragonfly::TempObject.new(File.new(sample_file))
|
10
|
-
@encoder = Dragonfly::Encoding::RMagickEncoder.new
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#encode" do
|
14
|
-
|
15
|
-
it "should encode the image to the correct format" do
|
16
|
-
image = @encoder.encode(@image, :gif)
|
17
|
-
image.should have_format('gif')
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should throw :unable_to_handle if the format is not handleable" do
|
21
|
-
lambda{
|
22
|
-
@encoder.encode(@image, :goofy)
|
23
|
-
}.should throw_symbol(:unable_to_handle)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should do nothing if the image is already in the correct format" do
|
27
|
-
image = @encoder.encode(@image, :png)
|
28
|
-
image.should == @image
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should work when not using the filesystem" do
|
32
|
-
@encoder.use_filesystem = false
|
33
|
-
image = @encoder.encode(@image, :gif)
|
34
|
-
image.should have_format('gif')
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'dragonfly/generation/shared_generator_spec'
|
3
|
-
|
4
|
-
describe Dragonfly::Generation::ImageMagickGenerator do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
@generator = Dragonfly::Generation::ImageMagickGenerator.new
|
8
|
-
end
|
9
|
-
|
10
|
-
it_should_behave_like 'image generator'
|
11
|
-
|
12
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
unless ENV['IGNORE_RMAGICK']
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'dragonfly/generation/shared_generator_spec'
|
5
|
-
|
6
|
-
describe Dragonfly::Generation::RMagickGenerator do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
@generator = Dragonfly::Generation::RMagickGenerator.new
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "when using the filesystem" do
|
13
|
-
before(:each) do
|
14
|
-
@generator.use_filesystem = true
|
15
|
-
end
|
16
|
-
it_should_behave_like 'image generator'
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "when not using the filesystem" do
|
20
|
-
before(:each) do
|
21
|
-
@generator.use_filesystem = false
|
22
|
-
end
|
23
|
-
it_should_behave_like 'image generator'
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|