Sha256: 34a245c61bdc7ecbc1ddc0b99f309c84bd290a14d249f158362f460f855f9617

Contents?: true

Size: 1.3 KB

Versions: 74

Compression:

Stored size: 1.3 KB

Contents

require 'gems/version'
require 'rubygems'
require 'yaml'

module Gems
  module Configuration
    # An array of valid keys in the options hash when configuring a {Gems::Client}
    VALID_OPTIONS_KEYS = [
      :host,
      :key,
      :password,
      :user_agent,
      :username,
    ]

    # Set the default API endpoint
    DEFAULT_HOST = ENV['RUBYGEMS_HOST'] ? ENV['RUBYGEMS_HOST'] : "https://rubygems.org"

    # Set the default credentials
    DEFAULT_KEY = Gem.configuration.rubygems_api_key

    # Set the default 'User-Agent' HTTP header
    DEFAULT_USER_AGENT = "Gems #{Gems::VERSION}"

    attr_accessor *VALID_OPTIONS_KEYS

    # When this module is extended, set all configuration options to their default values
    def self.extended(base)
      base.reset
    end

    # Convenience method to allow configuration options to be set in a block
    def configure
      yield self
    end

    # Create a hash of options and their values
    def options
      options = {}
      VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
      options
    end

    # Reset all configuration options to defaults
    def reset
      self.host       = DEFAULT_HOST
      self.key        = DEFAULT_KEY
      self.password   = nil
      self.user_agent = DEFAULT_USER_AGENT
      self.username   = nil
      self
    end
  end
end

Version data entries

74 entries across 70 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/gems-0.8.3/lib/gems/configuration.rb