Class: Scripted::Command

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {}, &block)
  @name = name
  @options = options
  define(&block) if block
end

Instance Attribute Details

#nameObject (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

#executableObject



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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


73
74
75
# File 'lib/scripted/command.rb', line 73

def only_when_failed?
  !!@only_when_failed
end

#parallel_idObject



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

Returns:

  • (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

Returns:

  • (Boolean)


49
50
51
# File 'lib/scripted/command.rb', line 49

def unimportant?
  !!@unimportant
end