Sha256: 18ea66974bef77cd523ccbcdf84dbacf162102b227f334125503296fff02b26b

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'deep_merge'

module Chronicle
  module ETL
    class JobDefinition
      SKELETON_DEFINITION = {
        extractor: {
          name: nil,
          options: {}
        },
        transformer: {
          name: nil,
          options: {}
        },
        loader: {
          name: nil,
          options: {}
        }
      }.freeze

      attr_accessor :definition

      def initialize()
        @definition = SKELETON_DEFINITION
      end

      # Add config hash to this definition
      def add_config(config = {})
        @definition = config.deep_merge(@definition)
        load_credentials
        validate
      end

      private

      def load_credentials
        Chronicle::ETL::Catalog::PHASES.each do |phase|
          credentials_name = @definition[phase][:options][:credentials]
          if credentials_name
            credentials = Chronicle::ETL::Config.load_credentials(credentials_name)
            @definition[phase][:options].deep_merge(credentials)
          end
        end
      end

      def validate
        return true   # TODO
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chronicle-etl-0.2.4 lib/chronicle/etl/job_definition.rb
chronicle-etl-0.2.3 lib/chronicle/etl/job_definition.rb