class Icomoon::Cli::Operation

Public Class Methods

dump_errors(exit_code = nil) click to toggle source
# File lib/icomoon/cli/operation.rb, line 33
def self.dump_errors(exit_code = nil)
  while (error = @@errors.shift)
    Icomoon::Cli.logs "#{'Error:'.red} #{error.message}"
  end

  exit(exit_code) if exit_code
end
dump_warnings() click to toggle source
# File lib/icomoon/cli/operation.rb, line 27
def self.dump_warnings
  while (warning = @@warnings.shift)
    Icomoon::Cli.logs "#{'Warning:'.yellow} #{warning.message}"
  end
end
new(name = nil) { || ... } click to toggle source
# File lib/icomoon/cli/operation.rb, line 8
def initialize(name = nil)
  return unless block_given?
  return if self.class.skip?

  Icomoon::Cli.log "#{name}... " if name

  begin
    yield
    puts '✔'.green if name
  rescue Icomoon::Cli::Error => error
    @@errors << error
    puts '✘'.red if name
    Icomoon::Cli::Operation.skip_all!
  rescue Icomoon::Cli::Warning => warning
    @@warnings << warning
    puts '✘'.red if name
  end
end
skip?() click to toggle source
# File lib/icomoon/cli/operation.rb, line 49
def self.skip?
  @@skip_all
end
skip_all!() click to toggle source
# File lib/icomoon/cli/operation.rb, line 45
def self.skip_all!
  @@skip_all = true
end
warn!(message) click to toggle source
# File lib/icomoon/cli/operation.rb, line 41
def self.warn!(message)
  @@warnings << Icomoon::Cli::Operation::Warning.new(message)
end