Module: FaviconMaker::BaseCommand

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

Instance Method Summary collapse

Instance Method Details

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



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

def compose(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

#on_windows?Boolean

Returns:

  • (Boolean)


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

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

#options_to_args(options) ⇒ Object



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

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

#to_sObject



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

def to_s
  @command
end