-
Notifications
You must be signed in to change notification settings - Fork 30
/
configuration.rb
51 lines (39 loc) · 1.06 KB
/
configuration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'faraday'
require_relative 'version'
module TeamCity
module Configuration
VALID_OPTIONS_KEYS = [
:adapter,
:endpoint,
:user_agent,
:http_user,
:http_password
].freeze
DEFAULT_ADAPTER = Faraday.default_adapter
DEFAULT_ENDPOINT = 'http://teamcity:8111/httpAuth/app/rest/'.freeze
DEFAULT_USER_AGENT = "TeamCity Ruby Client #{TeamCity::VERSION}".freeze
DEFAULT_HTTP_USER = nil
DEFAULT_HTTP_PASSWORD = nil
DEFAULT_FORMAT = :json
attr_accessor *VALID_OPTIONS_KEYS
def self.extended(base)
base.reset
end
def configure
yield self
end
def options
VALID_OPTIONS_KEYS.inject({}) do |option, key|
option.merge!(key => send(key))
end
end
# Reset all configuration options to defaults
def reset
self.adapter = DEFAULT_ADAPTER
self.endpoint = DEFAULT_ENDPOINT
self.user_agent = DEFAULT_USER_AGENT
self.http_user = DEFAULT_HTTP_USER
self.http_password = DEFAULT_HTTP_PASSWORD
end
end
end