Class: FlowEngine::CLI::FlowLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/flowengine/cli/flow_loader.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FlowLoader

Returns a new instance of FlowLoader.



10
11
12
13
# File 'lib/flowengine/cli/flow_loader.rb', line 10

def initialize(path)
  @path = File.expand_path(path)
  validate_path!
end

Class Method Details

.load(path) ⇒ Object



6
7
8
# File 'lib/flowengine/cli/flow_loader.rb', line 6

def self.load(path)
  new(path).load
end

Instance Method Details

#loadObject



15
16
17
18
19
20
21
22
23
# File 'lib/flowengine/cli/flow_loader.rb', line 15

def load
  content = File.read(@path)
  # Evaluate in a clean binding that has FlowEngine available
  # rubocop:disable Security/Eval
  eval(content, TOPLEVEL_BINDING.dup, @path, 1)
  # rubocop:enable Security/Eval
rescue SyntaxError => e
  raise FlowEngine::CLI::Error, "Syntax error in #{@path}: #{e.message}"
end