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 +4 -4
- data/History.md +6 -0
- data/README.md +1 -1
- data/lib/dragonfly/content.rb +5 -5
- data/lib/dragonfly/temp_object.rb +9 -6
- data/lib/dragonfly/version.rb +1 -1
- data/spec/dragonfly/content_spec.rb +7 -0
- data/spec/dragonfly/temp_object_spec.rb +12 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 685e6116346b2a5b8853e643a5441cbcc7bce93d
|
4
|
+
data.tar.gz: 92c44ab44a26bab0e3423d6a3e5cade8b040d4d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce6ef849c48cbacf4468019988dc99fd10781f52b5689d5550ec55a21c7c6fdc2f560024cf0908eefbcc529b5d194f411a812e48522c3ec7e6a81e8dfb26ac07
|
7
|
+
data.tar.gz: 256a355a616ad042a832d00e8e99407953f4afe1b2f769071aa9cc1e8b7582d465fa1e53f60bf538ce21b30b6643d540878f786a66316ebdc85b38877d0edc9b
|
data/History.md
CHANGED
data/README.md
CHANGED
data/lib/dragonfly/content.rb
CHANGED
@@ -66,7 +66,7 @@ module Dragonfly
|
|
66
66
|
# @example "beach.jpg"
|
67
67
|
# @return [String]
|
68
68
|
def name
|
69
|
-
meta["name"]
|
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
|
-
|
116
|
-
|
117
|
-
self.meta['name'] ||=
|
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)
|
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
|
-
#
|
66
|
-
@
|
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 :
|
75
|
+
attr_reader :name
|
74
76
|
|
75
77
|
def ext
|
76
|
-
|
77
|
-
|
78
|
+
if n = name
|
79
|
+
n.split('.').last
|
80
|
+
end
|
78
81
|
end
|
79
82
|
|
80
83
|
def data
|
data/lib/dragonfly/version.rb
CHANGED
@@ -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 "
|
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
|
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).
|
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).
|
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.
|
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.
|
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
|
411
|
-
temp_object.should_receive(:
|
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.
|
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-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|