Class: Cure::Coordinator

Inherits:
Object
  • Object
show all
Includes:
Configuration, Database, Helpers::PerfHelpers, Log
Defined in:
lib/cure/coordinator.rb

Overview

Coordinates the entire process: Extract -> Build -> Transform -> Export

Instance Method Summary collapse

Methods included from Helpers::PerfHelpers

#print_memory_usage, #print_time_spent

Methods included from Configuration

#config, #create_config, #register_config

Methods included from Database

#database_service, #init_database

Methods included from Log

#log_debug, #log_error, #log_info, #log_trace, #log_warn

Instance Method Details

#processObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cure/coordinator.rb', line 24

def process
  # need to check config is init'd
  result = nil
  print_memory_usage do
    print_time_spent do
      # 1. Extract into SQLite
      extract
      # 2. Manipulate SQLite columns
      build
      # 3. Validate columns

      # 4. Transform each row
      with_tables.each do |table|
        with_transformer(table) do |transformer|
          with_exporters(table) do |exporters|
            database_service.with_paged_result(table) do |row|
              transformed_row = transformer.transform(row)
              exporters.each do |exporter|
                # 4. Export
                exporter.process_row(transformed_row)
              end
            end
          end
        end
      end
    end
  end

  result
end