Module: PipelineToolkit::Cucumber::PipelineIO

Included in:
Machine
Defined in:
lib/pipeline_toolkit/cucumber/pipeline_io.rb

Overview

Provides IO methods for reading and writting pipeline messages to an IOProcess. NB: It is assumed that the module is being included in a IOProcess or subclass of.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#all_messagesObject (readonly)

Returns the value of attribute all_messages.



11
12
13
# File 'lib/pipeline_toolkit/cucumber/pipeline_io.rb', line 11

def all_messages
  @all_messages
end

Instance Method Details

#get_messages(number, timeout = 5) ⇒ Object

Gets output from process, and decodes it into a pipeline message



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pipeline_toolkit/cucumber/pipeline_io.rb', line 14

def get_messages(number, timeout = 5)
  output_msgs = []
  get_lines(@process.stdout, number, timeout) do |line|
    msg = MessageCoder.decode(line)
    output_msgs << msg
  end
  
  @all_messages ||= []
  @all_messages.concat(output_msgs)
  
  output_msgs
end

#input_messages(messages, simulate_acks = false) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/pipeline_toolkit/cucumber/pipeline_io.rb', line 27

def input_messages(messages, simulate_acks = false)
  messages.each do |message|
    simulate_ack_id(message) if simulate_acks
    @process.stdin.puts(MessageCoder.encode(message))
    @process.stdin.flush
  end
end