paperclip_utils 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paperclip_utils/version.rb +1 -1
- data/lib/paperclip_utils.rb +22 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc2d7df880cd7513a2e1c9c4f9c4fc4f1c3ad8f0
|
4
|
+
data.tar.gz: aaba3534a035c91068611bb136237b60fef2002f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80067787d5af63a54e44df1bf3077b27cad12e20f882d314f22808478c96e1a3f10a178f8c395d809f0261a892334280c349fcef212730a2e9db3c7610826049
|
7
|
+
data.tar.gz: 6b2e4e1a481186e4ab6a4bcbc20283b1c740ceb087a75e4ff1e75dd520e5d1225b93b3c4e8b6de0a4d5c248dbc851f51cf020e9f1ac722277b13309d4b5c2974
|
data/lib/paperclip_utils.rb
CHANGED
@@ -3,15 +3,29 @@ require 'paperclip_processors/ghostscript.rb'
|
|
3
3
|
|
4
4
|
module Paperclip
|
5
5
|
class Utils
|
6
|
-
def self.get_processors(content_type, to_processors
|
7
|
-
if to_processors
|
8
|
-
|
9
|
-
|
6
|
+
def self.get_processors(content_type, options={to_processors: [:thumbnail], fallback_processors: [], allowed_content_types: ALLOWED_CONTENT_TYPES})
|
7
|
+
if options[:to_processors]
|
8
|
+
if options[:to_processors].is_a?(Array)
|
9
|
+
processors = options[:to_processors]
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
if processors.include?(:thumbnail) && content_type == 'application/pdf' && !processors.include?(:ghostscript)
|
12
|
+
processors.unshift(:ghostscript)
|
13
|
+
end
|
14
|
+
elsif options[:to_processors].is_a?(Symbol)
|
15
|
+
processors = [options[:to_processors]]
|
16
|
+
else
|
17
|
+
processors = []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if options[:fallback_processors] != []
|
22
|
+
if options[:fallback_processors].is_a?(Array)
|
23
|
+
fallback_processors = options[:fallback_processors]
|
24
|
+
elsif options[:fallback_processors].is_a?(Symbol)
|
25
|
+
fallback_processors = [options[:fallback_processors]]
|
26
|
+
else
|
27
|
+
fallback_processors = []
|
28
|
+
end
|
15
29
|
end
|
16
30
|
|
17
31
|
return (allowed_content_types.include?(content_type) ? processors : fallback_processors)
|