Class: Chicago::ETL::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/chicago/etl/pipeline.rb

Overview

An ETL pipeline.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, schema, &block) ⇒ Pipeline

Creates a pipeline for a Schema.



9
10
11
12
13
# File 'lib/chicago/etl/pipeline.rb', line 9

def initialize(db, schema, &block)
  @schema, @db = schema, db
  @stages = Chicago::Schema::NamedElementCollection.new
  @builder_class_factory = block || lambda {|name, options| StageBuilder }
end

Instance Attribute Details

#stagesObject (readonly)

Returns all the defined stages.



6
7
8
# File 'lib/chicago/etl/pipeline.rb', line 6

def stages
  @stages
end

Instance Method Details

#build_stage(name, options, &block) ⇒ Object



32
33
34
# File 'lib/chicago/etl/pipeline.rb', line 32

def build_stage(name, options, &block)
  builder(name, options).build(name, options, &block)
end

#define_stage(*args, &block) ⇒ Object

Defines a generic stage in the pipeline.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chicago/etl/pipeline.rb', line 16

def define_stage(*args, &block)
  options = args.last.kind_of?(Hash) ? args.pop : {}

  if args.last.kind_of?(Stage)
    stage = args.pop
    name = StageName.new(args)
  else
    name = StageName.new(args)
    stage = build_stage(name, options, &block)
  end

  stage.name = StageName.new(args)

  @stages << stage
end