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.

Files changed (155) hide show
  1. data/{.specopts → .rspec} +0 -1
  2. data/.yardopts +6 -2
  3. data/Gemfile +14 -13
  4. data/History.md +47 -9
  5. data/README.md +25 -5
  6. data/Rakefile +37 -79
  7. data/VERSION +1 -1
  8. data/dragonfly.gemspec +140 -89
  9. data/extra_docs/Analysers.md +8 -48
  10. data/extra_docs/Configuration.md +40 -25
  11. data/extra_docs/Couch.md +49 -0
  12. data/extra_docs/DataStorage.md +94 -24
  13. data/extra_docs/Encoding.md +6 -35
  14. data/extra_docs/ExampleUseCases.md +113 -0
  15. data/extra_docs/GeneralUsage.md +7 -23
  16. data/extra_docs/Generators.md +15 -49
  17. data/extra_docs/Heroku.md +7 -8
  18. data/extra_docs/ImageMagick.md +126 -0
  19. data/extra_docs/MimeTypes.md +3 -3
  20. data/extra_docs/Models.md +163 -0
  21. data/extra_docs/Mongo.md +1 -4
  22. data/extra_docs/Processing.md +7 -60
  23. data/extra_docs/Rails2.md +3 -1
  24. data/extra_docs/Rails3.md +2 -10
  25. data/extra_docs/ServingRemotely.md +83 -0
  26. data/extra_docs/Sinatra.md +3 -3
  27. data/extra_docs/URLs.md +60 -33
  28. data/features/rails_3.0.5.feature +8 -0
  29. data/features/steps/rails_steps.rb +7 -18
  30. data/features/support/env.rb +10 -37
  31. data/features/support/setup.rb +32 -0
  32. data/fixtures/rails_3.0.5/files/app/models/album.rb +5 -0
  33. data/fixtures/rails_3.0.5/files/app/views/albums/new.html.erb +7 -0
  34. data/fixtures/{files → rails_3.0.5/files}/app/views/albums/show.html.erb +2 -0
  35. data/fixtures/{files → rails_3.0.5/files}/config/initializers/dragonfly.rb +0 -0
  36. data/fixtures/rails_3.0.5/files/features/manage_album_images.feature +38 -0
  37. data/fixtures/rails_3.0.5/files/features/step_definitions/helper_steps.rb +7 -0
  38. data/fixtures/{files → rails_3.0.5/files}/features/step_definitions/image_steps.rb +11 -1
  39. data/fixtures/{files → rails_3.0.5/files}/features/support/paths.rb +2 -0
  40. data/fixtures/{files → rails_3.0.5/files}/features/text_images.feature +0 -0
  41. data/fixtures/{rails_3.0.3 → rails_3.0.5}/template.rb +2 -2
  42. data/irbrc.rb +2 -1
  43. data/lib/dragonfly.rb +7 -0
  44. data/lib/dragonfly/active_model_extensions/attachment.rb +134 -46
  45. data/lib/dragonfly/active_model_extensions/attachment_class_methods.rb +144 -0
  46. data/lib/dragonfly/active_model_extensions/class_methods.rb +62 -9
  47. data/lib/dragonfly/active_model_extensions/instance_methods.rb +2 -2
  48. data/lib/dragonfly/active_model_extensions/validations.rb +10 -6
  49. data/lib/dragonfly/analyser.rb +0 -1
  50. data/lib/dragonfly/analysis/file_command_analyser.rb +1 -1
  51. data/lib/dragonfly/analysis/image_magick_analyser.rb +2 -43
  52. data/lib/dragonfly/app.rb +64 -55
  53. data/lib/dragonfly/config/heroku.rb +1 -1
  54. data/lib/dragonfly/config/image_magick.rb +2 -37
  55. data/lib/dragonfly/config/rails.rb +5 -2
  56. data/lib/dragonfly/configurable.rb +115 -35
  57. data/lib/dragonfly/core_ext/object.rb +1 -1
  58. data/lib/dragonfly/core_ext/string.rb +1 -1
  59. data/lib/dragonfly/data_storage/couch_data_store.rb +84 -0
  60. data/lib/dragonfly/data_storage/file_data_store.rb +43 -18
  61. data/lib/dragonfly/data_storage/mongo_data_store.rb +8 -4
  62. data/lib/dragonfly/data_storage/s3data_store.rb +82 -38
  63. data/lib/dragonfly/encoding/image_magick_encoder.rb +2 -53
  64. data/lib/dragonfly/function_manager.rb +4 -2
  65. data/lib/dragonfly/generation/image_magick_generator.rb +2 -136
  66. data/lib/dragonfly/hash_with_css_style_keys.rb +21 -0
  67. data/lib/dragonfly/image_magick/analyser.rb +51 -0
  68. data/lib/dragonfly/image_magick/config.rb +44 -0
  69. data/lib/dragonfly/{encoding/r_magick_encoder.rb → image_magick/encoder.rb} +10 -14
  70. data/lib/dragonfly/image_magick/generator.rb +145 -0
  71. data/lib/dragonfly/image_magick/processor.rb +104 -0
  72. data/lib/dragonfly/image_magick/utils.rb +72 -0
  73. data/lib/dragonfly/image_magick_utils.rb +2 -79
  74. data/lib/dragonfly/job.rb +152 -90
  75. data/lib/dragonfly/middleware.rb +5 -19
  76. data/lib/dragonfly/processing/image_magick_processor.rb +2 -95
  77. data/lib/dragonfly/rails/images.rb +15 -10
  78. data/lib/dragonfly/response.rb +26 -12
  79. data/lib/dragonfly/serializer.rb +1 -4
  80. data/lib/dragonfly/server.rb +103 -0
  81. data/lib/dragonfly/temp_object.rb +56 -101
  82. data/lib/dragonfly/url_mapper.rb +78 -0
  83. data/spec/dragonfly/active_model_extensions/model_spec.rb +772 -65
  84. data/spec/dragonfly/active_model_extensions/spec_helper.rb +90 -10
  85. data/spec/dragonfly/analyser_spec.rb +1 -1
  86. data/spec/dragonfly/analysis/file_command_analyser_spec.rb +5 -14
  87. data/spec/dragonfly/app_spec.rb +35 -180
  88. data/spec/dragonfly/configurable_spec.rb +259 -18
  89. data/spec/dragonfly/core_ext/string_spec.rb +2 -2
  90. data/spec/dragonfly/core_ext/symbol_spec.rb +1 -1
  91. data/spec/dragonfly/data_storage/couch_data_store_spec.rb +84 -0
  92. data/spec/dragonfly/data_storage/file_data_store_spec.rb +149 -22
  93. data/spec/dragonfly/data_storage/mongo_data_store_spec.rb +21 -2
  94. data/spec/dragonfly/data_storage/s3_data_store_spec.rb +207 -43
  95. data/spec/dragonfly/data_storage/{data_store_spec.rb → shared_data_store_examples.rb} +16 -15
  96. data/spec/dragonfly/function_manager_spec.rb +2 -2
  97. data/spec/dragonfly/{generation/hash_with_css_style_keys_spec.rb → hash_with_css_style_keys_spec.rb} +2 -2
  98. data/spec/dragonfly/{analysis/shared_analyser_spec.rb → image_magick/analyser_spec.rb} +19 -6
  99. data/spec/dragonfly/{encoding/image_magick_encoder_spec.rb → image_magick/encoder_spec.rb} +2 -2
  100. data/spec/dragonfly/image_magick/generator_spec.rb +172 -0
  101. data/spec/dragonfly/{processing/shared_processing_spec.rb → image_magick/processor_spec.rb} +55 -6
  102. data/spec/dragonfly/image_magick/utils_spec.rb +18 -0
  103. data/spec/dragonfly/job_builder_spec.rb +1 -1
  104. data/spec/dragonfly/job_definitions_spec.rb +1 -1
  105. data/spec/dragonfly/job_endpoint_spec.rb +26 -3
  106. data/spec/dragonfly/job_spec.rb +426 -208
  107. data/spec/dragonfly/loggable_spec.rb +2 -2
  108. data/spec/dragonfly/middleware_spec.rb +5 -26
  109. data/spec/dragonfly/routed_endpoint_spec.rb +1 -1
  110. data/spec/dragonfly/serializer_spec.rb +1 -14
  111. data/spec/dragonfly/server_spec.rb +261 -0
  112. data/spec/dragonfly/simple_cache_spec.rb +1 -1
  113. data/spec/dragonfly/temp_object_spec.rb +84 -130
  114. data/spec/dragonfly/url_mapper_spec.rb +130 -0
  115. data/spec/functional/deprecations_spec.rb +51 -0
  116. data/spec/functional/image_magick_app_spec.rb +27 -0
  117. data/spec/functional/model_urls_spec.rb +85 -0
  118. data/spec/functional/remote_on_the_fly_spec.rb +51 -0
  119. data/spec/functional/to_response_spec.rb +31 -0
  120. data/spec/spec_helper.rb +12 -22
  121. data/spec/{argument_matchers.rb → support/argument_matchers.rb} +0 -0
  122. data/spec/{image_matchers.rb → support/image_matchers.rb} +4 -4
  123. data/spec/support/simple_matchers.rb +53 -0
  124. data/yard/handlers/configurable_attr_handler.rb +2 -2
  125. data/yard/templates/default/fulldoc/html/css/common.css +12 -10
  126. data/yard/templates/default/layout/html/layout.erb +6 -0
  127. metadata +267 -308
  128. data/Gemfile.rails.2.3.5 +0 -20
  129. data/features/3.0.3.feature +0 -8
  130. data/features/rails_2.3.5.feature +0 -7
  131. data/fixtures/files/app/models/album.rb +0 -3
  132. data/fixtures/files/app/views/albums/new.html.erb +0 -4
  133. data/fixtures/files/features/manage_album_images.feature +0 -12
  134. data/fixtures/rails_2.3.5/template.rb +0 -10
  135. data/lib/dragonfly/analysis/r_magick_analyser.rb +0 -63
  136. data/lib/dragonfly/config/r_magick.rb +0 -46
  137. data/lib/dragonfly/generation/hash_with_css_style_keys.rb +0 -23
  138. data/lib/dragonfly/generation/r_magick_generator.rb +0 -155
  139. data/lib/dragonfly/processing/r_magick_processor.rb +0 -126
  140. data/lib/dragonfly/r_magick_utils.rb +0 -48
  141. data/lib/dragonfly/simple_endpoint.rb +0 -76
  142. data/spec/dragonfly/active_model_extensions/active_model_setup.rb +0 -97
  143. data/spec/dragonfly/active_model_extensions/active_record_setup.rb +0 -85
  144. data/spec/dragonfly/analysis/image_magick_analyser_spec.rb +0 -15
  145. data/spec/dragonfly/analysis/r_magick_analyser_spec.rb +0 -31
  146. data/spec/dragonfly/config/r_magick_spec.rb +0 -29
  147. data/spec/dragonfly/encoding/r_magick_encoder_spec.rb +0 -41
  148. data/spec/dragonfly/generation/image_magick_generator_spec.rb +0 -12
  149. data/spec/dragonfly/generation/r_magick_generator_spec.rb +0 -28
  150. data/spec/dragonfly/generation/shared_generator_spec.rb +0 -91
  151. data/spec/dragonfly/image_magick_utils_spec.rb +0 -16
  152. data/spec/dragonfly/processing/image_magick_processor_spec.rb +0 -29
  153. data/spec/dragonfly/processing/r_magick_processor_spec.rb +0 -30
  154. data/spec/dragonfly/simple_endpoint_spec.rb +0 -97
  155. data/spec/simple_matchers.rb +0 -44
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
- describe "data_store", :shared => true do
3
+ shared_examples_for "data_store" do
4
4
 
