dragonfly 1.1.1 → 1.1.2
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/.travis.yml +3 -2
- data/History.md +9 -0
- data/README.md +1 -1
- data/lib/dragonfly/content.rb +1 -1
- data/lib/dragonfly/file_data_store.rb +1 -1
- data/lib/dragonfly/job/fetch_url.rb +13 -5
- data/lib/dragonfly/temp_object.rb +13 -13
- data/lib/dragonfly/version.rb +1 -1
- data/spec/dragonfly/content_spec.rb +14 -5
- data/spec/dragonfly/image_magick/processors/convert_spec.rb +5 -5
- data/spec/dragonfly/job/fetch_url_spec.rb +12 -0
- data/spec/support/simple_matchers.rb +1 -1
- metadata +2 -3
- data/samples/memo.pdf +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 785986a8487e1cb1e971e16b2eb88dc51794d490
|
4
|
+
data.tar.gz: e76af75be5d2f6a224a042ab4f6b53dd8de93e5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 528e4445092921b2c590cf787c6a23aa1a0c3f912ae9bea19416f60672605693735d33d0c6f709334c68555b087afeb7b72bfd7666187c3745eecc9fb891d27f
|
7
|
+
data.tar.gz: c814aa4308afd5bb698c3e2f61605ffe6650d244fe8fbe3d84b843cf266c4e5ad9ea062d0bf0195b0856f758b213331e1d5ee9f4f1349fcd9dcd63710dcf0e8d
|
data/.travis.yml
CHANGED
data/History.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.1.2 (2017-05-06)
|
2
|
+
===================
|
3
|
+
Fixes
|
4
|
+
-----
|
5
|
+
- Allow relative redirect urls in `fetch_url` (zorec)
|
6
|
+
- Fixed Forwardable deprecation warnings (neodude)
|
7
|
+
- Fixed incorrect detection of empty directories in ruby 2.4 (yuszuv)
|
8
|
+
- Store content type in meta if it's available so we don't lose information (Lukas Svoboda)
|
9
|
+
|
1
10
|
1.1.1 (2016-10-26)
|
2
11
|
===================
|
3
12
|
Features
|
data/README.md
CHANGED
data/lib/dragonfly/content.rb
CHANGED
@@ -43,8 +43,8 @@ module Dragonfly
|
|
43
43
|
if data_uri?
|
44
44
|
update_from_data_uri
|
45
45
|
else
|
46
|
-
|
47
|
-
job.content.update(
|
46
|
+
response = get_following_redirects(url)
|
47
|
+
job.content.update(response.body || "", 'name' => filename, 'mime_type' => response.content_type)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -54,8 +54,9 @@ module Dragonfly
|
|
54
54
|
raise TooManyRedirects, "url #{url} redirected too many times" if redirect_limit == 0
|
55
55
|
response = get(url)
|
56
56
|
case response
|
57
|
-
when Net::HTTPSuccess then response
|
58
|
-
when Net::HTTPRedirection then
|
57
|
+
when Net::HTTPSuccess then response
|
58
|
+
when Net::HTTPRedirection then
|
59
|
+
get_following_redirects(redirect_url(url, response['location']), redirect_limit-1)
|
59
60
|
else
|
60
61
|
response.error!
|
61
62
|
end
|
@@ -83,7 +84,7 @@ module Dragonfly
|
|
83
84
|
if mime_type && b64_data
|
84
85
|
data = Base64.decode64(b64_data)
|
85
86
|
ext = app.ext_for(mime_type)
|
86
|
-
job.content.update(data, 'name' => "file.#{ext}")
|
87
|
+
job.content.update(data, 'name' => "file.#{ext}", 'mime_type' => mime_type)
|
87
88
|
else
|
88
89
|
raise CannotHandle, "fetch_url can only deal with base64-encoded data uris with specified content type"
|
89
90
|
end
|
@@ -102,6 +103,13 @@ module Dragonfly
|
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
106
|
+
def redirect_url(current_url, following_url)
|
107
|
+
redirect_url = URI.parse(following_url)
|
108
|
+
if redirect_url.relative?
|
109
|
+
redirect_url = URI::join(current_url, following_url)
|
110
|
+
end
|
111
|
+
redirect_url
|
112
|
+
end
|
105
113
|
end
|
106
114
|
end
|
107
115
|
end
|
@@ -84,6 +84,19 @@ module Dragonfly
|
|
84
84
|
@data ||= file{|f| f.read }
|
85
85
|
end
|
86
86
|
|
87
|
+
def tempfile
|
88
|
+
raise Closed, "can't read from tempfile as TempObject has been closed" if closed?
|
89
|
+
@tempfile ||= begin
|
90
|
+
case
|
91
|
+
when @data
|
92
|
+
@tempfile = Utils.new_tempfile(ext, @data)
|
93
|
+
when @pathname
|
94
|
+
@tempfile = copy_to_tempfile(@pathname.expand_path)
|
95
|
+
end
|
96
|
+
@tempfile
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
87
100
|
def file(&block)
|
88
101
|
f = tempfile.open
|
89
102
|
tempfile.binmode
|
@@ -174,19 +187,6 @@ module Dragonfly
|
|
174
187
|
|
175
188
|
private
|
176
189
|
|
177
|
-
def tempfile
|
178
|
-
raise Closed, "can't read from tempfile as TempObject has been closed" if closed?
|
179
|
-
@tempfile ||= begin
|
180
|
-
case
|
181
|
-
when @data
|
182
|
-
@tempfile = Utils.new_tempfile(ext, @data)
|
183
|
-
when @pathname
|
184
|
-
@tempfile = copy_to_tempfile(@pathname.expand_path)
|
185
|
-
end
|
186
|
-
@tempfile
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
190
|
def block_size
|
191
191
|
8192
|
192
192
|
end
|
data/lib/dragonfly/version.rb
CHANGED
@@ -67,11 +67,20 @@ describe Dragonfly::Content do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "mime_type" do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
context "when mime_type is stored in meta" do
|
71
|
+
it "takes it form meta" do
|
72
|
+
content.name = "thing.png"
|
73
|
+
content.meta.update("mime_type" => "text/html")
|
74
|
+
content.mime_type.should == "text/html"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
context "when mime_type is not stored in meta" do
|
78
|
+
it "takes it from the extension" do
|
79
|
+
content.name = "thing"
|
80
|
+
content.mime_type.should == "application/octet-stream"
|
81
|
+
content.name = "thing.png"
|
82
|
+
content.mime_type.should == "image/png"
|
83
|
+
end
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
@@ -8,7 +8,6 @@ describe Dragonfly::ImageMagick::Processors::Convert do
|
|
8
8
|
|
9
9
|
let(:app){ test_app }
|
10
10
|
let(:image){ sample_content('beach.png') } # 280x355
|
11
|
-
let(:pdf){ sample_content('memo.pdf') }
|
12
11
|
let(:processor){ Dragonfly::ImageMagick::Processors::Convert.new }
|
13
12
|
|
14
13
|
it "should allow for general convert commands" do
|
@@ -55,11 +54,12 @@ describe Dragonfly::ImageMagick::Processors::Convert do
|
|
55
54
|
end
|
56
55
|
|
57
56
|
it "accepts input arguments for convert commands" do
|
58
|
-
|
59
|
-
processor.call(
|
60
|
-
processor.call(
|
57
|
+
image2 = image.clone
|
58
|
+
processor.call(image, '')
|
59
|
+
processor.call(image2, '', 'input_args' => '-extract 50x50+10+10')
|
61
60
|
|
62
|
-
|
61
|
+
image.should_not equal_image(image2)
|
62
|
+
image2.should have_width(50)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "allows converting using specific delegates" do
|
@@ -19,6 +19,12 @@ describe Dragonfly::Job::FetchUrl do
|
|
19
19
|
job.data.should == "result!"
|
20
20
|
end
|
21
21
|
|
22
|
+
it "should set the mime_type when returned by the request" do
|
23
|
+
stub_request(:get, %r{http://thing\.com.*}).to_return(:body => '<ok />', :headers => {'Content-Type' => 'text/html'})
|
24
|
+
expect(job.fetch_url('http://place.com').mime_type).to eq('application/octet-stream')
|
25
|
+
expect(job.fetch_url('http://thing.com').mime_type).to eq('text/html')
|
26
|
+
end
|
27
|
+
|
22
28
|
it "should default to http" do
|
23
29
|
job.fetch_url!('place.com')
|
24
30
|
job.data.should == "result!"
|
@@ -140,6 +146,12 @@ describe Dragonfly::Job::FetchUrl do
|
|
140
146
|
job.fetch_url('redirectme.com').apply
|
141
147
|
}.to raise_error(Dragonfly::Job::FetchUrl::TooManyRedirects)
|
142
148
|
end
|
149
|
+
|
150
|
+
it "follows relative responses" do
|
151
|
+
stub_request(:get, "redirectme.com").to_return(:status => 302, :headers => {'Location' => 'relative-path.html'})
|
152
|
+
stub_request(:get, "redirectme.com/relative-path.html").to_return(:body => "OK!")
|
153
|
+
job.fetch_url('redirectme.com').data.should == 'OK!'
|
154
|
+
end
|
143
155
|
end
|
144
156
|
|
145
157
|
describe "data uris" do
|
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.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -178,7 +178,6 @@ files:
|
|
178
178
|
- samples/beach.png
|
179
179
|
- samples/egg.png
|
180
180
|
- samples/gif.gif
|
181
|
-
- samples/memo.pdf
|
182
181
|
- samples/round.gif
|
183
182
|
- samples/sample.docx
|
184
183
|
- samples/taj.jpg
|
data/samples/memo.pdf
DELETED
Binary file
|