paperclip_utils 1.0.0 → 1.0.1

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: c2e8431736373ee20d366e80cb129f148d5946d5
4
- data.tar.gz: 687372cc91a547926e4c431090a25e68dc828af0
3
+ metadata.gz: 8a0899fdf1f5ba88dc1cfccaa2bc59adc756dcf2
4
+ data.tar.gz: ccfff2e9c8fa0aef4016c9c9c77ecd70aaeee525
5
5
  SHA512:
6
- metadata.gz: 8a874977b84c615e02bdb43ba62d909d83cc75132ab366910cdd2cd2b1929ad3aa707e428a03c5eb6f6293e8f1ae7a4abc811729bf85fb14748b743e192c0bb4
7
- data.tar.gz: 832a6971e7cd36294c54b85d716e9c3757c201293710078a9dd37c8d97c5624ec027283392621790dab1dcce7f7931e308372bd6b5e90693774e55df24c98f9c
6
+ metadata.gz: a1c6a70af2891e30bf6918a48e394a8fc570e9e2baa6ac258836520e04154458e9a2ca724336e913e43e39791a6447e4f684a6942b60a05d67aef08edbdb43f7
7
+ data.tar.gz: 99a0ff3c01000b824826813ab5f2953da145f0f339a4a23c65e6344f99028b9d19d078821bdce847f321afee78e97dd94a41987b6cb01892cd5db9bd4e2a0153
data/README.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # Paperclip Utils
2
2
  <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=VKY8YAWAS5XRQ&lc=CA&item_name=Weston%20Ganger&item_number=paperclip_utils&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest" target="_blank" title="Donate"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="Donate"/></a>
3
3
 
4
- Paperclip Utils adds a few helper methods to ActiveRecord::Base for easier dynamic processors and styles on your Paperclip file uploads
4
+ Paperclip Utils is a helper class for easier dynamic processors and styles on your Paperclip file uploads
5
5
 
6
6
 
7
7
  # Install
8
8
  ```ruby
9
9
  gem install paperclip_utils
10
+ ```
10
11
 
11
12
 
12
- ```
13
- Paperclip Utils contains the following methods to ActiveRecord::Base:
13
+ Paperclip Utils contains the following methods:
14
14
  ```ruby
15
- get_paperclip_processors(content_type, processors_if_allowed, fallback_processors, allowed_content_types)
15
+ Paperclip::Utils.get_processors(content_type, processors_if_allowed, fallback_processors, allowed_content_types)
16
16
 
17
- get_paperclip_styles(content_type, styles_if_allowed, fallback_processors, allowed_content_types)
17
+ Paperclip::Utils.get_styles(content_type, styles_if_allowed, fallback_processors, allowed_content_types)
18
18
  ```
19
19
 
20
20
 
@@ -22,8 +22,8 @@ get_paperclip_styles(content_type, styles_if_allowed, fallback_processors, allow
22
22
  ```ruby
23
23
  class Post < ActiveRecord::Base
24
24
  has_attachment :file,
25
- styles: lambda{|x| x.instance.get_paperclip_styles },
26
- processors: lambda{|x| {x.get_paperclip_processors },
25
+ styles: lambda{|x| Paperclip::Utils.get_styles(x.instance.file.content_type) },
26
+ processors: lambda{|x| Paperclip::Utils.get_processors(x.file.content_type) },
27
27
  path: "public/system/:class/:attachment/:id_partition/:style/:filename",
28
28
  url: "#{ActionController::Base.relative_url_root}/system/:class/:attachment/:id_partition/:style/:filename"
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module PaperclipUtils
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -3,7 +3,7 @@ require 'paperclip_processors/ghostscript.rb'
3
3
 
4
4
  module Paperclip
5
5
  class Utils
6
- def self.get_paperclip_processors(content_type, to_processors=nil, fallback_processors=[], allowed_content_types=PAPERCLIP_UTILS_ALLOWED_CONTENT_TYPES)
6
+ def self.get_processors(content_type, to_processors=nil, fallback_processors=[], allowed_content_types=ALLOWED_CONTENT_TYPES)
7
7
  if to_processors && to_processors.is_a?(Array)
8
8
  processors = to_processors
9
9
  end
@@ -17,10 +17,10 @@ module Paperclip
17
17
  return (allowed_content_types.include?(content_type) ? processors : fallback_processors)
18
18
  end
19
19
 
20
- def self.get_paperclip_styles(content_type, to_styles={preview: "800x600>", thumb: "100x100>"}, fallback_styles={}, allowed_content_types=PAPERCLIP_UTILS_ALLOWED_CONTENT_TYPES)
20
+ def self.get_styles(content_type, to_styles={preview: "800x600>", thumb: "100x100>"}, fallback_styles={}, allowed_content_types=ALLOWED_CONTENT_TYPES)
21
21
  return (allowed_content_types.include?(content_type) ? to_styles : fallback_styles)
22
22
  end
23
23
 
24
- PAPERCLIP_UTILS_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']
24
+ 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']
25
25
  end
26
26
  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.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger