Sha256: b00530cd2d39373eccc00ee8621cc66295f2b376dc782655d44fe8d0e2608f33

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'config/factory'
require 'uri'

class SourceConfig
  include Config::Factory

  key :protocol

  attr_reader :source_uri

  def initialize(source_url:)
    @source_uri = URI(source_url)
  end
end

class OAISourceConfig < SourceConfig
  protocol 'OAI'

  attr_reader :oai_base_url
  attr_reader :metadata_prefix
  attr_reader :set
  attr_reader :seconds_granularity

  def initialize(oai_base_url:, metadata_prefix:, set: nil, seconds_granularity: false)
    super(source_url: oai_base_url)
    @oai_base_url = source_uri
    @metadata_prefix = metadata_prefix
    @set = set
    @seconds_granularity = seconds_granularity
  end
end

class ResyncSourceConfig < SourceConfig
  protocol 'Resync'

  attr_reader :capability_list_url

  def initialize(capability_list_url:)
    super(url: capability_list_url)
    @capability_list_url = source_uri
  end
end

class DBConfig
  include Config::Factory

  attr_reader :connection_info

  def initialize(connection_info)
    @connection_info = connection_info
  end
end

# IndexConfig

class IndexConfig
  include Config::Factory

  key :adapter

  attr_reader :uri

  def initialize(url:)
    @uri = URI(url)
  end
end

class SolrConfig < IndexConfig
  adapter 'Solr'

  attr_reader :url
  attr_reader :proxy
  attr_reader :open_timeout
  attr_reader :read_timeout

  def initialize(url:, proxy: nil, open_timeout: 60, read_timeout: 120)
    super(url: url)
    @url = uri
    @proxy = proxy
    @open_timeout = open_timeout
    @read_timeout = read_timeout
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
config-factory-0.0.7 spec/unit/config/factory/fixtures.rb