-
Notifications
You must be signed in to change notification settings - Fork 51
/
default.rb
79 lines (64 loc) · 1.74 KB
/
default.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
module Dnsimple
# Default configuration options for {Client}
module Default
# Default API endpoint
BASE_URL = "https://api.dnsimple.com/".freeze
# Default User Agent header
USER_AGENT = "dnsimple-ruby/#{VERSION}".freeze
class << self
# List of configurable keys for {Client}
# @return [Array] of option keys
def keys
@keys ||= [
:base_url,
:username,
:password,
:access_token,
:domain_api_token,
:user_agent,
:proxy,
]
end
# Configuration options
# @return [Hash]
def options
Hash[keys.map { |key| [key, send(key)] }]
end
# Default API endpoint from ENV or {BASE_URL}
# @return [String]
def base_url
ENV['DNSIMPLE_BASE_URL'] || BASE_URL
end
# Default DNSimple username for Basic Auth from ENV
# @return [String]
def username
ENV['DNSIMPLE_USERNAME']
end
# Default DNSimple password for Basic Auth from ENV
# @return [String]
def password
ENV['DNSIMPLE_PASSWORD']
end
# Default DNSimple access token for OAuth authentication from ENV
# @return [String]
def access_token
ENV['DNSIMPLE_ACCESS_TOKEN']
end
# Default DNSimple Domain API Token for Token Auth from ENV
# @return [String]
def domain_api_token
ENV['DNSIMPLE_API_DOMAIN_TOKEN']
end
# Default User-Agent header string from ENV
# @return [String]
def user_agent
ENV['DNSIMPLE_USER_AGENT']
end
# Default Proxy address:port from ENV
# @return [String]
def proxy
ENV['DNSIMPLE_PROXY']
end
end
end
end