Class: TyranoDsl::FileActions::ClearDirectory

Inherits:
Object
  • Object
show all
Includes:
FileActionsModule
Defined in:
lib/tyrano_dsl/file_actions/clear_directory.rb

Overview

Remove all files from a directory

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathString (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_sObject



30
31
32
# File 'lib/tyrano_dsl/file_actions/clear_directory.rb', line 30

def to_s
  "Clear directory [#{path}]"
end