Class: TyranoDsl::FileActions::FileCopy

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

Overview

Direct copy of a file from a source to a destination

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_path, to_path) ⇒ FileCopy

Returns a new instance of FileCopy.

Parameters:

  • from_path (String)
  • to_path (String)


18
19
20
21
22
# File 'lib/tyrano_dsl/file_actions/file_copy.rb', line 18

def initialize(from_path, to_path)
  @from_path = from_path
  @to_path = to_path
  log {self.to_s}
end

Instance Attribute Details

#from_pathString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/tyrano_dsl/file_actions/file_copy.rb', line 10

def from_path
  @from_path
end

#to_pathString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/tyrano_dsl/file_actions/file_copy.rb', line 12

def to_path
  @to_path
end

Instance Method Details

#run(tyrano_project_path) ⇒ Object

Parameters:

  • tyrano_project_path (String)


25
26
27
28
29
30
# File 'lib/tyrano_dsl/file_actions/file_copy.rb', line 25

def run(tyrano_project_path)
  full_path = File.join(tyrano_project_path, to_path)
  log {"Copy file [#{from_path}] to [#{full_path}]"}
  create_parent_dir_if_not_exist(full_path)
  FileUtils.copy_file from_path, full_path
end

#to_sObject



32
33
34
# File 'lib/tyrano_dsl/file_actions/file_copy.rb', line 32

def to_s
  "Copy file [#{from_path}] to [#{to_path}]"
end