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
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.
17 18 19 20 |
# File 'lib/inquirex/tty/flow_loader.rb', line 17 def initialize(path) @path = File.(path) validate_path! end |
Class Method Details
.load(path) ⇒ Inquirex::Definition
12 13 14 |
# File 'lib/inquirex/tty/flow_loader.rb', line 12 def self.load(path) new(path).load end |
Instance Method Details
#load ⇒ Inquirex::Definition
24 25 26 27 28 29 30 31 |
# File 'lib/inquirex/tty/flow_loader.rb', line 24 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 |