Class: Koch::CreateDirectory

Inherits:
Resource show all
Includes:
Ogm
Defined in:
lib/koch/create_directory.rb

Overview

Creates a directory if it doesn’t exist and/or changes its mode/owner/group

Instance Attribute Summary

Attributes inherited from Resource

#changed, #name

Instance Method Summary collapse

Methods included from Ogm

#apply_group, #apply_mode, #apply_owner

Methods inherited from Resource

dsl_writer, #initialize

Constructor Details

This class inherits a constructor from Koch::Resource

Instance Method Details

#apply!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/koch/create_directory.rb', line 12

def apply!
  if Dir.exist? name
    debug "Not creating directory #{name}, it already exists"
  else
    @changed = true
    maybe("Creating directory #{name}") do
      FileUtils.mkdir_p name
    end
  end

  apply_owner
  apply_group
  apply_mode
end