Class: Spark::Command::Pipe
- Inherits:
-
Object
- Object
- Spark::Command::Pipe
- Defined in:
- lib/spark/command/basic.rb
Overview
Pipe
Instance Method Summary collapse
Instance Method Details
#before_run ⇒ Object
296 297 298 299 300 |
# File 'lib/spark/command/basic.rb', line 296 def before_run require 'open3' @in, @out, @threads = Open3.pipeline_rw(*@cmds) end |
#lazy_run(iterator) ⇒ Object
318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/spark/command/basic.rb', line 318 def lazy_run(iterator, *) create_writing_thread(iterator) Enumerator::Lazy.new([nil]) do |yielder, _| begin loop { yielder << @out.readline.rstrip } rescue EOFError end end end |
#run(iterator) ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/spark/command/basic.rb', line 302 def run(iterator, *) create_writing_thread(iterator) new_iterator = [] # Read full input begin loop { new_iterator << @out.readline.rstrip } rescue EOFError end new_iterator end |