Class: Scripted::Command
- Inherits:
-
Object
- Object
- Scripted::Command
- Defined in:
- lib/scripted/command.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #define(&block) ⇒ Object
- #executable ⇒ Object
- #execute!(logger) ⇒ Object
- #forced! ⇒ Object
- #forced? ⇒ Boolean
- #important! ⇒ Object
- #important? ⇒ Boolean
-
#initialize(name, options = {}, &block) ⇒ Command
constructor
A new instance of Command.
- #only_when_failed! ⇒ Object
- #only_when_failed? ⇒ Boolean
- #parallel_id ⇒ Object
- #rake(command) ⇒ Object
- #ruby(&code) ⇒ Object
- #run_in_parallel_with?(other) ⇒ Boolean
- #sh(command) ⇒ Object (also: #:`)
- #unimportant! ⇒ Object
- #unimportant? ⇒ Boolean
Constructor Details
#initialize(name, options = {}, &block) ⇒ Command
Returns a new instance of Command.
10 11 12 13 14 |
# File 'lib/scripted/command.rb', line 10 def initialize(name, = {}, &block) @name = name @options = define(&block) if block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/scripted/command.rb', line 8 def name @name end |
Instance Method Details
#define(&block) ⇒ Object
16 17 18 |
# File 'lib/scripted/command.rb', line 16 def define(&block) instance_eval &block end |
#executable ⇒ Object
20 21 22 |
# File 'lib/scripted/command.rb', line 20 def executable @command || Commands::Shell.new(@name) end |
#execute!(logger) ⇒ Object
24 25 26 |
# File 'lib/scripted/command.rb', line 24 def execute!(logger) executable.execute!(logger) end |
#forced! ⇒ Object
57 58 59 |
# File 'lib/scripted/command.rb', line 57 def forced! @forced = true end |
#forced? ⇒ Boolean
61 62 63 |
# File 'lib/scripted/command.rb', line 61 def forced? !!@forced end |
#important! ⇒ Object
41 42 43 |
# File 'lib/scripted/command.rb', line 41 def important! @important = true end |
#important? ⇒ Boolean
45 46 47 |
# File 'lib/scripted/command.rb', line 45 def important? !!@important end |
#only_when_failed! ⇒ Object
77 78 79 |
# File 'lib/scripted/command.rb', line 77 def only_when_failed! @only_when_failed = true end |
#only_when_failed? ⇒ Boolean
73 74 75 |
# File 'lib/scripted/command.rb', line 73 def only_when_failed? !!@only_when_failed end |
#parallel_id ⇒ Object
65 66 67 |
# File 'lib/scripted/command.rb', line 65 def parallel_id @options[:parallel_id] end |
#rake(command) ⇒ Object
33 34 35 |
# File 'lib/scripted/command.rb', line 33 def rake(command) @command = Commands::Rake.new(command) end |
#ruby(&code) ⇒ Object
37 38 39 |
# File 'lib/scripted/command.rb', line 37 def ruby(&code) @command = Commands::Ruby.new(code) end |
#run_in_parallel_with?(other) ⇒ Boolean
69 70 71 |
# File 'lib/scripted/command.rb', line 69 def run_in_parallel_with?(other) other && parallel_id == other.parallel_id end |
#sh(command) ⇒ Object Also known as: :`
28 29 30 |
# File 'lib/scripted/command.rb', line 28 def sh(command) @command = Commands::Shell.new(command) end |
#unimportant! ⇒ Object
53 54 55 |
# File 'lib/scripted/command.rb', line 53 def unimportant! @unimportant = true end |
#unimportant? ⇒ Boolean
49 50 51 |
# File 'lib/scripted/command.rb', line 49 def unimportant? !!@unimportant end |