dragonfly 0.5.0 → 0.5.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dragonfly}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Evans"]
@@ -44,12 +44,7 @@ Each method takes the temp_object, and the (optional) processing options hash as
44
44
  end
45
45
 
46
46
  app = Dragonfly::App[:images]
47
-
48
47
  app.register_processor(MyProcessor)
49
-
50
- temp_object = app.create_object(File.new('path/to/image.png'))
51
-
52
- temp_object.process(:black_and_white, :some => 'option')
53
48
 
54
49
  You can register multiple processors.
55
50
 
@@ -59,6 +54,11 @@ As with analysers and encoders, if the processor is {Dragonfly::Configurable con
59
54
  p.some_attribute = 'hello'
60
55
  end
61
56
 
57
+ Your new processing method is now available to use:
58
+
59
+ temp_object = app.create_object(File.new('path/to/image.png'))
60
+ temp_object.process(:black_and_white, :some => 'option') # processed temp_object
61
+
62
62
  To get the url for content processed by your custom processor, the long way is using something like:
63
63
 
64
64
  app.url_for('some_uid',
@@ -79,7 +79,7 @@ However, this could soon get tedious if using more than once, so the best thing
79
79
  So in your configuration of the Dragonfly app (or in an initializer if using 'dragonfly/rails/images') you
80
80
  could do something like:
81
81
 
82
- Dragonfly::App[:images].parameters.add_shortcut(/^bw-(\d*x\d*)$/) do |string, match_data|
82
+ app.parameters.add_shortcut(/^bw-(\d*x\d*)$/) do |string, match_data|
83
83
  {
84
84
  :processing_method => :black_and_white,
85
85
  :processing_options => {:size => match_data[1]},
@@ -7,13 +7,18 @@ module Dragonfly
7
7
 
8
8
  configurable_attr :file_command, "file"
9
9
  configurable_attr :use_filesystem, false
10
+ configurable_attr :num_bytes_to_check, 255
10
11
 
11
12
  def mime_type(temp_object)
12
13
  if use_filesystem
13
14
  `#{file_command} -b --mime '#{temp_object.path}'`
14
15
  else
15
16
  IO.popen("#{file_command} -b --mime -", 'r+') do |io|
16
- io.write temp_object.data
17
+ if num_bytes_to_check
18
+ io.write temp_object.data[0, num_bytes_to_check]
19
+ else
20
+ io.write temp_object.data
21
+ end
17
22
  io.close_write
18
23
  io.read
19
24
  end
@@ -36,6 +36,20 @@ describe Dragonfly::Analysis::FileCommandAnalyser do
36
36
  @analyser.mime_type(@temp_object)
37
37
  @temp_object.instance_eval{@tempfile}.should be_nil
38
38
  end
39
+
40
+ {
41
+ :jpg => 'image/jpeg',
42
+ :png => 'image/png',
43
+ :gif => 'image/gif',
44
+ :tif => 'image/tiff'
45
+ }.each do |format, mime_type|
46
+ it "should work properly (without a broken pipe error) for big files of format #{format}" do
47
+ processor = Dragonfly::Processing::RMagickProcessor.new
48
+ temp_object = Dragonfly::TempObject.new(processor.generate(1000, 1000, format))
49
+ @analyser.mime_type(temp_object).should == mime_type
50
+ end
51
+ end
52
+
39
53
  end
40
54
 
41
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Evans