lib/mini_magick/configuration.rb in mini_magick-4.9.3 vs lib/mini_magick/configuration.rb in mini_magick-4.9.4

- old
+ new

@@ -9,20 +9,16 @@ # [GraphicsMagick](http://www.graphicsmagick.org). # # @return [Symbol] `:imagemagick`, `:imagemagick7`, or `:graphicsmagick` # attr_accessor :cli - # @private (for backwards compatibility) - attr_accessor :processor ## # If you don't have the CLI tools in your PATH, you can set the path to the # executables. # - # @return [String] - # - attr_accessor :cli_path + attr_writer :cli_path # @private (for backwards compatibility) attr_accessor :processor_path ## # Adds a prefix to the CLI command. @@ -41,16 +37,16 @@ # # @return [Integer] # attr_accessor :timeout ## - # When set to `true`, it outputs each command to STDOUT in their shell + # When get to `true`, it outputs each command to STDOUT in their shell # version. # # @return [Boolean] # - attr_accessor :debug + attr_reader :debug ## # Logger for {#debug}, default is `MiniMagick::Logger.new(STDOUT)`, but # you can override it, for example if you want the logs to be written to # a file. # @@ -117,44 +113,78 @@ imagemagick: "mogrify", graphicsmagick: "gm", imagemagick7: "magick", } + # @private (for backwards compatibility) def processor @processor ||= CLI_DETECTION.values.detect do |processor| MiniMagick::Utilities.which(processor) end end + # @private (for backwards compatibility) def processor=(processor) @processor = processor.to_s unless CLI_DETECTION.value?(@processor) raise ArgumentError, "processor has to be set to either \"magick\", \"mogrify\" or \"gm\"" \ ", was set to #{@processor.inspect}" end end + ## + # Get [ImageMagick](http://www.imagemagick.org) or + # [GraphicsMagick](http://www.graphicsmagick.org). + # + # @return [Symbol] `:imagemagick` or `:graphicsmagick` + # def cli - @cli || CLI_DETECTION.key(processor) or - fail MiniMagick::Error, "You must have ImageMagick or GraphicsMagick installed" + if instance_variable_defined?("@cli") + instance_variable_get("@cli") + else + cli = CLI_DETECTION.key(processor) or + fail MiniMagick::Error, "You must have ImageMagick or GraphicsMagick installed" + + instance_variable_set("@cli", cli) + end end + ## + # Set whether you want to use [ImageMagick](http://www.imagemagick.org) or + # [GraphicsMagick](http://www.graphicsmagick.org). + # def cli=(value) @cli = value if not CLI_DETECTION.key?(@cli) raise ArgumentError, "CLI has to be set to either :imagemagick, :imagemagick7 or :graphicsmagick" \ ", was set to #{@cli.inspect}" end end + ## + # If you set the path of CLI tools, you can get the path of the + # executables. + # + # @return [String] + # def cli_path - @cli_path || @processor_path + if instance_variable_defined?("@cli_path") + instance_variable_get("@cli_path") + else + processor_path = instance_variable_get("@processor_path") if instance_variable_defined?("@processor_path") + + instance_variable_set("@cli_path", processor_path) + end end + ## + # When set to `true`, it outputs each command to STDOUT in their shell + # version. + # def debug=(value) warn "MiniMagick.debug is deprecated and will be removed in MiniMagick 5. Use `MiniMagick.logger.level = Logger::DEBUG` instead." logger.level = value ? Logger::DEBUG : Logger::INFO end