class Cukedep::DeleteAction
A delete action object has for purpose to delete files matching one of its file patterns. These file are deleted from (a subdir of) a given 'target' directory.
Public Class Methods
new(thePatterns, aDelta = nil)
click to toggle source
Constructor.
- thePatterns
-
An array of file patterns.
Calls superclass method
Cukedep::FileAction::new
# File lib/cukedep/file-action.rb, line 82 def initialize(thePatterns, aDelta = nil) super(thePatterns, aDelta) end
Public Instance Methods
run!(targetDir)
click to toggle source
# File lib/cukedep/file-action.rb, line 86 def run!(targetDir) return if patterns.empty? orig_dir = Dir.getwd # Store current work directory # pp orig_dir begin Dir.chdir(full_path(targetDir)) patterns.each do |pattern| Dir.glob(pattern) { |fname| single_action(fname) } end ensure Dir.chdir(orig_dir) # Restore original work directory end end
Private Instance Methods
single_action(aFilename)
click to toggle source
# File lib/cukedep/file-action.rb, line 105 def single_action(aFilename) FileUtils.remove_file(aFilename) end