5
5
  # Using these shared spec requires you to set the inst var @data_store
6
6
 
@@ -26,32 +26,33 @@ describe "data_store", :shared => true do
26
26
 
27
27
  describe "retrieve" do
28
28
 
29
- describe "without extra info" do
29
+ describe "without meta" do
30
30
  before(:each) do
31
31
  uid = @data_store.store(@temp_object)
32
- @obj, @extra_info = @data_store.retrieve(uid)
32
+ @obj, @meta = @data_store.retrieve(uid)
33
33
  end
34
34
 
35
35
  it "should retrieve the stored data" do
36
36
  Dragonfly::TempObject.new(@obj).data.should == @temp_object.data
37
37
  end
38
+
39
+ it "should return a meta hash (probably empty)" do
40
+ @meta.should be_a(Hash)
41
+ end
38
42
 
39
- it { @extra_info[:name].should be_nil }
40
- it { @extra_info[:meta].should be_a(Hash) }
41
43
  end
42
44
 
43
- describe "when extra info is given" do
45
+ describe "when meta is given" do
44
46
  before(:each) do
45
- temp_object = Dragonfly::TempObject.new('gollum',
46
- :name => 'danny.boy',
47
- :meta => {:bitrate => '35'}
48
- )
49
- @uid = @data_store.store(temp_object)
50
- @obj, @extra_info = @data_store.retrieve(@uid)
47
+ temp_object = Dragonfly::TempObject.new('gollum')
48
+ @uid = @data_store.store(temp_object, :meta => {:bitrate => '35', :name => 'danny.boy'})
49
+ @obj, @meta = @data_store.retrieve(@uid)
51
50
  end
