Class: Awestruct::Commands::Manifest::CopyFile

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

Instance Method Summary collapse

Constructor Details

#initialize(path, input_path) ⇒ CopyFile

Returns a new instance of CopyFile.



142
143
144
145
# File 'lib/awestruct/commands/manifest.rb', line 142

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

Instance Method Details

#notunperform(dir) ⇒ Object



165
166
167
168
169
170
171
172
173
# File 'lib/awestruct/commands/manifest.rb', line 165

def notunperform(dir)
  p = File.join( @dir, p )
  if ( ! File.exist?( p ) )
    $stderr.puts "Does not exist: #{p}"
    return
  end
  $stderr.puts "Remove: #{p}"
  FileUtils.rm( p )
end

#perform(dir) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/awestruct/commands/manifest.rb', line 147

def perform(dir )
  p = File.join( dir, @path )
  if ( File.exist?( p ) )
    $stderr.puts "Exists: #{p}"
    return
  end
  if ( ! File.directory?( File.dirname( p ) ) )
    $stderr.puts "No directory: #{File.dirname( p )}"
    return
  end
  $stderr.puts "Create file: #{p}"
  File.open( p, 'w' ){|f| f.write( File.read( @input_path ) ) }
end

#unperform(dir) ⇒ Object



161
162
163
# File 'lib/awestruct/commands/manifest.rb', line 161

def unperform(dir)
  # nothing
end