dragonfly 0.1.4 → 0.1.5

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.1.4
1
+ 0.1.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dragonfly-rails}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
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"]
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dragonfly}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
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"]
@@ -97,7 +97,7 @@ module Dragonfly
97
97
  def magic_attributes
98
98
  parent_model.class.column_names.select { |name|
99
99
  name =~ /^#{attribute_name}_(.+)$/ &&
100
- (analyser.has_analysis_method?($1) || %w(size ext).include?($1))
100
+ (analyser.has_analysis_method?($1) || %w(size name ext).include?($1))
101
101
  }
102
102
  end
103
103
 
@@ -100,7 +100,7 @@ module Dragonfly
100
100
  include Configurable
101
101
 
102
102
  configurable_attr :datastore do DataStorage::FileDataStore.new end
103
- configurable_attr :encoder do Encoding::Base.new end
103
+ configurable_attr :encoder do Encoding::TransparentEncoder.new end
104
104
  configurable_attr :log do Logger.new('/var/tmp/dragonfly.log') end
105
105
  configurable_attr :cache_duration, 3600*24*365 # Defaults to 1 year
106
106
  configurable_attr :fallback_mime_type, 'application/octet-stream'
@@ -30,8 +30,9 @@ module Dragonfly
30
30
  end
31
31
 
32
32
  def retrieve(uid)
33
- entries = Dir[absolute_storage_path(uid) + '*']
34
- raise DataNotFound if entries.empty?
33
+ pattern = "#{absolute_storage_path(uid)}*"
34
+ entries = Dir[pattern]
35
+ raise DataNotFound, "Couldn't find any files matching #{pattern}" if entries.empty?
35
36
  File.new(entries.first)
36
37
  rescue Errno::ENOENT => e
37
38
  raise DataNotFound, e.message
@@ -35,6 +35,7 @@ module Dragonfly
35
35
  end
36
36
 
37
37
  def url_to_parameters(path, query_string)
38
+ path = unescape(path)
38
39
  validate_format!(path)
39
40
  path = remove_path_prefix(path)
40
41
  query = parse_nested_query(query_string)
@@ -6,6 +6,7 @@ class MigrationForTest < ActiveRecord::Migration
6
6
  t.string :preview_image_uid
7
7
  t.string :preview_image_some_analyser_method
8
8
  t.integer :preview_image_size
9
+ t.string :preview_image_name
9
10
  t.string :preview_image_ext
10
11
  t.string :preview_image_blah_blah
11
12
  t.string :other_image_uid
@@ -401,6 +401,13 @@ describe Item do
401
401
  @item.preview_image = data
402
402
  @item.preview_image_ext.should == 'png'
403
403
  end
404
+
405
+ it "should store the original file name if it exists" do
406
+ data = 'jasdlkf sadjl'
407
+ data.stub!(:original_filename).and_return('hello.png')
408
+ @item.preview_image = data
409
+ @item.preview_image_name.should == 'hello.png'
410
+ end
404
411
 
405
412
  end
406
413
 
@@ -91,6 +91,12 @@ describe Dragonfly::UrlHandler do
91
91
  parameters.format.should == 'bean'
92
92
  end
93
93
 
94
+ it "should unescape any url-escaped characters" do
95
+ parameters = @url_handler.url_to_parameters('hello%20bean.jpg', 'm=whats%20up')
96
+ parameters.uid.should == 'hello bean'
97
+ parameters.processing_method.should == 'whats up'
98
+ end
99
+
94
100
  end
95
101
 
96
102
  describe "forming a url from parameters" do
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.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Evans