52
51
 
53
- it { @extra_info[:name].should == 'danny.boy' }
54
- it { @extra_info[:meta].should include_hash(:bitrate => '35') }
52
+ it "should return the stored meta" do
53
+ @meta[:bitrate].should == '35'
54
+ @meta[:name].should == 'danny.boy'
55
+ end
55
56
  end
56
57
 
57
58
  it "should raise an exception if the data doesn't exist" do
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
- Spec::Matchers.define :have_keys do |*keys|
3
+ RSpec::Matchers.define :have_keys do |*keys|
4
4
  match do |given|
5
5
  given.keys.map{|sym| sym.to_s }.sort == keys.map{|sym| sym.to_s }.sort
6
6
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dragonfly::Generation::HashWithCssStyleKeys do
3
+ describe Dragonfly::HashWithCssStyleKeys do
4
4
 
5
5
  before(:each) do
6
- @hash = Dragonfly::Generation::HashWithCssStyleKeys[
6
+ @hash = Dragonfly::HashWithCssStyleKeys[
7
7
  :font_style => 'normal',
8
8
  :'font-weight' => 'bold',
9
9
  'font_colour' => 'white',
@@ -1,10 +1,13 @@
1
- # NEEDS:
2
- #
3
- # @image
4
- # @processor
5
- #
6
- describe "image analyser methods", :shared => true do
1
+ require 'spec_helper'
2
+
3
+ describe Dragonfly::ImageMagick::Analyser do
7
4
 
5
+ before(:each) do
6
+ image_path = File.dirname(__FILE__) + '/../../../samples/beach.png'
7
+ @image = Dragonfly::TempObject.new(File.new(image_path))
8
+ @analyser = Dragonfly::ImageMagick::Analyser.new
9
+ end
10
+
8
11
  it "should return the width" do
9
12
  @analyser.width(@image).should == 280
10
13
  end
@@ -48,4 +51,14 @@ describe "image analyser methods", :shared => true do
48
51
  end
49
52
  end
50
53
 
54
+ it "should say if it's an image" do
55
+ @analyser.image?(@image).should == true
56
+ end
57
+
58
+ it "should say if it's not an image" do
59
+ suppressing_stderr do
60
+ @analyser.image?(Dragonfly::TempObject.new('blah')).should == false
61
+ end
62
+ end
63
+
51
64
  end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dragonfly::Encoding::ImageMagickEncoder do
3
+ describe Dragonfly::ImageMagick::Encoder do
4
4
 
5
5
  before(:all) do
6
6
  sample_file = File.dirname(__FILE__) + '/../../../samples/beach.png' # 280x355, 135KB
7
7
  @image = Dragonfly::TempObject.new(File.new(sample_file))
8
- @encoder = Dragonfly::Encoding::ImageMagickEncoder.new
8
+ @encoder = Dragonfly::ImageMagick::Encoder.new
9
9
  end
10
10
 
11
11
  describe "#encode" do
@@ -0,0 +1,172 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dragonfly::ImageMagick::Generator do
4
+
5
+ before(:each) do
6
+ @generator = Dragonfly::ImageMagick::Generator.new
7
+ end
8
+
9
+ describe "plain" do
10
+ describe "of given dimensions and colour" do
11
+ before(:each) do
12
+ @image, @meta = @generator.plain(23,12,'white')
13
+ end
14
+ it {@image.should have_width(23)}
15
+ it {@image.should have_height(12)}
16
+ it {@image.should have_format('png')}
17
+ it {@meta.should == {:format => :png, :name => 'plain.png'}}
18
+ end
19
+
20
+ it "should cope with colour name format" do
21
+ image, meta = @generator.plain(1, 1, 'red')
22
+ image.should have_width(1)
23
+ end
24
+
25
+ it "should cope with rgb format" do
26
+ image, meta = @generator.plain(1, 1, 'rgb(244,255,1)')
27
+ image.should have_width(1)
28
+ end
29
+
30
+ it "should cope with rgb format with whitespace" do
31
+ image, meta = @generator.plain(1, 1, ' rgb ( 244 , 255 , 1 ) ')
32
+ image.should have_width(1)
33
+ end
34
+
35
+ it "should cope with rgb percent format" do
36
+ image, meta = @generator.plain(1, 1, 'rgb(100%,50%,20%)')
37
+ image.should have_width(1)
38
+ end
39
+
40
+ it "should cope with hex format" do
41
+ image, meta = @generator.plain(1, 1, '#fdafda')
42
+ image.should have_width(1)
43
+ end
44
+
45
+ it "should cope with uppercase hex format" do
46
+ image, meta = @generator.plain(1, 1, '#FDAFDA')
47
+ image.should have_width(1)
48
+ end
49
+
50
+ it "should cope with shortened hex format" do
51
+ image, meta = @generator.plain(1, 1, '#fda')
52
+ image.should have_width(1)
53
+ end
54
+
55
+ it "should cope with 'transparent'" do
56
+ image, meta = @generator.plain(1, 1, 'transparent')
57
+ image.should have_width(1)
58
+ end
59
+
60
+ it "should cope with rgba format" do
61
+ image, meta = @generator.plain(1, 1, 'rgba(25,100,255,0.5)')
62
+ image.should have_width(1)
63
+ end
64
+
65
+ it "should cope with hsl format" do
66
+ image, meta = @generator.plain(1, 1, 'hsl(25,100,255)')
67
+ image.should have_width(1)
68
+ end
69
+
70
+ it "should blow up with an invalid colour" do
71
+ lambda{
72
+ @generator.plain(1,1,'rgb(doogie)')
73
+ }.should_not raise_error()
74
+ end
75
+
76
+ describe "specifying the format" do
77
+ before(:each) do
78
+ @image, @meta = @generator.plain(23, 12, 'white', :format => :gif)
79
+ end
80
+ it {@image.should have_format('gif')}
81
+ it {@meta.should == {:format => :gif, :name => 'plain.gif'}}
82
+ end
83
+ end
84
+
85
+ describe "plasma" do
86
+ describe "of given dimensions" do
87
+ before(:each) do
88
+ @image, @meta = @generator.plasma(23,12)
89
+ end
90
+ it {@image.should have_width(23)}
91
+ it {@image.should have_height(12)}
92
+ it {@image.should have_format('png')}
93
+ it {@meta.should == {:format => :png, :name => 'plasma.png'}}
94
+ end
95
+
96
+ describe "specifying the format" do
97
+ before(:each) do
98
+ @image, @meta = @generator.plasma(23, 12, :gif)
99
+ end
100
+ it {@image.should have_format('gif')}
101
+ it {@meta.should == {:format => :gif, :name => 'plasma.gif'}}
102
+ end
103
+ end
104
+
105
+ describe "text" do
106
+ before(:each) do
107
+ @text = "mmm"
108
+ end
109
+
110
+ describe "creating a text image" do
111
+ before(:each) do
112
+ @image, @meta = @generator.text(@text, :font_size => 12)
113
+ end
114
+ it {@image.should have_width(20..40)} # approximate
115
+ it {@image.should have_height(10..20)}
116
+ it {@image.should have_format('png')}
117
+ it {@meta.should == {:format => :png, :name => 'text.png'}}
118
+ end
119
+
120
+ describe "specifying the format" do
121
+ before(:each) do
122
+ @image, @meta = @generator.text(@text, :format => :gif)
123
+ end
124
+ it {@image.should have_format('gif')}
125
+ it {@meta.should == {:format => :gif, :name => 'text.gif'}}
126
+ end
127
+
128
+ describe "padding" do
129
+ before(:each) do
130
+ no_padding_text, meta = @generator.text(@text, :font_size => 12)
131
+ @width = image_properties(no_padding_text)[:width].to_i
132
+ @height = image_properties(no_padding_text)[:height].to_i
133
+ end
134
+ it "1 number shortcut" do
135
+ image, meta = @generator.text(@text, :padding => '10')
136
+ image.should have_width(@width + 20)
137
+ image.should have_height(@height + 20)
138
+ end
139
+ it "2 numbers shortcut" do
140
+ image, meta = @generator.text(@text, :padding => '10 5')
141
+ image.should have_width(@width + 10)
142
+ image.should have_height(@height + 20)
143
+ end
144
+ it "3 numbers shortcut" do
145
+ image, meta = @generator.text(@text, :padding => '10 5 8')
146
+ image.should have_width(@width + 10)
147
+ image.should have_height(@height + 18)
148
+ end
149
+ it "4 numbers shortcut" do
150
+ image, meta = @generator.text(@text, :padding => '1 2 3 4')
151
+ image.should have_width(@width + 6)
152
+ image.should have_height(@height + 4)
153
+ end
154
+ it "should override the general padding declaration with the specific one (e.g. 'padding-left')" do
155
+ image, meta = @generator.text(@text, :padding => '10', 'padding-left' => 9)
156
+ image.should have_width(@width + 19)
157
+ image.should have_height(@height + 20)
158
+ end
159
+ it "should ignore 'px' suffixes" do
160
+ image, meta = @generator.text(@text, :padding => '1px 2px 3px 4px')
161
+ image.should have_width(@width + 6)
162
+ image.should have_height(@height + 4)
163
+ end
164
+ it "bad padding string" do
165
+ lambda{
166
+ @generator.text(@text, :padding => '1 2 3 4 5')
167
+ }.should raise_error(ArgumentError)
168
+ end
169
+ end
170
+ end
171
+
172
+ end
@@ -1,9 +1,12 @@
1
- # NEEDS:
2
- #
3
- # @image
4
- # @processor
5
- #
6
- describe "processing methods", :shared => true do
1
+ require 'spec_helper'
2
+
3
+ describe Dragonfly::ImageMagick::Processor do
4
+
5
+ before(:each) do
6
+ sample_file = File.dirname(__FILE__) + '/../../../samples/beach.png' # 280x355
7
+ @image = Dragonfly::TempObject.new(File.new(sample_file))
8
+ @processor = Dragonfly::ImageMagick::Processor.new
9
+ end
7
10
 
8
11
  describe "resize" do
9
12
 
@@ -110,6 +113,22 @@ describe "processing methods", :shared => true do
110
113
  image.should have_width(180)
111
114
  image.should have_height(155)
112
115
  end
116
+
117
+ it "should crop twice in a row correctly" do
118
+ image1 = @processor.crop(@image, :x => '10', :y => '10', :width => '100', :height => '100')
119
+ image2 = @processor.crop(Dragonfly::TempObject.new(image1), :x => '0' , :y => '0' , :width => '50' , :height => '50' )
120
+ image2.should have_width(50)
121
+ image2.should have_height(50)
122
+ end
123
+
124
+ it "should crop twice in a row while consciously keeping page geometry" do
125
+ # see http://www.imagemagick.org/Usage/crop/#crop_page
126
+ # it explains how cropping multiple times without resetting geometry behaves
127
+ image1 = @processor.crop(@image, :x => '10', :y => '10', :width => '100', :height => '100', :repage => false)
128
+ image2 = @processor.crop(Dragonfly::TempObject.new(image1), :x => '0' , :y => '0' , :width => '50' , :height => '50')
129
+ image2.should have_width(40)
130
+ image2.should have_height(40)
131
+ end
113
132
 
114
133
  end
115
134
 
@@ -170,6 +189,16 @@ describe "processing methods", :shared => true do
170
189
 
171
190
  end
172
191
 
192
+ describe "strip" do
193
+ it "should strip exif data" do
194
+ jpg = Dragonfly::TempObject.new(Pathname.new(File.dirname(__FILE__) + '/../../../samples/taj.jpg'))
195
+ image = @processor.strip(jpg)
196
+ image.should have_width(300)
197
+ image.should have_height(300)
198
+ image.size.should < jpg.size
199
+ end
200
+ end
201
+
173
202
  describe "thumb" do
174
203
  it "should call resize if the correct string given" do
175
204
  @processor.should_receive(:resize).with(@image, '30x40').and_return(image = mock)
@@ -211,5 +240,25 @@ describe "processing methods", :shared => true do
211
240
  image.should have_height(355)
212
241
  end
213
242
  end
243
+
244
+ describe "convert" do
245
+ it "should allow for general convert commands" do
246
+ image = @processor.convert(@image, '-scale 56x71')
247
+ image.should have_width(56)
248
+ image.should have_height(71)
249
+ end
250
+ it "should allow for general convert commands with added format" do
251
+ image, extra = @processor.convert(@image, '-scale 56x71', :gif)
252
+ image.should have_width(56)
253
+ image.should have_height(71)
254
+ image.should have_format('gif')
255
+ extra[:format].should == :gif
256
+ end
214
257
 
258
+ it "should work for commands with parenthesis" do
259
+ image = @processor.convert(@image, "\\( +clone -sparse-color Barycentric '0,0 black 0,%[fx:h-1] white' -function polynomial 2,-2,0.5 \\) -compose Blur -set option:compose:args 15 -composite")
260
+ image.should have_width(280)
261
+ end
262
+ end
263
+
215
264
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dragonfly::ImageMagick::Utils do
4
+
5
+ before(:each) do
6
+ @obj = Object.new
7
+ @obj.extend(Dragonfly::ImageMagick::Utils)
8
+ end
9
+
10
+ it "should raise an error if the identify command isn't found" do
11
+ suppressing_stderr do
12
+ lambda{
13
+ @obj.send(:run, "non-existent-command")
14
+ }.should raise_error(Dragonfly::ImageMagick::Utils::ShellCommandFailed)
15
+ end
16
+ end
17
+
18
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Dragonfly::JobBuilder do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Dragonfly::JobDefinitions do
4
4
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  ## General tests for Response go here as it's a pretty simple wrapper around that
5
5
 
@@ -7,7 +7,7 @@ describe "Dragonfly::JobEndpoint Rack::Lint tests" do
7
7
  before(:each) do
8
8
  @app = test_app
9
9
  @app.generator.add(:test_data){ "Test Data" }
10
- @job = Dragonfly::Job.new(@app).generate(:test_data)
10
+ @job = @app.generate(:test_data)
11
11
  @endpoint = Rack::Lint.new(Dragonfly::JobEndpoint.new(@job))
12
12
  end
13
13
 
@@ -43,7 +43,7 @@ describe Dragonfly::JobEndpoint do
43
43
  before(:each) do
44
44
  @app = test_app
45
45
  @app.datastore.stub!(:retrieve).with('egg').and_return(["GUNGLE", {:name => 'gung.txt'}])
46
- @job = Dragonfly::Job.new(@app).fetch('egg')
46
+ @job = @app.new_job.fetch('egg')
47
47
  end
48
48
 
49
49
  it "should return a correct response to a successful GET request" do
@@ -169,5 +169,28 @@ describe Dragonfly::JobEndpoint do
169
169
  end
170
170
  end
171
171
  end
172
+
173
+ describe "custom headers" do
174
+ before(:each) do
175
+ @app.configure{|c| c.response_headers['This-is'] = 'brill' }
176
+ end
177
+ it "should allow specifying custom headers" do
178
+ make_request(@job).headers['This-is'].should == 'brill'
179
+ end
180
+ it "should not interfere with other headers" do
181
+ make_request(@job).headers['Content-Length'].should == '6'
182
+ end
183
+ it "should allow overridding other headers" do
184
+ @app.response_headers['Cache-Control'] = 'try me'
185
+ make_request(@job).headers['Cache-Control'].should == 'try me'
186
+ end
187
+ it "should allow giving a proc" do
188
+ @app.response_headers['Cache-Control'] = proc{|job, request|
189
+ job.basename.reverse.upcase + request['a']
190
+ }
191
+ response = make_request(@job, 'QUERY_STRING' => 'a=egg')
192
+ response['Cache-Control'].should == 'GNUGegg'
193
+ end
194
+ end
172
195
 
173
196
  end