dragonfly 1.3.0 → 1.4.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/History.md +16 -0
- data/README.md +5 -1
- data/dev/test.ru +1 -1
- data/dragonfly.gemspec +2 -1
- data/lib/dragonfly/content.rb +17 -18
- data/lib/dragonfly/image_magick/commands.rb +35 -0
- data/lib/dragonfly/image_magick/generators/plain.rb +13 -7
- data/lib/dragonfly/image_magick/generators/plasma.rb +10 -6
- data/lib/dragonfly/image_magick/generators/text.rb +67 -58
- data/lib/dragonfly/image_magick/plugin.rb +26 -25
- data/lib/dragonfly/image_magick/processors/encode.rb +16 -5
- data/lib/dragonfly/image_magick/processors/thumb.rb +37 -31
- data/lib/dragonfly/middleware.rb +2 -1
- data/lib/dragonfly/param_validators.rb +37 -0
- data/lib/dragonfly/response.rb +11 -11
- data/lib/dragonfly/routed_endpoint.rb +1 -1
- data/lib/dragonfly/server.rb +7 -7
- data/lib/dragonfly/version.rb +1 -1
- data/spec/dragonfly/app_spec.rb +1 -1
- data/spec/dragonfly/configurable_spec.rb +4 -4
- data/spec/dragonfly/content_spec.rb +1 -1
- data/spec/dragonfly/file_data_store_spec.rb +2 -2
- data/spec/dragonfly/image_magick/commands_spec.rb +98 -0
- data/spec/dragonfly/image_magick/generators/plain_spec.rb +39 -13
- data/spec/dragonfly/image_magick/generators/plasma_spec.rb +28 -9
- data/spec/dragonfly/image_magick/generators/text_spec.rb +51 -20
- data/spec/dragonfly/image_magick/plugin_spec.rb +45 -28
- data/spec/dragonfly/image_magick/processors/encode_spec.rb +30 -0
- data/spec/dragonfly/image_magick/processors/thumb_spec.rb +46 -45
- data/spec/dragonfly/job/fetch_url_spec.rb +1 -1
- data/spec/dragonfly/job_endpoint_spec.rb +26 -26
- data/spec/dragonfly/middleware_spec.rb +15 -6
- data/spec/dragonfly/model/active_record_spec.rb +2 -2
- data/spec/dragonfly/model/model_spec.rb +1 -1
- data/spec/dragonfly/param_validators_spec.rb +89 -0
- data/spec/dragonfly/server_spec.rb +4 -4
- data/spec/dragonfly/temp_object_spec.rb +5 -5
- data/spec/functional/shell_commands_spec.rb +6 -9
- data/spec/functional/to_response_spec.rb +2 -2
- data/spec/functional/urls_spec.rb +1 -1
- data/spec/spec_helper.rb +18 -14
- data/spec/support/image_matchers.rb +1 -1
- metadata +27 -12
- data/lib/dragonfly/image_magick/generators/convert.rb +0 -19
- data/lib/dragonfly/image_magick/processors/convert.rb +0 -33
- data/spec/dragonfly/image_magick/generators/convert_spec.rb +0 -19
- data/spec/dragonfly/image_magick/processors/convert_spec.rb +0 -88
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Dragonfly::ImageMagick::Processors::Convert do
|
4
|
-
|
5
|
-
def sample_content(name)
|
6
|
-
Dragonfly::Content.new(app, SAMPLES_DIR.join(name))
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:app){ test_app }
|
10
|
-
let(:image){ sample_content('beach.png') } # 280x355
|
11
|
-
let(:processor){ Dragonfly::ImageMagick::Processors::Convert.new }
|
12
|
-
|
13
|
-
it "should allow for general convert commands" do
|
14
|
-
processor.call(image, '-scale 56x71')
|
15
|
-
image.should have_width(56)
|
16
|
-
image.should have_height(71)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should allow for general convert commands with added format" do
|
20
|
-
processor.call(image, '-scale 56x71', 'format' => 'gif')
|
21
|
-
image.should have_width(56)
|
22
|
-
image.should have_height(71)
|
23
|
-
image.should have_format('gif')
|
24
|
-
image.meta['format'].should == 'gif'
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should work for commands with parenthesis" do
|
28
|
-
processor.call(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")
|
29
|
-
image.should have_width(280)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should work for files with spaces/apostrophes in the name" do
|
33
|
-
image = Dragonfly::Content.new(app, SAMPLES_DIR.join("mevs' white pixel.png"))
|
34
|
-
processor.call(image, "-resize 2x2!")
|
35
|
-
image.should have_width(2)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "updates the url with format if given" do
|
39
|
-
url_attributes = Dragonfly::UrlAttributes.new
|
40
|
-
processor.update_url(url_attributes, '-scale 56x71', 'format' => 'gif')
|
41
|
-
url_attributes.ext.should == 'gif'
|
42
|
-
end
|
43
|
-
|
44
|
-
it "allows converting specific frames" do
|
45
|
-
gif = sample_content('gif.gif')
|
46
|
-
processor.call(gif, '-resize 50x50')
|
47
|
-
all_frames_size = gif.size
|
48
|
-
|
49
|
-
gif = sample_content('gif.gif')
|
50
|
-
processor.call(gif, '-resize 50x50', 'frame' => 0)
|
51
|
-
one_frame_size = gif.size
|
52
|
-
|
53
|
-
one_frame_size.should < all_frames_size
|
54
|
-
end
|
55
|
-
|
56
|
-
it "accepts input arguments for convert commands" do
|
57
|
-
image2 = image.clone
|
58
|
-
processor.call(image, '')
|
59
|
-
processor.call(image2, '', 'input_args' => '-extract 50x50+10+10')
|
60
|
-
|
61
|
-
image.should_not equal_image(image2)
|
62
|
-
image2.should have_width(50)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "allows converting using specific delegates" do
|
66
|
-
expect {
|
67
|
-
processor.call(image, '', 'format' => 'jpg', 'delegate' => 'png')
|
68
|
-
}.to call_command(app.shell, %r{convert png:/[^']+?/beach\.png /[^']+?\.jpg})
|
69
|
-
end
|
70
|
-
|
71
|
-
it "maintains the mime_type meta if it exists already" do
|
72
|
-
processor.call(image, '-resize 10x')
|
73
|
-
image.meta['mime_type'].should be_nil
|
74
|
-
|
75
|
-
image.add_meta('mime_type' => 'image/png')
|
76
|
-
processor.call(image, '-resize 5x')
|
77
|
-
image.meta['mime_type'].should == 'image/png'
|
78
|
-
image.mime_type.should == 'image/png' # sanity check
|
79
|
-
end
|
80
|
-
|
81
|
-
it "doesn't maintain the mime_type meta on format change" do
|
82
|
-
image.add_meta('mime_type' => 'image/png')
|
83
|
-
processor.call(image, '', 'format' => 'gif')
|
84
|
-
image.meta['mime_type'].should be_nil
|
85
|
-
image.mime_type.should == 'image/gif' # sanity check
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|