dragonfly 0.1.6 → 0.2.1
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/.yardopts +4 -0
- data/{README.markdown → README.md} +12 -24
- data/Rakefile +6 -6
- data/VERSION +1 -1
- data/config.rb +1 -3
- data/docs.watchr +1 -1
- data/dragonfly-rails.gemspec +2 -5
- data/dragonfly.gemspec +32 -12
- data/extra_docs/ActiveRecord.md +195 -0
- data/extra_docs/Analysers.md +63 -0
- data/extra_docs/DataStorage.md +33 -0
- data/extra_docs/Encoding.md +58 -0
- data/extra_docs/GettingStarted.md +114 -0
- data/extra_docs/Processing.md +58 -0
- data/extra_docs/Shortcuts.md +118 -0
- data/extra_docs/UsingWithRails.md +104 -0
- data/features/{dragonfly.feature → images.feature} +14 -4
- data/features/no_processing.feature +20 -0
- data/features/steps/dragonfly_steps.rb +29 -8
- data/features/support/env.rb +20 -8
- data/generators/dragonfly_app/USAGE +0 -1
- data/generators/dragonfly_app/dragonfly_app_generator.rb +1 -13
- data/generators/dragonfly_app/templates/metal_file.erb +1 -1
- data/lib/dragonfly/active_record_extensions.rb +1 -0
- data/lib/dragonfly/active_record_extensions/attachment.rb +52 -6
- data/lib/dragonfly/active_record_extensions/validations.rb +26 -6
- data/lib/dragonfly/analysis/base.rb +6 -3
- data/lib/dragonfly/analysis/r_magick_analyser.rb +0 -6
- data/lib/dragonfly/app.rb +53 -35
- data/lib/dragonfly/configurable.rb +1 -1
- data/lib/dragonfly/data_storage/file_data_store.rb +8 -8
- data/lib/dragonfly/delegatable.rb +14 -0
- data/lib/dragonfly/delegator.rb +50 -0
- data/lib/dragonfly/encoding/base.rb +7 -7
- data/lib/dragonfly/encoding/r_magick_encoder.rb +3 -0
- data/lib/dragonfly/encoding/transparent_encoder.rb +1 -1
- data/lib/dragonfly/extended_temp_object.rb +13 -7
- data/lib/dragonfly/parameters.rb +17 -11
- data/lib/dragonfly/processing/base.rb +9 -0
- data/lib/dragonfly/processing/r_magick_processor.rb +15 -1
- data/lib/dragonfly/r_magick_configuration.rb +12 -8
- data/lib/dragonfly/rails/images.rb +1 -1
- data/lib/dragonfly/temp_object.rb +14 -2
- data/lib/dragonfly/url_handler.rb +5 -6
- data/samples/sample.docx +0 -0
- data/spec/dragonfly/active_record_extensions/model_spec.rb +175 -84
- data/spec/dragonfly/analysis/r_magick_analyser_spec.rb +0 -8
- data/spec/dragonfly/app_spec.rb +3 -3
- data/spec/dragonfly/configurable_spec.rb +1 -1
- data/spec/dragonfly/data_storage/file_data_store_spec.rb +55 -40
- data/spec/dragonfly/delegatable_spec.rb +32 -0
- data/spec/dragonfly/delegator_spec.rb +133 -0
- data/spec/dragonfly/encoding/r_magick_encoder_spec.rb +28 -0
- data/spec/dragonfly/extended_temp_object_spec.rb +5 -5
- data/spec/dragonfly/parameters_spec.rb +22 -32
- data/spec/dragonfly/processing/rmagick_processor_spec.rb +1 -2
- data/spec/dragonfly/temp_object_spec.rb +51 -0
- data/spec/dragonfly/url_handler_spec.rb +10 -15
- data/yard/handlers/configurable_attr_handler.rb +38 -0
- data/yard/setup.rb +9 -0
- data/yard/templates/default/fulldoc/html/css/common.css +27 -0
- data/yard/templates/default/module/html/configuration_summary.erb +31 -0
- data/yard/templates/default/module/setup.rb +17 -0
- metadata +31 -12
- data/features/support/image_helpers.rb +0 -9
- data/generators/dragonfly_app/templates/custom_processing.erb +0 -13
- data/lib/dragonfly/analysis/analyser.rb +0 -45
- data/lib/dragonfly/processing/processor.rb +0 -14
- data/spec/dragonfly/analysis/analyser_spec.rb +0 -85
@@ -1,85 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
|
3
|
-
class ImageAnalyser < Dragonfly::Analysis::Base
|
4
|
-
|
5
|
-
def width(temp_object)
|
6
|
-
temp_object.data.length
|
7
|
-
end
|
8
|
-
|
9
|
-
def mime_type(temp_object)
|
10
|
-
return 'image/fart' if temp_object.data == 'THIS IS AN IMAGE'
|
11
|
-
return 'image/pdf' if temp_object.data == 'THIS IS A PDF'
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
class PdfAnalyser < Dragonfly::Analysis::Base
|
17
|
-
|
18
|
-
def pdf_type(temp_object)
|
19
|
-
'egg'
|
20
|
-
end
|
21
|
-
|
22
|
-
def mime_type(temp_object)
|
23
|
-
'application/pdf' if temp_object.data == 'THIS IS A PDF'
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Dragonfly::Analysis::Analyser do
|
29
|
-
|
30
|
-
describe "mime_type" do
|
31
|
-
|
32
|
-
before(:each) do
|
33
|
-
@analyser = Dragonfly::Analysis::Analyser.new
|
34
|
-
@image = Dragonfly::TempObject.new("THIS IS AN IMAGE")
|
35
|
-
@pdf = Dragonfly::TempObject.new("THIS IS A PDF")
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "when no analysers have been registered" do
|
39
|
-
|
40
|
-
it "should return nil when no modules have been registered" do
|
41
|
-
@analyser.mime_type(@image).should be_nil
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should should return analysis methods as an empty array" do
|
45
|
-
@analyser.analysis_methods.should == []
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "after registering a number of modules" do
|
51
|
-
|
52
|
-
before(:each) do
|
53
|
-
@analyser.register(ImageAnalyser.new)
|
54
|
-
@analyser.register(PdfAnalyser.new)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should return the correct value when one of the modules returns non-nil" do
|
58
|
-
@analyser.mime_type(@image).should == 'image/fart'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should override the first registered modules's value with the second, when they both return non-nil" do
|
62
|
-
@analyser.mime_type(@pdf).should == 'application/pdf'
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should return all the analysis methods" do
|
66
|
-
@analyser.analysis_methods.sort.should == ['mime_type', 'pdf_type', 'width']
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should say if if has an analysis method (as a symbol)" do
|
70
|
-
@analyser.has_analysis_method?('pdf_type').should be_true
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should say if if has an analysis method (as a string)" do
|
74
|
-
@analyser.has_analysis_method?(:pdf_type).should be_true
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should delegate the call of a method to the registered analysers" do
|
78
|
-
@analyser.width(@image).should == 16
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|