Class: TyranoDsl::FileActions::FileCopy
- Inherits:
-
Object
- Object
- TyranoDsl::FileActions::FileCopy
- 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
- #from_path ⇒ String readonly
- #to_path ⇒ String readonly
Instance Method Summary collapse
-
#initialize(from_path, to_path) ⇒ FileCopy
constructor
A new instance of FileCopy.
- #run(tyrano_project_path) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(from_path, to_path) ⇒ FileCopy
Returns a new instance of FileCopy.
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_path ⇒ String (readonly)
10 11 12 |
# File 'lib/tyrano_dsl/file_actions/file_copy.rb', line 10 def from_path @from_path end |
#to_path ⇒ String (readonly)
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
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_s ⇒ Object
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 |