Class: Cukedep::DeleteAction
- Inherits:
-
FileAction
- Object
- FileAction
- Cukedep::DeleteAction
- Defined in:
- lib/cukedep/file-action.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from FileAction
Instance Method Summary collapse
-
#initialize(thePatterns, aDelta = nil) ⇒ DeleteAction
constructor
Constructor.
- #run!(targetDir) ⇒ Object
Methods inherited from FileAction
Constructor Details
#initialize(thePatterns, aDelta = nil) ⇒ DeleteAction
Constructor. [thePatterns] An array of file patterns.
81 82 83 |
# File 'lib/cukedep/file-action.rb', line 81 def initialize(thePatterns, aDelta = nil) super(thePatterns, aDelta) end |
Instance Method Details
#run!(targetDir) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/cukedep/file-action.rb', line 85 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 |