paperclip_utils 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/paperclip_utils.rb +14 -20
- data/lib/paperclip_utils/version.rb +1 -1
- 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: 43be69395250e10d0d52dc24580b9c9f3d6ff4f3
|
4
|
+
data.tar.gz: 63318882fbdeaedeece02d331a36597431823670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df486426f658553cd33b7dd12d93684f689908b98eab73e22998da5f362a98d75c540d178110e9f122bf8f6035dc2550c448f840b9f3100bff3604bf568400d
|
7
|
+
data.tar.gz: db3976453fb9d532accd13698a61e8c78a706f29ede4c3726c44a2bad5d7a926023b24abc6b682413bb744c5475a31c82a1af9bb7dbcf43786e7d500d6023e81
|
data/lib/paperclip_utils.rb
CHANGED
@@ -3,26 +3,26 @@ require 'paperclip_processors/ghostscript.rb'
|
|
3
3
|
|
4
4
|
module Paperclip
|
5
5
|
class Utils
|
6
|
-
def self.get_processors(content_type,
|
7
|
-
if
|
8
|
-
if
|
9
|
-
processors =
|
6
|
+
def self.get_processors(content_type, to_processors: [:thumbnail], fallback_processors: [], allowed_content_types: ALLOWED_CONTENT_TYPES)
|
7
|
+
if to_processors
|
8
|
+
if to_processors.is_a?(Array)
|
9
|
+
processors = to_processors
|
10
10
|
|
11
11
|
if processors.include?(:thumbnail) && content_type == 'application/pdf' && !processors.include?(:ghostscript)
|
12
12
|
processors.unshift(:ghostscript)
|
13
13
|
end
|
14
|
-
elsif
|
15
|
-
processors = [
|
14
|
+
elsif to_processors.is_a?(Symbol)
|
15
|
+
processors = [to_processors]
|
16
16
|
else
|
17
17
|
processors = []
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
if
|
22
|
-
if
|
23
|
-
fallback_processors =
|
24
|
-
elsif
|
25
|
-
fallback_processors = [
|
21
|
+
if fallback_processors != []
|
22
|
+
if fallback_processors.is_a?(Array)
|
23
|
+
fallback_processors = fallback_processors
|
24
|
+
elsif fallback_processors.is_a?(Symbol)
|
25
|
+
fallback_processors = [fallback_processors]
|
26
26
|
else
|
27
27
|
fallback_processors = []
|
28
28
|
end
|
@@ -31,9 +31,7 @@ module Paperclip
|
|
31
31
|
return (allowed_content_types.include?(content_type) ? processors : fallback_processors)
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.get_styles(content_type,
|
35
|
-
to_styles = options[:to_styles]
|
36
|
-
|
34
|
+
def self.get_styles(content_type, to_styles: {preview: "800x600>", thumb: "100x100>"}, fallback_styles: {}, allowed_content_types: ALLOWED_CONTENT_TYPES)
|
37
35
|
if to_styles
|
38
36
|
if ['application/pdf','image/tiff','image/tif','image/x-tiff'].include?(content_type)
|
39
37
|
to_styles.each do |k,v|
|
@@ -41,13 +39,9 @@ module Paperclip
|
|
41
39
|
end
|
42
40
|
end
|
43
41
|
else
|
44
|
-
|
45
|
-
to_styles = {preview: ["800x600>", :jpg], thumb: ["100x100>", :jpg]}
|
46
|
-
else
|
47
|
-
to_styles = {preview: "800x600>", thumb: "100x100>"}
|
48
|
-
end
|
42
|
+
to_styles = []
|
49
43
|
end
|
50
|
-
return (
|
44
|
+
return (allowed_content_types.include?(content_type) ? to_styles : fallback_styles)
|
51
45
|
end
|
52
46
|
|
53
47
|
ALLOWED_CONTENT_TYPES = ['application/pdf', 'image/png', 'image/x-png', 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/tif', 'image/tiff', 'image/x-tiff']
|