Class: Awestruct::CLI::Manifest::CopyFile
- Inherits:
-
Object
- Object
- Awestruct::CLI::Manifest::CopyFile
- Defined in:
- lib/awestruct/cli/manifest.rb
Instance Method Summary collapse
-
#initialize(path, input_path, opts = {}) ⇒ CopyFile
constructor
A new instance of CopyFile.
- #notunperform(dir) ⇒ Object
- #perform(dir) ⇒ Object
- #unperform(dir) ⇒ Object
Constructor Details
#initialize(path, input_path, opts = {}) ⇒ CopyFile
Returns a new instance of CopyFile.
194 195 196 197 198 |
# File 'lib/awestruct/cli/manifest.rb', line 194 def initialize(path, input_path, opts = {}) @path = path @input_path = input_path @overwrite = opts[:overwrite] end |
Instance Method Details
#notunperform(dir) ⇒ Object
218 219 220 221 222 223 224 225 226 |
# File 'lib/awestruct/cli/manifest.rb', line 218 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
200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/awestruct/cli/manifest.rb', line 200 def perform(dir ) p = File.join( dir, @path ) if !@overwrite && 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
214 215 216 |
# File 'lib/awestruct/cli/manifest.rb', line 214 def unperform(dir) # nothing end |