Class: Confire::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/confire/processor.rb

Overview

This is where the main bits are processed

We can process lines and blocks here

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Processor

Returns a new instance of Processor.



7
8
9
10
11
# File 'lib/confire/processor.rb', line 7

def initialize(options = {})
  @logger = options[:logger]
  @custom_processor = options[:custom_processor]
  @custom_processor.logger = @logger if @custom_processor
end

Instance Attribute Details

#custom_processorObject

Returns the value of attribute custom_processor.



5
6
7
# File 'lib/confire/processor.rb', line 5

def custom_processor
  @custom_processor
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/confire/processor.rb', line 5

def logger
  @logger
end

Instance Method Details

#process_block(line_buffer, test_number) ⇒ Object

Will process a test case. Just return whatever we want to print out as results. line_buffer: an array of inputs. each line read is an element in the array test_number: the current test case number we are working on. probably won’t need this value



17
18
19
20
21
22
23
# File 'lib/confire/processor.rb', line 17

def process_block(line_buffer, test_number)
  if (@custom_processor && @custom_processor.class.method_defined?(:process_testcase))
    @custom_processor.process_testcase line_buffer
  else
    line_buffer
  end
end

#process_line(line) ⇒ Object

Process the line

Each of these lines get stored as an element in the line_buffer array

line: the line the process



28
29
30
31
32
33
34
# File 'lib/confire/processor.rb', line 28

def process_line(line)
  if (@custom_processor && @custom_processor.class.method_defined?(:process_line))
    @custom_processor.process_line line
  else
    line.split ' '
  end
end