Module: BaseCommand

Included in:
IcoCommand, PngCommand
Defined in:
lib/favicon_maker/base_command.rb

Instance Method Summary collapse

Instance Method Details

#on_windows?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/favicon_maker/base_command.rb', line 22

def on_windows?
  (RbConfig::CONFIG['host_os'].match /mswin|mingw|cygwin/)
end

#options_to_args(options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/favicon_maker/base_command.rb', line 11

def options_to_args(options)
  return nil if options.nil?
  options.map { |k,v|
    if [ :xc, :null ].include?(k)
      "#{k}:#{v}"
    else
      "-#{k} #{v}".strip
    end
  }.join(' ')
end

#run_convert(template_file_path, output_file_path, convert_settings, options, format, &block) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/favicon_maker/base_command.rb', line 3

def run_convert(template_file_path, output_file_path, convert_settings, options, format, &block)
  ico_cmd =   [ "convert -background none #{options}".strip ]
  ico_cmd +=  [ "\"#{template_file_path}\" #{options_to_args(convert_settings)}" ]
  ico_cmd +=  yield([]) if block_given?
  ico_cmd +=  [ " #{format}:\"#{output_file_path}\"" ]
  @command = ico_cmd.join(' ')
end

#to_sObject



26
27
28
# File 'lib/favicon_maker/base_command.rb', line 26

def to_s
  @command
end