Class: Inquirex::TTY::FlowLoader
- Inherits:
-
Object
- Object
- Inquirex::TTY::FlowLoader
- Defined in:
- lib/inquirex/tty/flow_loader.rb
Overview
Loads a flow definition from a Ruby file by evaluating it in a top-level
binding. The file is expected to call Inquirex.define and return an
Inquirex::Definition.
Class Method Summary collapse
-
.load(path) ⇒ Inquirex::Definition
Loads and evaluates a flow definition file in one call.
Instance Method Summary collapse
-
#initialize(path) ⇒ FlowLoader
constructor
A new instance of FlowLoader.
- #load ⇒ Inquirex::Definition
Constructor Details
#initialize(path) ⇒ FlowLoader
Returns a new instance of FlowLoader.
23 24 25 26 |
# File 'lib/inquirex/tty/flow_loader.rb', line 23 def initialize(path) @path = File.(path) validate_path! end |
Class Method Details
.load(path) ⇒ Inquirex::Definition
Loads and evaluates a flow definition file in one call.
18 19 20 |
# File 'lib/inquirex/tty/flow_loader.rb', line 18 def self.load(path) new(path).load end |
Instance Method Details
#load ⇒ Inquirex::Definition
30 31 32 33 34 35 36 37 |
# File 'lib/inquirex/tty/flow_loader.rb', line 30 def load content = File.read(@path) # rubocop:disable Security/Eval eval(content, TOPLEVEL_BINDING.dup, @path, 1) # rubocop:enable Security/Eval rescue SyntaxError => e raise Inquirex::TTY::Error, "Syntax error in #{@path}: #{e.}" end |