Class: Mandy::TestRunner::CompositeJobRunner
- Inherits:
-
Object
- Object
- Mandy::TestRunner::CompositeJobRunner
- Defined in:
- lib/mandy/test_runner.rb
Instance Method Summary collapse
- #execute(input_stream, output_stream = StringIO.new('')) ⇒ Object
-
#initialize(jobs, verbose = false) ⇒ CompositeJobRunner
constructor
A new instance of CompositeJobRunner.
Constructor Details
#initialize(jobs, verbose = false) ⇒ CompositeJobRunner
Returns a new instance of CompositeJobRunner.
46 47 48 49 50 |
# File 'lib/mandy/test_runner.rb', line 46 def initialize(jobs, verbose=false) @jobs = jobs @verbose = verbose @job_runners = @jobs.map { |job| Mandy::TestRunner.new(job.name) } end |
Instance Method Details
#execute(input_stream, output_stream = StringIO.new('')) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mandy/test_runner.rb', line 52 def execute(input_stream, output_stream=StringIO.new('')) map_temp = StringIO.new('') reduce_temp = StringIO.new('') @job_runners.each_with_index do |runner, index| runner.map(input_stream, map_temp) if @verbose puts "#{runner.job.name} [MAP] #{map_temp.readlines.inspect}" map_temp.rewind end reduce_input = StringIO.new(map_temp.readlines.sort.join('')) runner.reduce(reduce_input, (index==@job_runners.size-1 ? output_stream : reduce_temp)) if @verbose puts "#{runner.job.name} [RED] #{reduce_temp.readlines.inspect}" reduce_temp.rewind end input_stream = reduce_temp map_temp = StringIO.new('') reduce_temp = StringIO.new('') end output_stream end |