lib/mini_magick.rb in mini_magick-3.8.0 vs lib/mini_magick.rb in mini_magick-3.8.1
- old
+ new
@@ -1,10 +1,5 @@
-require 'tempfile'
-require 'subexec'
-require 'stringio'
-require 'pathname'
-require 'shellwords'
require 'mini_magick/command_builder'
require 'mini_magick/errors'
require 'mini_magick/image'
require 'mini_magick/utilities'
@@ -14,27 +9,24 @@
class << self
attr_accessor :processor
attr_accessor :processor_path
attr_accessor :timeout
+ attr_accessor :debug
attr_accessor :validate_on_create
attr_accessor :validate_on_write
##
- # Tries to detect the current processor based if any of the processors exist.
- # Mogrify have precedence over gm by default.
+ # Tries to detect the current processor based if any of the processors
+ # exist. Mogrify have precedence over gm by default.
#
# === Returns
- # * [String] The detected procesor
- def choose_processor
- self.processor = if MiniMagick::Utilities.which('mogrify')
- :mogrify
- elsif MiniMagick::Utilities.which('gm')
- :gm
- else
- nil
- end
+ # * [Symbol] The detected procesor
+ def processor
+ @processor ||= [:mogrify, :gm].detect do |processor|
+ MiniMagick::Utilities.which(processor.to_s)
+ end
end
##
# Discovers the imagemagick version based on mogrify's output.
#
@@ -61,29 +53,23 @@
def valid_version_installed?
image_magick_version >= minimum_image_magick_version
end
##
- # Picks the right processor if it isn't set and returns whether it's mogrify or not.
+ # Checks whether the current processory is mogrify.
#
# === Returns
# * [Boolean]
def mogrify?
- choose_processor if processor.nil?
-
- return processor.to_s.downcase.to_sym == :mogrify unless processor.nil?
- false
+ processor && processor.to_sym == :mogrify
end
##
- # Picks the right processor if it isn't set and returns whether it's graphicsmagick or not.
+ # Checks whether the current processor is graphicsmagick.
#
# === Returns
# * [Boolean]
def gm?
- choose_processor if processor.nil?
-
- return processor.to_s.downcase.to_sym == :gm unless processor.nil?
- false
+ processor && processor.to_sym == :gm
end
end
end