Class: Freyia::Automations::EmptyDirectory
- Inherits:
-
Object
- Object
- Freyia::Automations::EmptyDirectory
- Defined in:
- lib/freyia/automations/empty_directory.rb
Overview
Class which holds create directory logic. This is the base class for other automations like create_file and directory.
This implementation is based in Templater automations, created by Jonas Nicklas and Michael S. Klishin under MIT LICENSE.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#given_destination ⇒ Object
readonly
Returns the value of attribute given_destination.
-
#relative_destination ⇒ Object
readonly
Returns the value of attribute relative_destination.
Instance Method Summary collapse
- #call ⇒ Object
-
#exists? ⇒ Boolean
Checks if the destination file already exists.
-
#initialize(base, destination, **config) ⇒ EmptyDirectory
constructor
Initializes given the source and destination.
Constructor Details
#initialize(base, destination, **config) ⇒ EmptyDirectory
Initializes given the source and destination.
Parameters
32 33 34 35 36 |
# File 'lib/freyia/automations/empty_directory.rb', line 32 def initialize(base, destination, **config) @base = base @config = { verbose: true }.merge(config) self.destination = destination end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
22 23 24 |
# File 'lib/freyia/automations/empty_directory.rb', line 22 def base @base end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/freyia/automations/empty_directory.rb', line 22 def config @config end |
#destination ⇒ Object
Returns the value of attribute destination.
22 23 24 |
# File 'lib/freyia/automations/empty_directory.rb', line 22 def destination @destination end |
#given_destination ⇒ Object (readonly)
Returns the value of attribute given_destination.
22 23 24 |
# File 'lib/freyia/automations/empty_directory.rb', line 22 def given_destination @given_destination end |
#relative_destination ⇒ Object (readonly)
Returns the value of attribute relative_destination.
22 23 24 |
# File 'lib/freyia/automations/empty_directory.rb', line 22 def relative_destination @relative_destination end |
Instance Method Details
#call ⇒ Object
45 46 47 48 49 50 |
# File 'lib/freyia/automations/empty_directory.rb', line 45 def call invoke_with_conflict_check do require "fileutils" ::FileUtils.mkdir_p(destination) end end |
#exists? ⇒ Boolean
Checks if the destination file already exists.
41 42 43 |
# File 'lib/freyia/automations/empty_directory.rb', line 41 def exists? ::File.exist?(destination) end |