Module: MiniMagick::Configuration

Included in:
MiniMagick
Defined in:
lib/mini_magick/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cli_prefixString+

Adds a prefix to the CLI command. For example, you could use ‘firejail` to run all commands in a sandbox. Can be a string, or an array of strings. e.g. ’firejail’, or [‘firejail’, ‘–force’]

Returns:

  • (String)
  • (Array<String>)


16
17
18
# File 'lib/mini_magick/configuration.rb', line 16

def cli_prefix
  @cli_prefix
end

#errorsBoolean

If set to ‘false`, it will not raise errors when ImageMagick returns status code different than 0. Defaults to `true`.

Returns:

  • (Boolean)


46
47
48
# File 'lib/mini_magick/configuration.rb', line 46

def errors
  @errors
end

#loggerLogger

Logger for commands, default is ‘Logger.new($stdout)`, but you can override it, for example if you want the logs to be written to a file.

Returns:

  • (Logger)


31
32
33
# File 'lib/mini_magick/configuration.rb', line 31

def logger
  @logger
end

#timeoutInteger

If you don’t want commands to take too long, you can set a timeout (in seconds).

Returns:

  • (Integer)


24
25
26
# File 'lib/mini_magick/configuration.rb', line 24

def timeout
  @timeout
end

#tmpdirString

Temporary directory used by MiniMagick, default is ‘Dir.tmpdir`, but you can override it.

Returns:

  • (String)


38
39
40
# File 'lib/mini_magick/configuration.rb', line 38

def tmpdir
  @tmpdir
end

#warningsObject

If set to ‘false`, it will not forward warnings from ImageMagick to standard error.



51
52
53
# File 'lib/mini_magick/configuration.rb', line 51

def warnings
  @warnings
end

Class Method Details

.extended(base) ⇒ Object



53
54
55
56
57
58
# File 'lib/mini_magick/configuration.rb', line 53

def self.extended(base)
  base.tmpdir = Dir.tmpdir
  base.errors = true
  base.logger = Logger.new($stdout).tap { |l| l.level = Logger::INFO }
  base.warnings = true
end

Instance Method Details

#configure {|self| ... } ⇒ Object

Examples:

MiniMagick.configure do |config|
  config.timeout = 5
end

Yields:

  • (self)


67
68
69
# File 'lib/mini_magick/configuration.rb', line 67

def configure
  yield self
end