Class: TyranoDsl::FileActions::ClearDirectory
- Inherits:
-
Object
- Object
- TyranoDsl::FileActions::ClearDirectory
- Includes:
- FileActionsModule
- Defined in:
- lib/tyrano_dsl/file_actions/clear_directory.rb
Overview
Remove all files from a directory
Instance Attribute Summary collapse
- #path ⇒ String readonly
Instance Method Summary collapse
-
#initialize(path) ⇒ ClearDirectory
constructor
A new instance of ClearDirectory.
- #run(tyrano_project_path) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ ClearDirectory
15 16 17 18 |
# File 'lib/tyrano_dsl/file_actions/clear_directory.rb', line 15 def initialize(path) @path = path log {to_s} end |
Instance Attribute Details
#path ⇒ String (readonly)
12 13 14 |
# File 'lib/tyrano_dsl/file_actions/clear_directory.rb', line 12 def path @path end |
Instance Method Details
#run(tyrano_project_path) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/tyrano_dsl/file_actions/clear_directory.rb', line 21 def run(tyrano_project_path) full_path = File.join(tyrano_project_path, path) log {"Cleaning [#{full_path}]"} if File.exists? full_path FileUtils.remove_entry full_path end FileUtils.mkdir_p full_path end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/tyrano_dsl/file_actions/clear_directory.rb', line 30 def to_s "Clear directory [#{path}]" end |