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.
189 190 191 192 193 |
# File 'lib/awestruct/cli/manifest.rb', line 189 def initialize(path, input_path, opts = {}) @path = path @input_path = input_path @overwrite = opts[:overwrite] end |
Instance Method Details
#notunperform(dir) ⇒ Object
213 214 215 216 217 218 219 220 221 |
# 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) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 |
# 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) ⇒ Object
209 210 211 |
# File 'lib/awestruct/cli/manifest.rb', line 209 def unperform(dir) # nothing end |