dragonfly 1.0.10 → 1.0.11

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13de1169904aec53779af0935d6a07ecd59fe6a5
4
- data.tar.gz: c5f99e7f5de7a1a7b93cbd93246e9737651f2c45
3
+ metadata.gz: 685e6116346b2a5b8853e643a5441cbcc7bce93d
4
+ data.tar.gz: 92c44ab44a26bab0e3423d6a3e5cade8b040d4d9
5
5
  SHA512:
6
- metadata.gz: 4852dbed8e8ef2cf0fbfab4c6eb93f9036315ce8e83d581cd00c12fefefdf7fc4b7b0e87107391e8c2b8ddad26503b64ecd63d1267a0eacc3d50033abde29859
7
- data.tar.gz: e4f00871e4aca9c56e424dec1ef41d77183b0d305eaae765ba199cd39ec04516b084ce421171c1aa91f546c59dbd1c5549d02456d6246925afc39fea537c8d12
6
+ metadata.gz: ce6ef849c48cbacf4468019988dc99fd10781f52b5689d5550ec55a21c7c6fdc2f560024cf0908eefbcc529b5d194f411a812e48522c3ec7e6a81e8dfb26ac07
7
+ data.tar.gz: 256a355a616ad042a832d00e8e99407953f4afe1b2f769071aa9cc1e8b7582d465fa1e53f60bf538ce21b30b6643d540878f786a66316ebdc85b38877d0edc9b
data/History.md CHANGED
@@ -1,3 +1,9 @@
1
+ 1.0.11 (2015-09-04)
2
+ ===================
3
+ Fixes
4
+ -----
5
+ - Make sure tempfiles are created with paths matching the meta name
6
+
1
7
  1.0.10 (2015-05-14)
2
8
  ===================
3
9
  Features
data/README.md CHANGED
@@ -44,7 +44,7 @@ Installation
44
44
 
45
45
  or in your Gemfile
46
46
  ```ruby
47
- gem 'dragonfly', '~> 1.0.10'
47
+ gem 'dragonfly', '~> 1.0.11'
48
48
  ```
49
49
 
50
50
  Require with
@@ -66,7 +66,7 @@ module Dragonfly
66
66
  # @example "beach.jpg"
67
67
  # @return [String]
68
68
  def name
69
- meta["name"] || temp_object.original_filename
69
+ meta["name"]
70
70
  end
71
71
 
72
72
  # @example
@@ -112,12 +112,12 @@ module Dragonfly
112
112
  # @param meta [Hash] - should be json-like, i.e. contain no types other than String, Number, Boolean
113
113
  # @return [Content] self
114
114
  def update(obj, meta=nil)
115
- self.temp_object = TempObject.new(obj)
116
- original_filename = temp_object.original_filename
117
- self.meta['name'] ||= original_filename if original_filename
115
+ meta ||= {}
116
+ self.temp_object = TempObject.new(obj, meta['name'])
117
+ self.meta['name'] ||= temp_object.name if temp_object.name
118
118
  clear_analyser_cache
119
119
  add_meta(obj.meta) if obj.respond_to?(:meta)
120
- add_meta(meta) if meta
120
+ add_meta(meta)
121
121
  self
122
122
  end
123
123
 
@@ -39,7 +39,7 @@ module Dragonfly
39
39
 
40
40
  # Instance Methods
41
41
 
42
- def initialize(obj)
42
+ def initialize(obj, name=nil)
43
43
  if obj.is_a? TempObject
44
44
  @data = obj.get_data
45
45
  @tempfile = obj.get_tempfile
@@ -62,19 +62,22 @@ module Dragonfly
62
62
 
63
63
  @tempfile.close if @tempfile
64
64
 
65
- # Original filename
66
- @original_filename = if obj.respond_to?(:original_filename)
65
+ # Name
66
+ @name = if name
67
+ name
68
+ elsif obj.respond_to?(:original_filename)
67
69
  obj.original_filename
68
70
  elsif @pathname
69
71
  @pathname.basename.to_s
70
72
  end
71
73
  end
72
74
 
73
- attr_reader :original_filename
75
+ attr_reader :name
74
76
 
75
77
  def ext
76
- name = original_filename
77
- name.split('.').last if name
78
+ if n = name
79
+ n.split('.').last
80
+ end
78
81
  end
79
82
 
80
83
  def data
@@ -1,3 +1,3 @@
1
1
  module Dragonfly
2
- VERSION = '1.0.10'
2
+ VERSION = '1.0.11'
3
3
  end
@@ -205,6 +205,13 @@ describe Dragonfly::Content do
205
205
  str.should == "asdf"
206
206
  end
207
207
 
208
+ describe "tempfile" do
209
+ it "uses the name for the file extension" do
210
+ content.update("ASDF", 'name' => 'asdf.txt')
211
+ expect(content.tempfile.path).to match(/\.txt$/)
212
+ end
213
+ end
214
+
208
215
  end
209
216
 
210
217
  describe "shell commands" do
@@ -368,33 +368,37 @@ describe Dragonfly::TempObject do
368
368
  it_should_behave_like "common behaviour"
369
369
  end
370
370
 
371
- describe "original_filename" do
371
+ describe "name" do
372
372
 
373
373
  before(:each) do
374
374
  @obj = new_tempfile
375
375
  end
376
376
 
377
- it "should set the original_filename if the initial object responds to 'original filename'" do
377
+ it "should set the name from the arg passed in" do
378
+ Dragonfly::TempObject.new(@obj, 'goof.ball').name.should == 'goof.ball'
379
+ end
380
+
381
+ it "should set the name if the initial object responds to 'original filename'" do
378
382
  def @obj.original_filename
379
383
  'jimmy.page'
380
384
  end
381
- Dragonfly::TempObject.new(@obj).original_filename.should == 'jimmy.page'
385
+ Dragonfly::TempObject.new(@obj).name.should == 'jimmy.page'
382
386
  end
383
387
 
384
388
  it "should not set the name if the initial object doesn't respond to 'original filename'" do
385
- Dragonfly::TempObject.new(@obj).original_filename.should be_nil
389
+ Dragonfly::TempObject.new(@obj).name.should be_nil
386
390
  end
387
391
 
388
392
  it "should set the name if the initial object is a file object" do
389
393
  file = File.new(SAMPLES_DIR.join('round.gif'))
390
394
  temp_object = Dragonfly::TempObject.new(file)
391
- temp_object.original_filename.should == 'round.gif'
395
+ temp_object.name.should == 'round.gif'
392
396
  end
393
397
 
394
398
  it "should set the name if the initial object is a pathname" do
395
399
  pathname = Pathname.new(SAMPLES_DIR + '/round.gif')
396
400
  temp_object = Dragonfly::TempObject.new(pathname)
397
- temp_object.original_filename.should == 'round.gif'
401
+ temp_object.name.should == 'round.gif'
398
402
  end
399
403
 
400
404
  end
@@ -407,8 +411,8 @@ describe Dragonfly::TempObject do
407
411
  temp_object.ext.should be_nil
408
412
  end
409
413
 
410
- it "uses original_filename if present" do
411
- temp_object.should_receive(:original_filename).and_return('some.thing.yo')
414
+ it "uses name if present" do
415
+ temp_object.should_receive(:name).and_return('some.thing.yo')
412
416
  temp_object.ext.should == 'yo'
413
417
  end
414
418
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-14 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack