Class: TyranoDsl::FileActions::CreateFile
- Inherits:
-
Object
- Object
- TyranoDsl::FileActions::CreateFile
- Includes:
- FileActionsModule
- Defined in:
- lib/tyrano_dsl/file_actions/create_file.rb
Overview
Create a file with a custom content
Instance Attribute Summary collapse
- #content ⇒ String readonly
- #path ⇒ String readonly
Instance Method Summary collapse
-
#initialize(path, content) ⇒ CreateFile
constructor
A new instance of CreateFile.
- #run(tyrano_project_path) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path, content) ⇒ CreateFile
Returns a new instance of CreateFile.
15 16 17 18 19 |
# File 'lib/tyrano_dsl/file_actions/create_file.rb', line 15 def initialize(path, content) @path = path @content = content log {self.to_s} end |
Instance Attribute Details
#content ⇒ String (readonly)
9 10 11 |
# File 'lib/tyrano_dsl/file_actions/create_file.rb', line 9 def content @content end |
#path ⇒ String (readonly)
11 12 13 |
# File 'lib/tyrano_dsl/file_actions/create_file.rb', line 11 def path @path end |
Instance Method Details
#run(tyrano_project_path) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/tyrano_dsl/file_actions/create_file.rb', line 22 def run(tyrano_project_path) full_path = File.join(tyrano_project_path, path) log {"Creating file [#{full_path}]"} create_parent_dir_if_not_exist(full_path) File.write(full_path, content) end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/tyrano_dsl/file_actions/create_file.rb', line 29 def to_s "Create file [#{path}]" end |