Class: Scripted::Running::RunCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/scripted/running/run_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, logger) ⇒ RunCommand

Returns a new instance of RunCommand.



10
11
12
13
# File 'lib/scripted/running/run_command.rb', line 10

def initialize(command, logger)
  @command = command
  @logger = logger
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/scripted/running/run_command.rb', line 7

def command
  @command
end

#delegateObject (readonly)

Returns the value of attribute delegate.



8
9
10
# File 'lib/scripted/running/run_command.rb', line 8

def delegate
  @delegate
end

#ended_atObject (readonly)

Returns the value of attribute ended_at.



8
9
10
# File 'lib/scripted/running/run_command.rb', line 8

def ended_at
  @ended_at
end

#exceptionObject (readonly)

Returns the value of attribute exception.



8
9
10
# File 'lib/scripted/running/run_command.rb', line 8

def exception
  @exception
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/scripted/running/run_command.rb', line 7

def logger
  @logger
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



8
9
10
# File 'lib/scripted/running/run_command.rb', line 8

def runtime
  @runtime
end

#started_atObject (readonly)

Returns the value of attribute started_at.



8
9
10
# File 'lib/scripted/running/run_command.rb', line 8

def started_at
  @started_at
end

Instance Method Details

#doneObject



24
25
26
27
28
29
30
# File 'lib/scripted/running/run_command.rb', line 24

def done
  @executed = true
  @running  = false
  @ended_at = Time.now
  @runtime  = @ended_at - @started_at
  delegate.done(self)
end

#execute!(delegate) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/scripted/running/run_command.rb', line 15

def execute!(delegate)
  return if executed?
  @delegate = delegate
  @running = true
  @started_at = Time.now
  logger.execute(self)
  Execute.call(command, self, logger)
end

#executed?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/scripted/running/run_command.rb', line 63

def executed?
  !!@executed
end

#failed!(exception) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/scripted/running/run_command.rb', line 37

def failed!(exception)
  @success = false
  @exception = exception
  if important?
    @halted = true
    delegate.halt!(self)
  end
  done
end

#failed?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/scripted/running/run_command.rb', line 55

def failed?
  executed? && !unimportant? && !@success
end

#failed_but_unimportant?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/scripted/running/run_command.rb', line 75

def failed_but_unimportant?
  executed? && !@success && unimportant?
end

#forced?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/scripted/running/run_command.rb', line 91

def forced?
  command.forced?
end

#halted?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/scripted/running/run_command.rb', line 67

def halted?
  !!@halted
end

#important?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/scripted/running/run_command.rb', line 47

def important?
  command.important?
end

#nameObject



95
96
97
# File 'lib/scripted/running/run_command.rb', line 95

def name
  command.name
end

#only_when_failed?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/scripted/running/run_command.rb', line 87

def only_when_failed?
  command.only_when_failed?
end

#parallel?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/scripted/running/run_command.rb', line 83

def parallel?
  command.parallel?
end

#parallel_idObject



79
80
81
# File 'lib/scripted/running/run_command.rb', line 79

def parallel_id
  command.parallel_id
end

#running?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/scripted/running/run_command.rb', line 59

def running?
  !!@running
end

#success!Object



32
33
34
35
# File 'lib/scripted/running/run_command.rb', line 32

def success!
  @success = true
  done
end

#success?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/scripted/running/run_command.rb', line 51

def success?
  executed? && !!@success
end

#unimportant?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/scripted/running/run_command.rb', line 71

def unimportant?
  command.unimportant?
end