Module: Gemfury::Configuration

Included in:
Gemfury
Defined in:
lib/gemfury/configuration.rb

Overview

Defines constants and methods related to configuration

Constant Summary collapse

VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring

[
:user_api_key,
:adapter,
:endpoint,
:gitpoint,
:user_agent,
:api_version,
:account].freeze
DEFAULT_ADAPTER =

The adapter that will be used to connect if none is set

:net_http
DEFAULT_ENDPOINT =

The endpoint that will be used to connect if none is set

'https://api.fury.io/'.freeze
DEFAULT_GITPOINT =

The HTTP endpoint for git repo (used for .netrc credentials)

'https://git.fury.io/'.freeze
DEFAULT_USER_AGENT =

The value sent in the 'User-Agent' header if none is set

"Gemfury RubyGem #{Gemfury::VERSION}".freeze
DEFAULT_API_VERSION =

Default API version

1
DEFAULT_API_KEY =

Default user API key

nil
DEFAULT_ACCOUNT =

Use the current account (no impersonation)

nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values


39
40
41
# File 'lib/gemfury/configuration.rb', line 39

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:


44
45
46
# File 'lib/gemfury/configuration.rb', line 44

def configure
  yield self
end

#optionsObject

Create a hash of options and their values


49
50
51
52
53
# File 'lib/gemfury/configuration.rb', line 49

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
  options
end

#resetObject

Reset all configuration options to defaults


56
57
58
59
60
61
62
63
64
65
# File 'lib/gemfury/configuration.rb', line 56

def reset
  self.user_api_key       = DEFAULT_API_KEY
  self.adapter            = DEFAULT_ADAPTER
  self.endpoint           = DEFAULT_ENDPOINT
  self.gitpoint           = DEFAULT_GITPOINT
  self.user_agent         = DEFAULT_USER_AGENT
  self.api_version        = DEFAULT_API_VERSION
  self.            = DEFAULT_ACCOUNT
  self
end