Class: Ing::Files::CreateLink
- Inherits:
-
CreateFile
- Object
- EmptyDirectory
- CreateFile
- Ing::Files::CreateLink
- Defined in:
- lib/ing/actions/create_link.rb
Overview
CreateLink is a subset of CreateFile, which instead of taking a block of data, just takes a source string from the user.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
:nodoc:.
Attributes inherited from EmptyDirectory
#base, #config, #destination, #given_destination, #relative_destination
Instance Method Summary collapse
-
#identical? ⇒ Boolean
Checks if the content of the file at the destination is identical to the rendered result.
- #invoke! ⇒ Object
Methods inherited from CreateFile
Methods inherited from EmptyDirectory
#exists?, #initialize, #revoke!
Constructor Details
This class inherits a constructor from Ing::Files::CreateFile
Instance Attribute Details
#data ⇒ Object (readonly)
:nodoc:
29 30 31 |
# File 'lib/ing/actions/create_link.rb', line 29 def data @data end |
Instance Method Details
#identical? ⇒ Boolean
Checks if the content of the file at the destination is identical to the rendered result.
Returns
- Boolean
-
true if it is identical, false otherwise.
36 37 38 |
# File 'lib/ing/actions/create_link.rb', line 36 def identical? exists? && File.identical?(render, destination) end |
#invoke! ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ing/actions/create_link.rb', line 40 def invoke! invoke_with_conflict_check do FileUtils.mkdir_p(File.dirname(destination)) # Create a symlink by default config[:symbolic] = true if config[:symbolic].nil? File.unlink(destination) if exists? if config[:symbolic] File.symlink(render, destination) else File.link(render, destination) end end given_destination end |