Class: CircleCi::Config
- Inherits:
-
Object
- Object
- CircleCi::Config
- Defined in:
- lib/circleci/config.rb
Overview
Config class used internally. Configure API calls using CircleCi.configure
Constant Summary collapse
- DEFAULT_VERSION =
'v1.1'.freeze
- DEFAULT_HOST =
'https://circleci.com'.freeze
- DEFAULT_URI =
"#{DEFAULT_HOST}/api/#{DEFAULT_VERSION}".freeze
- DEFAULT_PORT =
443
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#port ⇒ Object
Returns the value of attribute port.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#proxy_host ⇒ Object
Returns the value of attribute proxy_host.
-
#proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
-
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
-
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
-
#request_overrides ⇒ Object
Returns the value of attribute request_overrides.
-
#token ⇒ Object
Returns the value of attribute token.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(host: DEFAULT_HOST, port: DEFAULT_PORT, proxy: nil, version: DEFAULT_VERSION, token: nil, request_overrides: {}, logger: nil) ⇒ Config
constructor
rubocop:disable Metrics/ParameterLists.
- #proxy_to_port ⇒ Object
- #proxy_uri ⇒ Object
- #proxy_userinfo? ⇒ Boolean
-
#uri ⇒ Object
rubocop:enable Metrics/ParameterLists.
Constructor Details
#initialize(host: DEFAULT_HOST, port: DEFAULT_PORT, proxy: nil, version: DEFAULT_VERSION, token: nil, request_overrides: {}, logger: nil) ⇒ Config
rubocop:disable Metrics/ParameterLists
21 22 23 24 25 26 27 28 29 |
# File 'lib/circleci/config.rb', line 21 def initialize(host: DEFAULT_HOST, port: DEFAULT_PORT, proxy: nil, version: DEFAULT_VERSION, token: nil, request_overrides: {}, logger: nil) @host = host @port = port @proxy = proxy.nil? ? false : proxy @version = version @token = token @request_overrides = request_overrides @logger = logger || Logger.new(STDOUT) end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def logger @logger end |
#port ⇒ Object
Returns the value of attribute port.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def port @port end |
#proxy ⇒ Object
Returns the value of attribute proxy.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def proxy @proxy end |
#proxy_host ⇒ Object
Returns the value of attribute proxy_host.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def proxy_user @proxy_user end |
#request_overrides ⇒ Object
Returns the value of attribute request_overrides.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def request_overrides @request_overrides end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def token @token end |
#version ⇒ Object
Returns the value of attribute version.
14 15 16 |
# File 'lib/circleci/config.rb', line 14 def version @version end |
Instance Method Details
#proxy_to_port ⇒ Object
40 41 42 |
# File 'lib/circleci/config.rb', line 40 def proxy_to_port proxy_port || 80 end |
#proxy_uri ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/circleci/config.rb', line 44 def proxy_uri return unless @proxy && proxy_host host_uri = URI.parse(proxy_host) userinfo = proxy_userinfo? ? "#{proxy_user}:#{proxy_pass}@" : '' URI.parse("#{host_uri.scheme}://#{userinfo}#{host_uri.host}:#{proxy_to_port}#{host_uri.path}") end |
#proxy_userinfo? ⇒ Boolean
36 37 38 |
# File 'lib/circleci/config.rb', line 36 def proxy_userinfo? proxy_user && proxy_pass end |
#uri ⇒ Object
rubocop:enable Metrics/ParameterLists
32 33 34 |
# File 'lib/circleci/config.rb', line 32 def uri URI.parse("#{@host || DEFAULT_HOST}:#{@port || DEFAULT_PORT}/api/#{@version || DEFAULT_VERSION}") end |