Class: MiniEtl::Process

Inherits:
Object
  • Object
show all
Includes:
Status
Defined in:
lib/mini_etl/process.rb

Overview

ETL Process wrapper Should this go all the way? Probably

Constant Summary collapse

VALID_STATES =
{
  initialized: 0,
  bootstrapped: 1,
  generated: 2,
  finished: 3,
  failed: 4
}.freeze

Constants included from Status

Status::DEFAULT_STATES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Status

included

Constructor Details

#initializeProcess

Returns a new instance of Process.



19
20
21
22
23
24
# File 'lib/mini_etl/process.rb', line 19

def initialize
  @source = Source.new
  @generator = Generator.new

  initialized!
end

Instance Attribute Details

#generatorObject (readonly)

Returns the value of attribute generator.



17
18
19
# File 'lib/mini_etl/process.rb', line 17

def generator
  @generator
end

#sourceObject (readonly)

Returns the value of attribute source.



17
18
19
# File 'lib/mini_etl/process.rb', line 17

def source
  @source
end

Instance Method Details

#bootstrapObject



26
27
28
29
30
31
32
33
34
# File 'lib/mini_etl/process.rb', line 26

def bootstrap
  if initialized? && @source.validate
    @source.fetch
    @generator.bootstrap(@source.type, @source.payload)
    bootstrapped!
  else
    failed!
  end
end

#generateObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mini_etl/process.rb', line 36

def generate
  # TODO: Parse it, bear in mind this will be in memory and may need to be split
  # TODO: Transform it into useful bits
  # This may be done in rails. Provide a useful interface in that case
  # TODO: Load the thing wherever it needs to go
  if bootstrapped?
    @generator.transform
    generated!
  else
    failed!
  end
end