smartthumbs 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,5 @@
1
1
  class ThumbsController < ApplicationController
2
2
 
3
- require 'RMagick'
4
- include Magick
5
-
6
3
  def deliver_crop
7
4
  klass, format, id = parse_params
8
5
 
@@ -1,11 +1,10 @@
1
1
  module Smartthumbs
2
2
 
3
3
  module Thumbable
4
- require 'RMagick'
5
- include Magick
6
4
 
7
5
  # return the rmagick instance
8
6
  def rmagick_img
7
+ return @rmagick_img unless @rmagick_img.blank?
9
8
  if self.class.st_config[:blob].present?
10
9
  @rmagick_img ||= Magick::ImageList.new.from_blob(
11
10
  self.send(self.class.st_config[:blob])
@@ -17,6 +16,12 @@ module Smartthumbs
17
16
  else
18
17
  raise "No thumb source defined. You have to define neither :blob or :file"
19
18
  end
19
+
20
+ if self.class.st_config[:before_resize].present? && self.respond_to?(self.class.st_config[:before_resize].to_sym)
21
+ self.send(self.class.st_config[:before_resize].to_sym)
22
+ end
23
+ @rmagick_img
24
+
20
25
  end
21
26
 
22
27
  # returns the specific format-array for the key f
@@ -27,7 +32,11 @@ module Smartthumbs
27
32
  if self.class.st_config[:formats].respond_to?(:call)
28
33
  self.class.st_config[:formats].call(f.to_sym)
29
34
  else
30
- self.class.st_config[:formats][f]
35
+ if self.class.st_config[:formats][f].is_a?(Symbol)
36
+ self.send(self.class.st_config[:formats][f])
37
+ else
38
+ self.class.st_config[:formats][f]
39
+ end
31
40
  end
32
41
  end
33
42
 
@@ -1,3 +1,3 @@
1
1
  module Smartthumbs
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartthumbs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alexander Pauly
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-01 00:00:00 +01:00
18
+ date: 2011-03-26 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency