lib/etl/engine.rb
# Initialization that is run when a job is executed.
# 
# Options:
# * <tt>:limit</tt>: Limit the number of records returned from sources
# * <tt>:offset</tt>: Specify the records for data from sources
# * <tt>:log_write_mode</tt>: If true then the log will write, otherwise it will append
# * <tt>:skip_bulk_import</tt>: Set to true to skip bulk import
# * <tt>:read_locally</tt>: Set to true to read from the local cache
# * <tt>:rails_root</tt>: Set to the rails root to boot rails
Initialization that is run when a job is executed.
Initialization that is run when a job is executed .
def init(options={})
        unless @initialized
          puts "initializing ETL engine\n\n"
          @limit = options[:limit]
          @offset = options[:offset]
          @log_write_mode = 'w' if options[:newlog]
          @skip_bulk_import = options[:skip_bulk_import]
          @read_locally = options[:read_locally]
          @rails_root = options[:rails_root]
          require File.join(@rails_root, 'config/environment') if @rails_root
          options[:config] ||= 'database.yml'
          options[:config] = 'config/database.yml' unless File.exist?(options[:config])
          database_configuration = YAML::load(ERB.new(IO.read(options[:config])).result + "\n")
          ActiveRecord::Base.configurations.merge!(database_configuration)
          ETL::Base.configurations = HashWithIndifferentAccess.new(database_configuration)
          require 'etl/execution'
          ETL::Execution::Base.establish_connection :etl_execution
          ETL::Execution::Execution.migrate
          @initialized = true
        end
      end
def init ( options = { } ) unless @initialized puts "initializing ETL engine\n\n" @limit = options [ :limit ] @offset = options [ :offset ] @log_write_mode = 'w' if options [ :newlog ] @skip_bulk_import = options [ :skip_bulk_import ] @read_locally = options [ :read_locally ] @rails_root = options [ :rails_root ] require File . join ( @rails_root , 'config/environment' ) if @rails_root options [ :config ] ||= 'database.yml' options [ :config ] = 'config/database.yml' unless File . exist? ( options [ :config ] ) database_configuration = YAML :: load ( ERB . new ( IO . read ( options [ :config ] ) ) . result + "\n" ) ActiveRecord :: Base . configurations . merge! ( database_configuration ) ETL :: Base . configurations = HashWithIndifferentAccess . new ( database_configuration ) require 'etl/execution' ETL :: Execution :: Base . establish_connection :etl_execution ETL :: Execution :: Execution . migrate @initialized = true end end
Initialization that is run when a job is executed.
Initialization that is run when a job is executed .
#puts "configurations in init: #{ActiveRecord::Base.configurations.inspect}"
options
<not_specific>