Class: Prepp::Command

Inherits:
Object show all
Defined in:
lib/prepp/commands/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *dependencies, &block) ⇒ Command

Returns a new instance of Command.



4
5
6
7
8
9
10
11
12
13
# File 'lib/prepp/commands/command.rb', line 4

def initialize(name, *dependencies, &block)
  @name = name.to_sym
  @dependencies = *dependencies
  @execute = []
  @verifiers = []

  @results = []

  instance_eval(&block)
end

Instance Attribute Details

#resultsObject

Returns the value of attribute results.



15
16
17
# File 'lib/prepp/commands/command.rb', line 15

def results
  @results
end

Instance Method Details

#execute(command = nil, &block) ⇒ Object



17
18
19
# File 'lib/prepp/commands/command.rb', line 17

def execute(command = nil, &block)
  @execute << (block_given? ? instance_eval(&block) : command)
end

#to_sObject



25
26
27
# File 'lib/prepp/commands/command.rb', line 25

def to_s
  build_ssh_command
end

#verify(command = nil, &block) ⇒ Object



21
22
23
# File 'lib/prepp/commands/command.rb', line 21

def verify(command = nil, &block)
  @verifiers << (block_given? ? instance_eval(&block) : command)
end