Sha256: 5663af4712e5258c5fa76a65d8f9f95c992ecbebd6ea1c5319bb8a3037992f89

Contents?: true

Size: 1.61 KB

Versions: 9

Compression:

Stored size: 1.61 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

        # TODO: allow overriding here. Maybe through self-registration process
        def plugin
          @provider
        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

9 entries across 9 versions & 1 rubygems

Version Path
chronicle-etl-0.5.5 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.5.4 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.5.3 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.5.2 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.5.1 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.5.0 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.4.4 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.4.3 lib/chronicle/etl/registry/connector_registration.rb
chronicle-etl-0.4.2 lib/chronicle/etl/registry/connector_registration.rb