class Itamae::Resource::Directory

Public Instance Methods

action_create(options) click to toggle source
# File lib/itamae/resource/directory.rb, line 43
def action_create(options)
  if !run_specinfra(:check_file_is_directory, attributes.path)
    run_specinfra(:create_file_as_directory, attributes.path)
  end
  if attributes.mode
    run_specinfra(:change_file_mode, attributes.path, attributes.mode)
  end
  if attributes.owner || attributes.group
    run_specinfra(:change_file_owner, attributes.path, attributes.owner, attributes.group)
  end
end
action_delete(options) click to toggle source
# File lib/itamae/resource/directory.rb, line 55
def action_delete(options)
  if run_specinfra(:check_file_is_directory, attributes.path)
    run_specinfra(:remove_file, attributes.path)
  end
end
pre_action() click to toggle source
# File lib/itamae/resource/directory.rb, line 12
def pre_action
  case @current_action
  when :create
    attributes.exist = true
  when :delete
    attributes.exist = false
  end
end
set_current_attributes() click to toggle source
# File lib/itamae/resource/directory.rb, line 28
def set_current_attributes
  exist = run_specinfra(:check_file_is_directory, attributes.path)
  current.exist = exist

  if exist
    current.mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
    current.owner = run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
    current.group = run_specinfra(:get_file_owner_group, attributes.path).stdout.chomp
  else
    current.mode = nil
    current.owner = nil
    current.group = nil
  end
end
show_differences() click to toggle source
Calls superclass method Itamae::Resource::Base#show_differences
# File lib/itamae/resource/directory.rb, line 21
def show_differences
  current.mode    = current.mode.rjust(4, '0') if current.mode
  attributes.mode = attributes.mode.rjust(4, '0') if attributes.mode

  super
end