Sha256: efbdd25bcd44737ca92edf1bae79b0cb510b57cfdf0b1b4b619dcd40d064a170
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 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'].freeze : Gem.host.freeze # Set the default credentials DEFAULT_KEY = Gem.configuration.rubygems_api_key.freeze # Set the default 'User-Agent' HTTP header DEFAULT_USER_AGENT = "Gems #{Gems::VERSION}".freeze 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gems-0.5.0 | lib/gems/configuration.rb |
gems-0.4.0 | lib/gems/configuration.rb |
gems-0.3.0 | lib/gems/configuration.rb |