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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4918846aff69a7cb7483d21babadf9f74d674d91
4
- data.tar.gz: e015447812e545b186c422b355de1916fc474201
3
+ metadata.gz: 785986a8487e1cb1e971e16b2eb88dc51794d490
4
+ data.tar.gz: e76af75be5d2f6a224a042ab4f6b53dd8de93e5d
5
5
  SHA512:
6
- metadata.gz: 5642ce50bb25ffd86a4960be6d69e011d285c749e54c572a2977399775ce7e30f9634bfe72bae98f5f2d1cb3e24ba860e6e711457a288b02f920a184142123c9
7
- data.tar.gz: c665ecd2f6c045a668abc45197900ca9a4fd75c3028dcf7085cc6cf1799d82c3c882d97d48eb11f792dfc59947143198ad918b60ee92155a981e5f1d40904dd9
6
+ metadata.gz: 528e4445092921b2c590cf787c6a23aa1a0c3f912ae9bea19416f60672605693735d33d0c6f709334c68555b087afeb7b72bfd7666187c3745eecc9fb891d27f
7
+ data.tar.gz: c814aa4308afd5bb698c3e2f61605ffe6650d244fe8fbe3d84b843cf266c4e5ad9ea062d0bf0195b0856f758b213331e1d5ee9f4f1349fcd9dcd63710dcf0e8d
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - "1.9.3"
4
- - "2.0.0"
4
+ - "2.0"
5
5
  - "2.1"
6
6
  - "2.2"
7
- - "2.3.0"
7
+ - "2.3"
8
+ - "2.4"
8
9
  - "jruby"
9
10
  script: bundle exec rspec spec
10
11
  before_install:
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
@@ -44,7 +44,7 @@ Installation
44
44
 
45
45
  or in your Gemfile
46
46
  ```ruby
47
- gem 'dragonfly', '~> 1.1.1'
47
+ gem 'dragonfly', '~> 1.1.2'
48
48
  ```
49
49
 
50
50
  Require with
@@ -79,7 +79,7 @@ module Dragonfly
79
79
  # @example "image/jpeg"
80
80
  # @return [String]
81
81
  def mime_type
82
- app.mime_type_for(ext)
82
+ meta['mime_type'] || app.mime_type_for(ext)
83
83
  end
84
84
 
85
85
  # Set the content using a pre-registered generator
@@ -168,7 +168,7 @@ module Dragonfly
168
168
  end
169
169
 
170
170
  def directory_empty?(path)
171
- Dir.entries(path) == ['.','..']
171
+ Dir.entries(path).sort == ['.','..'].sort
172
172
  end
173
173
 
174
174
  def root_path?(dir)
@@ -43,8 +43,8 @@ module Dragonfly
43
43
  if data_uri?
44
44
  update_from_data_uri
45
45
  else
46
- data = get_following_redirects(url)
47
- job.content.update(data, 'name' => filename)
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.body || ""
58
- when Net::HTTPRedirection then get_following_redirects(response['location'], redirect_limit-1)
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
@@ -1,3 +1,3 @@
1
1
  module Dragonfly
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -67,11 +67,20 @@ describe Dragonfly::Content do
67
67
  end
68
68
 
69
69
  describe "mime_type" do
70
- it "takes it from the extension" do
71
- content.name = "thing"
72
- content.mime_type.should == "application/octet-stream"
73
- content.name = "thing.png"
74
- content.mime_type.should == "image/png"
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
- pdf2 = pdf.clone
59
- processor.call(pdf, '-scale 85x110', 'format' => 'png')
60
- processor.call(pdf2, '-scale 85x110', 'format' => 'png', 'input_args' => '-density 150')
57
+ image2 = image.clone
58
+ processor.call(image, '')
59
+ processor.call(image2, '', 'input_args' => '-extract 50x50+10+10')
61
60
 
62
- pdf.should_not equal_image(pdf2)
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
@@ -9,7 +9,7 @@ end
9
9
 
10
10
  RSpec::Matchers.define :be_an_empty_directory do
11
11
  match do |given|
12
- !!ENV['TRAVIS'] || (Dir.entries(given) == ['.','..'])
12
+ !!ENV['TRAVIS'] || (Dir.entries(given).sort == ['.','..'].sort)
13
13
  end
14
14
  end
15
15
 
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.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: 2016-10-26 00:00:00.000000000 Z
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
Binary file