Sha256: 3d66c821494ff1193e8add991e0a057f59c177c761221493890c71e0f86178b5
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
module Mandy class TestRunner def initialize(job=Mandy::Job.jobs.first.name) @job = Mandy::Job.find_by_name(job) end def map(input, output_stream=StringIO.new(''), &blk) input = input_from_array(input) if input.is_a?(Array) input_stream = StringIO.new(input.to_s) @job.run_map(input_stream, output_stream, &blk) output_stream.rewind output_stream end def reduce(input, output_stream=StringIO.new(''), &blk) input = input_from_hash(input) if input.is_a?(Hash) input_stream = StringIO.new(input.to_s) @job.run_reduce(input_stream, output_stream, &blk) output_stream.rewind output_stream end private def input_from_array(input) input.join("\n") end def input_from_hash(input) output = [] input.each do |key, values| output << "#{key}\t#{values}" and next unless values.is_a?(Array) values.each { |value| output << "#{key}\t#{value}" } end input_from_array(output.sort) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trafficbroker-mandy-0.1.5 | lib/test_runner.rb |
trafficbroker-mandy-0.1.6 | lib/test_runner.rb |