8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/kumi/frontends/ruby.rb', line 8
def load(path:, inputs: {})
mod = Module.new
mod.extend(Kumi::Schema)
mod.module_eval(File.read(path), path)
schema_ast = if mod.const_defined?(:GoldenSchema)
golden = mod.const_get(:GoldenSchema)
golden.build if golden.respond_to?(:build)
golden.__syntax_tree__
elsif mod.__syntax_tree__
mod.__syntax_tree__
else
raise "No schema AST found. Make sure the .rb file calls 'schema do...end'"
end
[schema_ast, inputs]
end
|