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
20 21 22 23 24 25 26 27 28 |
# File 'lib/circleci/config.rb', line 20 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 : Logger.new(STDOUT) end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def logger @logger end |
#port ⇒ Object
Returns the value of attribute port.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def port @port end |
#proxy ⇒ Object
Returns the value of attribute proxy.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def proxy @proxy end |
#proxy_host ⇒ Object
Returns the value of attribute proxy_host.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def proxy_user @proxy_user end |
#request_overrides ⇒ Object
Returns the value of attribute request_overrides.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def request_overrides @request_overrides end |
#token ⇒ Object
Returns the value of attribute token.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def token @token end |
#version ⇒ Object
Returns the value of attribute version.
13 14 15 |
# File 'lib/circleci/config.rb', line 13 def version @version end |
Instance Method Details
#proxy_to_port ⇒ Object
39 40 41 |
# File 'lib/circleci/config.rb', line 39 def proxy_to_port proxy_port ? proxy_port : 80 end |
#proxy_uri ⇒ Object
43 44 45 46 47 48 |
# File 'lib/circleci/config.rb', line 43 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
35 36 37 |
# File 'lib/circleci/config.rb', line 35 def proxy_userinfo? proxy_user && proxy_pass end |
#uri ⇒ Object
rubocop:enable Metrics/ParameterLists
31 32 33 |
# File 'lib/circleci/config.rb', line 31 def uri URI.parse("#{@host || DEFAULT_HOST}:#{@port || DEFAULT_PORT}/api/#{@version || DEFAULT_VERSION}") end |