Class: Freyia::Automations::CreateLink
- Inherits:
-
CreateFile
- Object
- EmptyDirectory
- CreateFile
- Freyia::Automations::CreateLink
- Defined in:
- lib/freyia/automations/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
Returns the value of attribute data.
Attributes inherited from EmptyDirectory
#base, #config, #destination, #given_destination, #relative_destination
Instance Method Summary collapse
- #call ⇒ Object
- #exists? ⇒ Boolean
-
#identical? ⇒ Boolean
Checks if the content of the file at the destination is identical to the rendered result.
Methods inherited from CreateFile
Methods inherited from EmptyDirectory
Constructor Details
This class inherits a constructor from Freyia::Automations::CreateFile
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
24 25 26 |
# File 'lib/freyia/automations/create_link.rb', line 24 def data @data end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/freyia/automations/create_link.rb', line 34 def call invoke_with_conflict_check do require "fileutils" 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 |
#exists? ⇒ Boolean
50 |
# File 'lib/freyia/automations/create_link.rb', line 50 def exists? = super || File.symlink?(destination) |
#identical? ⇒ Boolean
Checks if the content of the file at the destination is identical to the rendered result.
29 30 31 32 |
# File 'lib/freyia/automations/create_link.rb', line 29 def identical? source = File.(render, File.dirname(destination)) exists? && File.identical?(source, destination) end |