Method: ETL#process

Defined in:
lib/etl/etl.rb

#process(options = {}, &block) ⇒ Object

Working towards a universal workflow driver here. The signature is just a hash and a block. That should work for about anything.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/etl/etl.rb', line 139

def process(options={}, &block)
  # Only setup the options the first time, the other times we are re-
  # starting the process. 
  @options = options unless @options
  @block = block

  self.class.logger.info "Processing #{self.class.to_s}"
  self.class.logger.info "To re-run this process, run: #{self.show_command}"
  self.class.logger.info "Note: Also pass the same block to #{self.class.to_s}" if block

  etl_callback(:before_extract)

  if @state == :extract
    extract 
    @state = :after_extract
  end

  etl_callback(:after_extract)

  # To be sure this is after all after_extract callbacks
  process_raw_data
  
  etl_callback(:before_transform)

  if @state == :transform
    transform
    @state = :after_transform
  end

  etl_callback(:after_transform)
  
  # To be sure this is after all after_tranform callbacks
  process_raw_data
  
  etl_callback(:before_load)

  if @state == :load
    load
    @state = :after_load
  end

  etl_callback(:after_load)
  @state
end