Sha256: 85087b7744fbff094a6eb9cd23e4423711dbf7c05868b2742dbdf6559430679d

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require "logger"

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

    HOST = "ezid.cdlib.org"

    # EZID host name
    #   Default: value of `EZID_HOST` environment variable, if present, or
    #   the EZID service host "ezid.cdlib.org".
    attr_accessor :host

    # Use HTTPS?
    #   Default: `true`, unless `EZID_USE_SSL` environment variable is set
    #   to the string "false".
    attr_accessor :use_ssl

    # EZID user name
    #   Default: value of `EZID_USER` environment variable
    attr_accessor :user

    # EZID password
    #   Default: value of `EZID_PASSWORD` environment variable
    attr_accessor :password

    # Ruby logger instance
    #   Default device: STDERR
    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
      @use_ssl          = ENV["EZID_USE_SSL"] != false.to_s
      @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-0.11.0 lib/ezid/configuration.rb
ezid-client-0.10.0 lib/ezid/configuration.rb