dragonfly 1.1.4 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +14 -6
  3. data/History.md +336 -309
  4. data/README.md +1 -1
  5. data/dev/rails_template.rb +35 -33
  6. data/dragonfly.gemspec +10 -16
  7. data/lib/dragonfly.rb +3 -1
  8. data/lib/dragonfly/content.rb +21 -22
  9. data/lib/dragonfly/image_magick/commands.rb +35 -0
  10. data/lib/dragonfly/image_magick/generators/plain.rb +13 -7
  11. data/lib/dragonfly/image_magick/generators/plasma.rb +10 -6
  12. data/lib/dragonfly/image_magick/generators/text.rb +67 -58
  13. data/lib/dragonfly/image_magick/plugin.rb +26 -25
  14. data/lib/dragonfly/image_magick/processors/encode.rb +16 -5
  15. data/lib/dragonfly/image_magick/processors/thumb.rb +37 -31
  16. data/lib/dragonfly/job/fetch_url.rb +1 -1
  17. data/lib/dragonfly/model/class_methods.rb +6 -1
  18. data/lib/dragonfly/param_validators.rb +37 -0
  19. data/lib/dragonfly/response.rb +2 -2
  20. data/lib/dragonfly/shell.rb +19 -13
  21. data/lib/dragonfly/utils.rb +1 -1
  22. data/lib/dragonfly/version.rb +1 -1
  23. data/samples/white pixel.png b/data/samples/mevs' white → pixel.png +0 -0
  24. data/spec/dragonfly/content_spec.rb +3 -3
  25. data/spec/dragonfly/cookie_monster_spec.rb +2 -2
  26. data/spec/dragonfly/image_magick/commands_spec.rb +98 -0
  27. data/spec/dragonfly/image_magick/generators/plain_spec.rb +39 -13
  28. data/spec/dragonfly/image_magick/generators/plasma_spec.rb +28 -9
  29. data/spec/dragonfly/image_magick/generators/text_spec.rb +51 -20
  30. data/spec/dragonfly/image_magick/plugin_spec.rb +45 -28
  31. data/spec/dragonfly/image_magick/processors/encode_spec.rb +30 -0
  32. data/spec/dragonfly/image_magick/processors/thumb_spec.rb +46 -45
  33. data/spec/dragonfly/model/active_record_spec.rb +62 -0
  34. data/spec/dragonfly/param_validators_spec.rb +89 -0
  35. data/spec/dragonfly/shell_spec.rb +12 -10
  36. data/spec/dragonfly_spec.rb +37 -13
  37. data/spec/functional/shell_commands_spec.rb +6 -9
  38. data/spec/spec_helper.rb +12 -14
  39. metadata +45 -14
  40. data/lib/dragonfly/image_magick/generators/convert.rb +0 -19
  41. data/lib/dragonfly/image_magick/processors/convert.rb +0 -33
  42. data/spec/dragonfly/image_magick/generators/convert_spec.rb +0 -19
  43. data/spec/dragonfly/image_magick/processors/convert_spec.rb +0 -88
@@ -1,19 +0,0 @@
1
- module Dragonfly
2
- module ImageMagick
3
- module Generators
4
- class Convert
5
-
6
- def call(content, args, format)
7
- format = format.to_s
8
- convert_command = content.env[:convert_command] || 'convert'
9
- content.shell_generate :ext => format do |path|
10
- "#{convert_command} #{args} #{path}"
11
- end
12
- content.add_meta('format' => format)
13
- end
14
-
15
- end
16
- end
17
- end
18
- end
19
-
@@ -1,33 +0,0 @@
1
- module Dragonfly
2
- module ImageMagick
3
- module Processors
4
- class Convert
5
-
6
- def call(content, args='', opts={})
7
- convert_command = content.env[:convert_command] || 'convert'
8
- format = opts['format']
9
-
10
- input_args = opts['input_args'] if opts['input_args']
11
- delegate_string = "#{opts['delegate']}:" if opts['delegate']
12
- frame_string = "[#{opts['frame']}]" if opts['frame']
13
-
14
- content.shell_update :ext => format do |old_path, new_path|
15
- "#{convert_command} #{input_args} #{delegate_string}#{old_path}#{frame_string} #{args} #{new_path}"
16
- end
17
-
18
- if format
19
- content.meta['format'] = format.to_s
20
- content.ext = format
21
- content.meta['mime_type'] = nil # don't need it as we have ext now
22
- end
23
- end
24
-
25
- def update_url(attrs, args='', opts={})
26
- format = opts['format']
27
- attrs.ext = format if format
28
- end
29
-
30
- end
31
- end
32
- end
33
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dragonfly::ImageMagick::Generators::Convert do
4
- let (:generator) { Dragonfly::ImageMagick::Generators::Convert.new }
5
- let (:app) { test_app }
6
- let (:image) { Dragonfly::Content.new(app) }
7
-
8
- describe "calling convert" do
9
- before(:each) do
10
- generator.call(image, "-size 1x1 xc:white", 'png')
11
- end
12
- it {image.should have_width(1)}
13
- it {image.should have_height(1)}
14
- it {image.should have_format('png')}
15
- it {image.meta.should == {'format' => 'png'}}
16
- end
17
-
18
- end
19
-
@@ -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 in the name" do
33
- image = Dragonfly::Content.new(app, SAMPLES_DIR.join('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