class Awestruct::CLI::Manifest::MkDir

Public Class Methods

new(path) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 97
def initialize(path)
  @path = path
end

Public Instance Methods

perform(dir) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 101
def perform(dir)
  p = File.join(dir, @path)
  if File.exist?(p)
    $LOG.error "Exists: #{p}" if $LOG.error?
    return
  end
  unless File.directory?(File.dirname(p))
    $LOG.error "Does not exist: #{File.dirname(p)}" if $LOG.error?
    return
  end
  $LOG.info "Create directory: #{p}" if $LOG.info?
  FileUtils.mkdir(p)
end
unperform(dir) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 115
def unperform(dir)
  p = File.join(dir, @path)
  unless File.exist?(p)
    $LOG.error "Does not exist: #{p}" if $LOG.error?
    return
  end
  unless File.directory?(p)
    $LOG.error "Not a directory: #{p}" if $LOG.error?
    return
  end
  if Dir.entries(p) != 2
    $LOG.error "Not empty: #{p}" if $LOG.error?
    return
  end
  $LOG.info "Remove: #{p}" if $LOG.info?
  FileUtils.rmdir(p)
end