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.



13
14
15
# File 'lib/kicker/utils.rb', line 13

def should_clear_screen
  @should_clear_screen
end

Instance Method Details

#clear_console!Object



53
54
55
# File 'lib/kicker/utils.rb', line 53

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

#execute(command) ⇒ Object



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

def execute(command)
  perform_work(command) do |status|
    _execute(status)
    yield status if block_given?
  end
end

#last_commandObject



32
33
34
# File 'lib/kicker/utils.rb', line 32

def last_command
  @last_command
end

#last_command_statusObject



49
50
51
# File 'lib/kicker/utils.rb', line 49

def last_command_status
  $?.exitstatus
end

#last_command_succeeded?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/kicker/utils.rb', line 45

def last_command_succeeded?
  $?.success?
end

#log(message) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/kicker/utils.rb', line 36

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) {|status| ... } ⇒ Object

Yields:

  • (status)


16
17
18
19
20
21
22
23
# File 'lib/kicker/utils.rb', line 16

def perform_work(command)
  @last_command = command
  status = Status.new(command, 0, '')
  will_execute_command(status)
  yield status
  did_execute_command(status)
  status
end