Class: Perkins::Build::Data
- Inherits:
-
Object
show all
- Defined in:
- lib/perkins/build/data.rb,
lib/perkins/build/data/env.rb,
lib/perkins/build/data/var.rb
Defined Under Namespace
Classes: Env, SshKey, Var
Constant Summary
collapse
- DEFAULTS =
{ }
- DEFAULT_CACHES =
{
apt: false,
bundler: false,
cocoapods: false,
composer: false
}
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data, defaults = {}) ⇒ Data
Returns a new instance of Data.
24
25
26
27
28
|
# File 'lib/perkins/build/data.rb', line 24
def initialize(data, defaults = {})
data = data.deep_symbolize_keys
defaults = defaults.deep_symbolize_keys
@data = DEFAULTS.deep_merge(defaults.deep_merge(data))
end
|
Instance Attribute Details
Returns the value of attribute data.
22
23
24
|
# File 'lib/perkins/build/data.rb', line 22
def data
@data
end
|
Instance Method Details
126
127
128
|
# File 'lib/perkins/build/data.rb', line 126
def api_url
repository[:api_url]
end
|
142
143
144
|
# File 'lib/perkins/build/data.rb', line 142
def branch
job[:branch]
end
|
154
155
156
|
# File 'lib/perkins/build/data.rb', line 154
def build
data[:source] || data[:build] || {} end
|
#cache(input = config[:cache]) ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/perkins/build/data.rb', line 58
def cache(input = config[:cache])
case input
when Hash then input
when Array then input.map { |e| cache(e) }.inject(:merge)
when String, Symbol then { input.to_sym => true }
when nil then {} when false then Hash[DEFAULT_CACHES.each_key.with_object(false).to_a]
else input.to_h
end
end
|
#cache?(type, default = DEFAULT_CACHES[type]) ⇒ Boolean
69
70
71
72
|
# File 'lib/perkins/build/data.rb', line 69
def cache?(type, default = DEFAULT_CACHES[type])
type &&= type.to_sym
!!cache.fetch(type) { default }
end
|
#cache_options ⇒ Object
54
55
56
|
# File 'lib/perkins/build/data.rb', line 54
def cache_options
data[:cache_options] || {}
end
|
138
139
140
|
# File 'lib/perkins/build/data.rb', line 138
def commit
job[:commit]
end
|
34
35
36
|
# File 'lib/perkins/build/data.rb', line 34
def config
data[:config]
end
|
74
75
76
|
# File 'lib/perkins/build/data.rb', line 74
def env_vars
@env_vars ||= Env.new(self).vars
end
|
#env_vars_groups ⇒ Object
78
79
80
|
# File 'lib/perkins/build/data.rb', line 78
def env_vars_groups
@env_vars_groups ||= Env.new(self).vars_groups
end
|
38
39
40
|
# File 'lib/perkins/build/data.rb', line 38
def hosts
data[:hosts] || {}
end
|
150
151
152
|
# File 'lib/perkins/build/data.rb', line 150
def job
data[:job] || {}
end
|
#paranoid_mode? ⇒ Boolean
42
43
44
|
# File 'lib/perkins/build/data.rb', line 42
def paranoid_mode?
data.fetch(:paranoid, false)
end
|
#pull_request ⇒ Object
114
115
116
|
# File 'lib/perkins/build/data.rb', line 114
def pull_request
job[:pull_request]
end
|
#raw_env_vars ⇒ Object
82
83
84
|
# File 'lib/perkins/build/data.rb', line 82
def raw_env_vars
data[:env_vars] || []
end
|
146
147
148
|
# File 'lib/perkins/build/data.rb', line 146
def ref
job[:ref]
end
|
#repository ⇒ Object
158
159
160
|
# File 'lib/perkins/build/data.rb', line 158
def repository
data[:repository] || {}
end
|
#secure_env_enabled? ⇒ Boolean
118
119
120
|
# File 'lib/perkins/build/data.rb', line 118
def secure_env_enabled?
job[:secure_env_enabled]
end
|
#skip_etc_hosts_fix? ⇒ Boolean
50
51
52
|
# File 'lib/perkins/build/data.rb', line 50
def skip_etc_hosts_fix?
data.fetch(:skip_etc_hosts_fix, false)
end
|
#skip_resolv_updates? ⇒ Boolean
46
47
48
|
# File 'lib/perkins/build/data.rb', line 46
def skip_resolv_updates?
data.fetch(:skip_resolv_updates, false)
end
|
134
135
136
|
# File 'lib/perkins/build/data.rb', line 134
def slug
repository[:slug]
end
|
#source_host ⇒ Object
122
123
124
|
# File 'lib/perkins/build/data.rb', line 122
def source_host
source_url =~ %r(^(?:https?|git)(?:://|@)([^/]*?)(?:/|:)) && $1
end
|
#source_url ⇒ Object
130
131
132
|
# File 'lib/perkins/build/data.rb', line 130
def source_url
repository[:source_url]
end
|
106
107
108
109
110
111
112
|
# File 'lib/perkins/build/data.rb', line 106
def ssh_key
if ssh_key = data[:ssh_key]
SshKey.new(ssh_key[:value], ssh_key[:source], ssh_key[:encoded])
elsif source_key = data[:config][:source_key]
SshKey.new(source_key, nil, true)
end
end
|
162
163
164
|
# File 'lib/perkins/build/data.rb', line 162
def token
data[:oauth_token]
end
|
30
31
32
|
# File 'lib/perkins/build/data.rb', line 30
def urls
data[:urls] || {}
end
|