Class: Roast::Workflow::ConfigurationParser

Inherits:
Object
  • Object
show all
Defined in:
lib/roast/workflow/configuration_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_path, files = [], options = {}) ⇒ ConfigurationParser

Returns a new instance of ConfigurationParser.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/roast/workflow/configuration_parser.rb', line 10

def initialize(workflow_path, files = [], options = {})
  @configuration = Configuration.new(workflow_path, options)
  @options = options
  @files = files

  # Initialize workflow dependencies
  initializer = WorkflowInitializer.new(@configuration)
  initializer.setup

  @workflow_runner = WorkflowRunner.new(@configuration, @options)
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



6
7
8
# File 'lib/roast/workflow/configuration_parser.rb', line 6

def configuration
  @configuration
end

#current_workflowObject (readonly)

Returns the value of attribute current_workflow.



6
7
8
# File 'lib/roast/workflow/configuration_parser.rb', line 6

def current_workflow
  @current_workflow
end

#filesObject (readonly)

Returns the value of attribute files.



6
7
8
# File 'lib/roast/workflow/configuration_parser.rb', line 6

def files
  @files
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/roast/workflow/configuration_parser.rb', line 6

def options
  @options
end

Instance Method Details

#begin!Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/roast/workflow/configuration_parser.rb', line 22

def begin!
  start_time = Time.now
  $stderr.puts "Starting workflow..."
  $stderr.puts "Workflow: #{configuration.workflow_path}"
  $stderr.puts "Options: #{options}"

  ActiveSupport::Notifications.instrument("roast.workflow.start", {
    workflow_path: configuration.workflow_path,
    options: options,
    name: configuration.basename,
  })

  if files.any?
    @workflow_runner.run_for_files(files)
  elsif configuration.has_target?
    @workflow_runner.run_for_targets
  else
    @workflow_runner.run_targetless
  end
rescue Roast::Errors::ExitEarly
  $stderr.puts "Exiting workflow early."
ensure
  execution_time = Time.now - start_time

  ActiveSupport::Notifications.instrument("roast.workflow.complete", {
    workflow_path: configuration.workflow_path,
    success: !$ERROR_INFO,
    execution_time: execution_time,
  })
end