Class: Pineapples::Actions::CopyFile
- Inherits:
-
CreateFile
- Object
- Action
- EmptyDirectory
- CreateFile
- Pineapples::Actions::CopyFile
- Defined in:
- lib/pineapples/actions/copy_file.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Action
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Attributes inherited from CreateFile
Attributes inherited from EmptyDirectory
Attributes inherited from Action
Instance Method Summary collapse
-
#initialize(generator, source, target, options, &block) ⇒ CopyFile
constructor
A new instance of CopyFile.
- #invoke! ⇒ Object
Methods inherited from CreateFile
Methods inherited from EmptyDirectory
Methods inherited from Action
colors, inherited, #skip?, status_color
Constructor Details
#initialize(generator, source, target, options, &block) ⇒ CopyFile
Returns a new instance of CopyFile.
31 32 33 34 35 36 |
# File 'lib/pineapples/actions/copy_file.rb', line 31 def initialize(generator, source, target, , &block) @source = File.(generator.find_in_source_paths(source.to_s)) @content = File.binread(@source) @content = block.call(@content) if block super(generator, target, @content, ) end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
29 30 31 |
# File 'lib/pineapples/actions/copy_file.rb', line 29 def source @source end |
Instance Method Details
#invoke! ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/pineapples/actions/copy_file.rb', line 38 def invoke! super if [:mode] == :preserve mode = File.stat(source).mode generator.chmod(target.fullpath, mode, ) end end |