Class: Resource::Execute

Inherits:
Base
  • Object
show all
Defined in:
lib/resource/execute.rb

Instance Method Summary collapse

Methods inherited from Base

inherited, #not_if, #set_base_defaults, #should_skip?, #unix_mode

Methods included from ClassAttr

included

Methods included from BlockAttr

included

Constructor Details

#initialize(title, &block) ⇒ Execute

Returns a new instance of Execute.



7
8
9
10
11
12
13
# File 'lib/resource/execute.rb', line 7

def initialize title, &block
  set_base_defaults
  @path = nil
  @commands = []
  @title = title
  self.instance_eval(&block)
end

Instance Method Details

#command(string) ⇒ Object



15
16
17
# File 'lib/resource/execute.rb', line 15

def command string
  @commands << { :command => string, :path => @path }
end

#runObject



19
20
21
22
23
24
25
26
# File 'lib/resource/execute.rb', line 19

def run
  Execution.block 'Execution', @title, @owner do |b|
    b.always_run @always_run
    @commands.each do |command_hash|
      b.run "#{command_hash[:command]}", command_hash[:path]
    end
  end
end