Class: Scripted::Running::RunCommand
- Inherits:
-
Object
- Object
- Scripted::Running::RunCommand
- Defined in:
- lib/scripted/running/run_command.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#delegate ⇒ Object
readonly
Returns the value of attribute delegate.
-
#ended_at ⇒ Object
readonly
Returns the value of attribute ended_at.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
Instance Method Summary collapse
- #done ⇒ Object
- #execute!(delegate) ⇒ Object
- #executed? ⇒ Boolean
- #failed!(exception) ⇒ Object
- #failed? ⇒ Boolean
- #failed_but_unimportant? ⇒ Boolean
- #forced? ⇒ Boolean
- #halted? ⇒ Boolean
- #important? ⇒ Boolean
-
#initialize(command, logger) ⇒ RunCommand
constructor
A new instance of RunCommand.
- #name ⇒ Object
- #only_when_failed? ⇒ Boolean
- #parallel? ⇒ Boolean
- #parallel_id ⇒ Object
- #running? ⇒ Boolean
- #success! ⇒ Object
- #success? ⇒ Boolean
- #unimportant? ⇒ Boolean
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
#command ⇒ Object (readonly)
Returns the value of attribute command.
7 8 9 |
# File 'lib/scripted/running/run_command.rb', line 7 def command @command end |
#delegate ⇒ Object (readonly)
Returns the value of attribute delegate.
8 9 10 |
# File 'lib/scripted/running/run_command.rb', line 8 def delegate @delegate end |
#ended_at ⇒ Object (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 |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
8 9 10 |
# File 'lib/scripted/running/run_command.rb', line 8 def exception @exception end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/scripted/running/run_command.rb', line 7 def logger @logger end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
8 9 10 |
# File 'lib/scripted/running/run_command.rb', line 8 def runtime @runtime end |
#started_at ⇒ Object (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
#done ⇒ Object
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
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
55 56 57 |
# File 'lib/scripted/running/run_command.rb', line 55 def failed? executed? && !unimportant? && !@success end |
#failed_but_unimportant? ⇒ Boolean
75 76 77 |
# File 'lib/scripted/running/run_command.rb', line 75 def failed_but_unimportant? executed? && !@success && unimportant? end |
#forced? ⇒ Boolean
91 92 93 |
# File 'lib/scripted/running/run_command.rb', line 91 def forced? command.forced? end |
#halted? ⇒ Boolean
67 68 69 |
# File 'lib/scripted/running/run_command.rb', line 67 def halted? !!@halted end |
#important? ⇒ Boolean
47 48 49 |
# File 'lib/scripted/running/run_command.rb', line 47 def important? command.important? end |
#name ⇒ Object
95 96 97 |
# File 'lib/scripted/running/run_command.rb', line 95 def name command.name end |
#only_when_failed? ⇒ Boolean
87 88 89 |
# File 'lib/scripted/running/run_command.rb', line 87 def only_when_failed? command.only_when_failed? end |
#parallel? ⇒ Boolean
83 84 85 |
# File 'lib/scripted/running/run_command.rb', line 83 def parallel? command.parallel? end |
#parallel_id ⇒ Object
79 80 81 |
# File 'lib/scripted/running/run_command.rb', line 79 def parallel_id command.parallel_id end |
#running? ⇒ 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
51 52 53 |
# File 'lib/scripted/running/run_command.rb', line 51 def success? executed? && !!@success end |
#unimportant? ⇒ Boolean
71 72 73 |
# File 'lib/scripted/running/run_command.rb', line 71 def unimportant? command.unimportant? end |