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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a56dbe7fd83b32d54e8e6a1d27c290c18bce57b
4
- data.tar.gz: d458ec5792f1be88c377c635e91d9555ec1488fb
3
+ metadata.gz: fc2d7df880cd7513a2e1c9c4f9c4fc4f1c3ad8f0
4
+ data.tar.gz: aaba3534a035c91068611bb136237b60fef2002f
5
5
  SHA512:
6
- metadata.gz: 93ab00047ac3dfa0c37887325be198c924640037ec221c752e6ab92c5a43000d9a3e7f6657a5841b7fe042ae44329072bd664f50bc1fceb032aa2ec2100c2f9d
7
- data.tar.gz: 5013432814851cab2c89dde719a355e0155b1a54d683aadb9a22fa6a67a8acbc9978037f840deb6c91a5509e3bb0522f916347f7fdf5521d95e5c40204bc54e3
6
+ metadata.gz: 80067787d5af63a54e44df1bf3077b27cad12e20f882d314f22808478c96e1a3f10a178f8c395d809f0261a892334280c349fcef212730a2e9db3c7610826049
7
+ data.tar.gz: 6b2e4e1a481186e4ab6a4bcbc20283b1c740ceb087a75e4ff1e75dd520e5d1225b93b3c4e8b6de0a4d5c248dbc851f51cf020e9f1ac722277b13309d4b5c2974
@@ -1,3 +1,3 @@
1
1
  module PaperclipUtils
2
- VERSION = '1.1.2'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -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=nil, fallback_processors=[], allowed_content_types=ALLOWED_CONTENT_TYPES)
7
- if to_processors && to_processors.is_a?(Array)
8
- processors = to_processors
9
- end
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
- if content_type == 'application/pdf'
12
- processors ||= [:ghostscript, :thumbnail]
13
- else
14
- processors ||= [:thumbnail]
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger