Class: Awestruct::CLI::Manifest::CopyFile

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/cli/manifest.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, input_path) ⇒ CopyFile

Returns a new instance of CopyFile.



147
148
149
150
# File 'lib/awestruct/cli/manifest.rb', line 147

def initialize(path, input_path)
  @path       = path
  @input_path = input_path
end

Instance Method Details

#notunperform(dir) ⇒ Object



170
171
172
173
174
175
176
177
178
# File 'lib/awestruct/cli/manifest.rb', line 170

def notunperform(dir)
  p = File.join( @dir, p )
  if ( ! 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) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/awestruct/cli/manifest.rb', line 152

def perform(dir )
  p = File.join( dir, @path )
  if ( File.exist?( p ) )
    $LOG.error "Exists: #{p}" if $LOG.error?
    return
  end
  if ( ! 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) ⇒ Object



166
167
168
# File 'lib/awestruct/cli/manifest.rb', line 166

def unperform(dir)
  # nothing
end