Sha256: 7d3a744614d1ef26cbf3146e749137e5a570876b54c5067d0ae0464fd25b4f56

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

module Chronicle
  module ETL
    module Registry
      # Records details about a connector such as its provider and a description
      class ConnectorRegistration
        # FIXME: refactor custom accessor methods later in file
        attr_accessor :identifier, :provider, :klass, :description

        def initialize(klass)
          @klass = klass
        end

        def phase
          if klass.ancestors.include? Chronicle::ETL::Extractor
            :extractor
          elsif klass.ancestors.include? Chronicle::ETL::Transformer
            :transformer
          elsif klass.ancestors.include? Chronicle::ETL::Loader
            :loader
          end
        end

        def to_s
          "#{phase}-#{identifier}"
        end

        def built_in?
          @klass.to_s.include? 'Chronicle::ETL'
        end

        def klass_name
          @klass.to_s
        end

        def identifier
          @identifier || @klass.to_s.split('::').last.gsub!(/(Extractor$|Loader$|Transformer$)/, '').downcase
        end

        def description
          @description || @klass.to_s.split('::').last
        end

        def provider
          @provider || (built_in? ? 'chronicle' : '')
        end

        def descriptive_phrase
          prefix = case phase
          when :extractor
            "Extracts from"
          when :transformer
            "Transforms"
          when :loader
            "Loads to"
          end

          "#{prefix} #{description}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chronicle-etl-0.4.1 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.4.0 lib/chronicle/etl/registry/connector_registration.rb