Class: Mandy::TestRunner
- Inherits:
-
Object
- Object
- Mandy::TestRunner
- Defined in:
- lib/mandy/test_runner.rb
Defined Under Namespace
Classes: CompositeJobRunner
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(job = Mandy::Job.jobs.first.name, opts = {}) ⇒ TestRunner
constructor
A new instance of TestRunner.
- #map(input_stream, output_stream = StringIO.new(''), &blk) ⇒ Object
- #reduce(input_stream, output_stream = StringIO.new(''), &blk) ⇒ Object
Constructor Details
#initialize(job = Mandy::Job.jobs.first.name, opts = {}) ⇒ TestRunner
Returns a new instance of TestRunner.
5 6 7 8 |
# File 'lib/mandy/test_runner.rb', line 5 def initialize(job=Mandy::Job.jobs.first.name, opts={}) ENV[Mandy::Job::JSON_PAYLOAD_KEY] = opts[:parameters].to_json @job = Mandy::Job.find_by_name(job) end |
Instance Attribute Details
#job ⇒ Object (readonly)
Returns the value of attribute job.
3 4 5 |
# File 'lib/mandy/test_runner.rb', line 3 def job @job end |
Class Method Details
.end_to_end(verbose = false) ⇒ Object
26 27 28 |
# File 'lib/mandy/test_runner.rb', line 26 def self.end_to_end(verbose=false) CompositeJobRunner.new(Mandy::Job.jobs,verbose) end |
Instance Method Details
#map(input_stream, output_stream = StringIO.new(''), &blk) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mandy/test_runner.rb', line 10 def map(input_stream, output_stream=StringIO.new(''), &blk) input_stream = input_from_array(input_stream) if input_stream.is_a?(Array) input_stream = StringIO.new(input_stream) if input_stream.is_a?(String) @job.run_map(input_stream, output_stream, &blk) output_stream.rewind output_stream end |
#reduce(input_stream, output_stream = StringIO.new(''), &blk) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/mandy/test_runner.rb', line 18 def reduce(input_stream, output_stream=StringIO.new(''), &blk) input_stream = input_from_hash(input_stream) if input_stream.is_a?(Hash) input_stream = StringIO.new(input_stream) if input_stream.is_a?(String) @job.run_reduce(input_stream, output_stream, &blk) output_stream.rewind output_stream end |