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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc2d7df880cd7513a2e1c9c4f9c4fc4f1c3ad8f0
4
- data.tar.gz: aaba3534a035c91068611bb136237b60fef2002f
3
+ metadata.gz: 43be69395250e10d0d52dc24580b9c9f3d6ff4f3
4
+ data.tar.gz: 63318882fbdeaedeece02d331a36597431823670
5
5
  SHA512:
6
- metadata.gz: 80067787d5af63a54e44df1bf3077b27cad12e20f882d314f22808478c96e1a3f10a178f8c395d809f0261a892334280c349fcef212730a2e9db3c7610826049
7
- data.tar.gz: 6b2e4e1a481186e4ab6a4bcbc20283b1c740ceb087a75e4ff1e75dd520e5d1225b93b3c4e8b6de0a4d5c248dbc851f51cf020e9f1ac722277b13309d4b5c2974
6
+ metadata.gz: 9df486426f658553cd33b7dd12d93684f689908b98eab73e22998da5f362a98d75c540d178110e9f122bf8f6035dc2550c448f840b9f3100bff3604bf568400d
7
+ data.tar.gz: db3976453fb9d532accd13698a61e8c78a706f29ede4c3726c44a2bad5d7a926023b24abc6b682413bb744c5475a31c82a1af9bb7dbcf43786e7d500d6023e81
@@ -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, 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]
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 options[:to_processors].is_a?(Symbol)
15
- processors = [options[:to_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 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]]
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, options={to_styles: nil, fallback_styles: {}, allowed_content_types: ALLOWED_CONTENT_TYPES})
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
- if ['application/pdf','image/tiff','image/tif','image/x-tiff'].include?(content_type)
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 (options[:allowed_content_types].include?(content_type) ? to_styles : options[:fallback_styles])
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']
@@ -1,3 +1,3 @@
1
1
  module PaperclipUtils
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger