Sha256: c0a6ddb14317331b82b97ac6d45327e4540d8d804438386d5eac20baa19dffc7
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module Gitlab # Defines constants and methods related to configuration. module Configuration # An array of valid keys in the options hash when configuring a Gitlab::API. VALID_OPTIONS_KEYS = [:endpoint, :private_token, :user_agent, :sudo].freeze # The user agent that will be sent to the API endpoint if none is set. DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}".freeze # @private attr_accessor(*VALID_OPTIONS_KEYS) # Sets all configuration options to their default values # when this module is extended. def self.extended(base) base.reset end # Convenience method to allow configuration options to be set in a block. def configure yield self end # Creates a hash of options and their values. def options VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end # Resets all configuration options to the defaults. def reset self.endpoint = ENV['GITLAB_API_ENDPOINT'] self.private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] self.sudo = nil self.user_agent = DEFAULT_USER_AGENT end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitlab-3.2.0 | lib/gitlab/configuration.rb |
gitlab-3.1.0 | lib/gitlab/configuration.rb |