Module: Kicker::Utils

Extended by:
Utils
Included in:
Utils
Defined in:
lib/kicker/utils.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#should_clear_screenObject Also known as: should_clear_screen?

Returns the value of attribute should_clear_screen.



7
8
9
# File 'lib/kicker/utils.rb', line 7

def should_clear_screen
  @should_clear_screen
end

Instance Method Details

#clear_console!Object



41
42
43
# File 'lib/kicker/utils.rb', line 41

def clear_console!
  puts(CLEAR) if Kicker.clear_console?
end

#execute(command_or_options) ⇒ Object



25
26
27
28
29
30
# File 'lib/kicker/utils.rb', line 25

def execute(command_or_options)
  perform_work(command_or_options) do |job|
    _execute(job)
    yield job if block_given?
  end
end

#log(message) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/kicker/utils.rb', line 32

def log(message)
  if Kicker.quiet
    puts message
  else
    now = Time.now
    puts "#{now.strftime('%H:%M:%S')}.#{now.usec.to_s[0,2]} | #{message}"
  end
end

#perform_work(command_or_options) {|job| ... } ⇒ Object

Yields:

  • (job)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kicker/utils.rb', line 10

def perform_work(command_or_options)
  if command_or_options.is_a?(Hash)
    options = command_or_options
  elsif command_or_options.is_a?(String)
    options = { :command => command_or_options }
  else
    raise ArgumentError, "Should be a string or a hash."
  end
  job = Job.new(options)
  will_execute_command(job)
  yield job
  did_execute_command(job)
  job
end