Class: Grntest::Executors::StandardIOExecutor

Inherits:
BaseExecutor
  • Object
show all
Defined in:
lib/grntest/executors/standard-io-executor.rb

Instance Attribute Summary

Attributes inherited from BaseExecutor

#context

Instance Method Summary collapse

Methods inherited from BaseExecutor

#execute, #shutdown

Constructor Details

#initialize(input, output, context) ⇒ StandardIOExecutor

Returns a new instance of StandardIOExecutor.



21
22
23
24
25
# File 'lib/grntest/executors/standard-io-executor.rb', line 21

def initialize(input, output, context)
  super(context)
  @input = input
  @output = output
end

Instance Method Details

#create_sub_executor(context) ⇒ Object



50
51
52
# File 'lib/grntest/executors/standard-io-executor.rb', line 50

def create_sub_executor(context)
  self.class.new(@input, @output, context)
end

#ensure_groonga_readyObject



44
45
46
47
48
# File 'lib/grntest/executors/standard-io-executor.rb', line 44

def ensure_groonga_ready
  @input.print("status\n")
  @input.flush
  @output.gets
end

#send_command(command) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/grntest/executors/standard-io-executor.rb', line 27

def send_command(command)
  command_line = command.original_source
  if !command.key?(:output_type) and @output_type
    command_line = command_line.sub(/$/, " --output_type #{@output_type}")
  end
  begin
    debug_input(command_line)
    @input.print(command_line)
    @input.print("\n")
    @input.flush
  rescue SystemCallError
    message = "failed to write to groonga: <#{command_line}>: #{$!}"
    raise Error.new(message)
  end
  read_output(command)
end