shrine 2.10.0 → 2.10.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of shrine might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5820e9c06eec70c66a52ff3cc099847651076e2e
4
- data.tar.gz: 6328bfb5edf7cb31a0e6b8ebb8a0815483451314
3
+ metadata.gz: 3ed9afc9d88a2781a07ccb93dabbcc8623149d58
4
+ data.tar.gz: b4f2759ea268ec45cd2d04221b5715bf27daf678
5
5
  SHA512:
6
- metadata.gz: 41411c21937516fb928e686378c8b2d16a3a30ae9f1bf15c47010863a7d39c676c6a9ded87cad0a48f95108e1cc6dfc7e3cfab5363d79e73f3f14505fa05a9b9
7
- data.tar.gz: 832a9a41216b0c2406b327bbb442aa0f82af69973afef87f7ee99abcc72ddde3d5634330f8b8cb9fc123589a171fd61cd2754079999d2e0d5d643f9ae493fe44
6
+ metadata.gz: 162a3fa939f7462da506c18abab20900fc5dc464cb59e9d200ad7d585e366255ac88f27235814e90e8ffbc660ce6e023ce49240fca755552133883e2a15adfc6
7
+ data.tar.gz: 51d52ca48da06898697bf4a3c2b35ce3c34518ad38a878b5aad9519b4c9755c14e2b90ffee188e6543b62bbf64f64f71bc6a6dbc2c6285d82605f033a826e4ac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.10.1 (2018-04-02)
2
+
3
+ * Correctly determine MIME type from extension of empty files (@janko-m)
4
+
1
5
  ## 2.10.0 (2018-03-28)
2
6
 
3
7
  * Add `:fastimage` analyzer to `determine_mime_type` plugin (@mokolabs)
@@ -155,8 +155,6 @@ class Shrine
155
155
  end
156
156
 
157
157
  def call(io)
158
- return nil if io.eof? # empty file doesn't have a MIME type
159
-
160
158
  mime_type = send(:"extract_with_#{@tool}", io)
161
159
  io.rewind
162
160
 
@@ -180,7 +178,8 @@ class Shrine
180
178
  raise Error, stderr.read unless status.success?
181
179
  $stderr.print(stderr.read)
182
180
 
183
- stdout.read.strip
181
+ mime_type = stdout.read.strip
182
+ mime_type unless mime_type == "application/x-empty"
184
183
  end
185
184
  rescue Errno::ENOENT
186
185
  raise Error, "The `file` command-line tool is not installed"
@@ -197,7 +196,8 @@ class Shrine
197
196
  require "filemagic"
198
197
 
199
198
  FileMagic.open(FileMagic::MAGIC_MIME_TYPE) do |filemagic|
200
- filemagic.buffer(io.read(MAGIC_NUMBER))
199
+ mime_type = filemagic.buffer(io.read(MAGIC_NUMBER).to_s)
200
+ mime_type unless mime_type == "application/x-empty"
201
201
  end
202
202
  end
203
203
 
@@ -211,6 +211,8 @@ class Shrine
211
211
  def extract_with_marcel(io)
212
212
  require "marcel"
213
213
 
214
+ return nil if io.eof? # marcel returns "application/octet-stream" for empty files
215
+
214
216
  Marcel::MimeType.for(io)
215
217
  end
216
218
 
@@ -8,7 +8,7 @@ class Shrine
8
8
  module VERSION
9
9
  MAJOR = 2
10
10
  MINOR = 10
11
- TINY = 0
11
+ TINY = 1
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down