Class: Igniter::Extensions::Contracts::Creator::Writer
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Creator::Writer
- Defined in:
- lib/igniter/extensions/contracts/creator/writer.rb
Constant Summary collapse
- VALID_MODES =
%i[skip_existing overwrite].freeze
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#workflow ⇒ Object
readonly
Returns the value of attribute workflow.
Instance Method Summary collapse
-
#initialize(workflow:, root:, mode: :skip_existing) ⇒ Writer
constructor
A new instance of Writer.
- #plan ⇒ Object
- #scaffold ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(workflow:, root:, mode: :skip_existing) ⇒ Writer
Returns a new instance of Writer.
17 18 19 20 21 22 |
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 17 def initialize(workflow:, root:, mode: :skip_existing) @workflow = workflow @root = File.(root.to_s) @mode = normalize_mode(mode) freeze end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
15 16 17 |
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 15 def mode @mode end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
15 16 17 |
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 15 def root @root end |
#workflow ⇒ Object (readonly)
Returns the value of attribute workflow.
15 16 17 |
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 15 def workflow @workflow end |
Instance Method Details
#plan ⇒ Object
28 29 30 |
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 28 def plan WriteResult.new(root: root, mode: mode, steps: plan_steps) end |
#scaffold ⇒ Object
24 25 26 |
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 24 def scaffold workflow.scaffold end |
#write ⇒ Object
32 33 34 |
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 32 def write WriteResult.new(root: root, mode: mode, steps: directory_steps + file_steps) end |