Class: Resource::Directory

Inherits:
Base
  • Object
show all
Defined in:
lib/resource/directory.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(target, &block) ⇒ Directory

Returns a new instance of Directory.



7
8
9
10
11
# File 'lib/resource/directory.rb', line 7

def initialize target, &block
  set_base_defaults
  @target = target
  self.instance_eval(&block)
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
# File 'lib/resource/directory.rb', line 13

def run
  Execution.block 'Creating directory', @target, 'root' do |b|
    b.always_run @always_run
    b.run "mkdir -p #{@target}"
    b.run "chmod #{unix_mode} #{@target}"
    b.run "chown #{@owner}:#{@group} #{@target}"
  end
end