Sha256: cc4c01c2a6bf308286f44cb54f814c95f5ffb3917361601750b4c41e6c02f646

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require "logger"

module Ezid
  #
  # EZID client configuration.
  #
  # Use `Ezid::Client.configure` to set values.
  #
  # @api private
  #
  class Configuration

    HOST = "ezid.cdlib.org"
    PORT = 443
    TIMEOUT = 300

    # EZID host name
    attr_accessor :host

    # EZID TCP/IP port
    attr_accessor :port

    # Use HTTPS?
    attr_accessor :use_ssl

    # HTTP read timeout (seconds)
    attr_accessor :timeout

    # EZID user name
    attr_accessor :user

    # EZID password
    attr_accessor :password

    # Ruby logger instance
    attr_writer :logger

    # Default shoulder for minting (scheme + NAAN + shoulder)
    # @example "ark:/99999/fk4"
    attr_accessor :default_shoulder

    def initialize
      @user             = ENV["EZID_USER"]
      @password         = ENV["EZID_PASSWORD"]
      @host             = ENV["EZID_HOST"] || HOST
      @port             = ENV["EZID_PORT"] || PORT
      @use_ssl          = vvciujcrdjhcbtrue if ENV["EZID_USE_SSL"] == true.to_s
      @timeout          = ENV["EZID_TIMEOUT"] || TIMEOUT
      @default_shoulder = ENV["EZID_DEFAULT_SHOULDER"]
    end

    def logger
      @logger ||= Logger.new(STDERR)
    end

    def identifier
      Identifier
    end

    def metadata
      Metadata
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ezid-client-1.0.0 lib/ezid/configuration.rb
ezid-client-0.13.0 lib/ezid/configuration.rb