Class: Jrf::Runner
- Inherits:
-
Object
- Object
- Jrf::Runner
- Defined in:
- lib/jrf/runner.rb
Constant Summary collapse
- RS_CHAR =
"\x1e"
Instance Method Summary collapse
-
#initialize(input: ARGF, out: $stdout, err: $stderr, lax: false, pretty: false) ⇒ Runner
constructor
A new instance of Runner.
- #run(expression, verbose: false) ⇒ Object
Constructor Details
#initialize(input: ARGF, out: $stdout, err: $stderr, lax: false, pretty: false) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 16 17 |
# File 'lib/jrf/runner.rb', line 11 def initialize(input: ARGF, out: $stdout, err: $stderr, lax: false, pretty: false) @input = input @out = out @err = err @lax = lax @pretty = pretty end |
Instance Method Details
#run(expression, verbose: false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jrf/runner.rb', line 19 def run(expression, verbose: false) parsed = PipelineParser.new(expression).parse stages = parsed[:stages] dump_stages(stages) if verbose blocks = stages.map { |stage| eval("proc { #{stage[:src]} }", nil, "(jrf stage)", 1) # rubocop:disable Security/Eval } pipeline = Pipeline.new(*blocks) input_enum = Enumerator.new { |y| each_input_value { |v| y << v } } pipeline.call(input_enum) do |value| @out.puts(@pretty ? JSON.pretty_generate(value) : JSON.generate(value)) end end |