Class: AppStage::DeleteFiles
- Inherits:
-
Object
- Object
- AppStage::DeleteFiles
- Defined in:
- lib/delete_files.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ DeleteFiles
constructor
A new instance of DeleteFiles.
Constructor Details
#initialize(options) ⇒ DeleteFiles
Returns a new instance of DeleteFiles.
4 5 6 |
# File 'lib/delete_files.rb', line 4 def initialize() @options = end |
Instance Method Details
#execute ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/delete_files.rb', line 8 def execute begin files_json = ListFiles.new(@options).getFileList pattern = @options[:delete] || ".*" matching_files = files_json.select{|f| f['name'].match(/#{pattern}/)} puts "Deleting #{matching_files.count} files" matching_files.each do |rf| puts " deleting #{rf['name']}" delete_file(rf['id']) end 0 rescue Exception => e puts "Delete failed - #{e.}" -1 end end |