class Awestruct::CLI::Manifest::CopyFile

Public Class Methods

new(path, input_path, opts = {}) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 189
def initialize(path, input_path, opts = {})
  @path = path
  @input_path = input_path
  @overwrite = opts[:overwrite]
end

Public Instance Methods

notunperform(dir) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 213
def notunperform(dir)
  p = File.join(@dir, p)
  unless File.exist?(p)
    $LOG.error "Does not exist: #{p}" if $LOG.error?
    return
  end
  $LOG.info "Remove: #{p}" if $LOG.info?
  FileUtils.rm(p)
end
perform(dir) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 195
def perform(dir)
  p = File.join(dir, @path)
  if !@overwrite && File.exist?(p)
    $LOG.error "Exists: #{p}" if $LOG.error?
    return
  end
  unless File.directory?(File.dirname(p))
    $LOG.error "No directory: #{File.dirname(p)}" if $LOG.error?
    return
  end
  $LOG.info "Create file: #{p}" if $LOG.info?
  File.open(p, 'w') { |f| f.write(File.read(@input_path)) }
end
unperform(dir) click to toggle source
# File lib/awestruct/cli/manifest.rb, line 209
def unperform(dir)
  # nothing
end