Module: Doem::Runner

Included in:
Doem
Defined in:
lib/doem/runner.rb

Overview

The runner for the whole process

Instance Method Summary collapse

Instance Method Details

#process_rows(providers, tweakers, consumers) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/doem/runner.rb', line 15

def process_rows(providers, tweakers, consumers)
  providers.each do |provider|
    provider.each do |row|
      tweakers.each do |tweaker|
        row = tweaker.tweak row
        break unless row
      end
      # nil means to dismiss the row
      next unless row
      consumers.each do |consumer|
        consumer << row
      end
    end
  end
  consumers.each do |consumer|
    consumer.build if consumer.respond_to? :build
    consumer.close if consumer.respond_to? :close
  end
end

#run(instruction) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/doem/runner.rb', line 4

def run(instruction)
  context = instruction.context
  context.pre_hooks.each(&:call)
  process_rows(
    context.providers,
    context.tweakers,
    context.consumers
  )
  context.post_hooks.each(&:call)
end