Class: Roast::Workflow::ConfigurationParser

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
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.



19
20
21
22
23
24
25
26
27
# File 'lib/roast/workflow/configuration_parser.rb', line 19

def initialize(workflow_path, files = [], options = {})
  @configuration = Configuration.new(workflow_path, options)
  @options = options
  @files = files
  @replay_processed = false # Initialize replay tracking
  include_tools
  load_roast_initializers
  configure_api_client
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



15
16
17
# File 'lib/roast/workflow/configuration_parser.rb', line 15

def configuration
  @configuration
end

#current_workflowObject (readonly)

Returns the value of attribute current_workflow.



15
16
17
# File 'lib/roast/workflow/configuration_parser.rb', line 15

def current_workflow
  @current_workflow
end

#filesObject (readonly)

Returns the value of attribute files.



15
16
17
# File 'lib/roast/workflow/configuration_parser.rb', line 15

def files
  @files
end

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/roast/workflow/configuration_parser.rb', line 15

def options
  @options
end

Instance Method Details

#begin!Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/roast/workflow/configuration_parser.rb', line 29

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

  name = configuration.basename
  context_path = configuration.context_path

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

  if files.any?
    $stderr.puts "WARNING: Ignoring target parameter because files were provided: #{configuration.target}" if configuration.has_target?
    files.each do |file|
      $stderr.puts "Running workflow for file: #{file}"
      setup_workflow(file.strip, name:, context_path:)
      parse(configuration.steps)
    end
  elsif configuration.has_target?
    configuration.target.lines.each do |file|
      $stderr.puts "Running workflow for file: #{file.strip}"
      setup_workflow(file.strip, name:, context_path:)
      parse(configuration.steps)
    end
  else
    # Handle targetless workflow - run once without a specific target
    $stderr.puts "Running targetless workflow"
    setup_workflow(nil, name:, context_path:)
    parse(configuration.steps)
  end
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