Class: Igniter::Extensions::Contracts::Creator::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/extensions/contracts/creator/writer.rb

Constant Summary collapse

VALID_MODES =
%i[skip_existing overwrite].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path(root.to_s)
  @mode = normalize_mode(mode)
  freeze
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



15
16
17
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 15

def mode
  @mode
end

#rootObject (readonly)

Returns the value of attribute root.



15
16
17
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 15

def root
  @root
end

#workflowObject (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

#planObject



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

#scaffoldObject



24
25
26
# File 'lib/igniter/extensions/contracts/creator/writer.rb', line 24

def scaffold
  workflow.scaffold
end

#writeObject



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