Class: Vx::Builder::BuildConfiguration
- Inherits:
-
Object
- Object
- Vx::Builder::BuildConfiguration
show all
- Defined in:
- lib/vx/builder/build_configuration.rb,
lib/vx/builder/build_configuration/env.rb,
lib/vx/builder/build_configuration/cache.rb,
lib/vx/builder/build_configuration/vexor.rb,
lib/vx/builder/build_configuration/deploy.rb,
lib/vx/builder/build_configuration/matrix.rb,
lib/vx/builder/build_configuration/deploy/base.rb,
lib/vx/builder/build_configuration/deploy/shell.rb
Defined Under Namespace
Classes: Cache, Deploy, Env, Matrix, Vexor
Constant Summary
collapse
- REQUIRED_KEYS =
%w{
rvm
scala
jdk
go
node_js
rust
python
language
script
}
- ATTRIBUTES =
%w{
rvm
scala
jdk
go
node_js
rust
python
language
gemfile
services
image
bundler_args
pip_args
before_install
install
before_script
script
after_success
before_deploy
after_deploy
parallel
parallel_job_number
database
}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(new_attributes = {}, matrix_attributes = {}) ⇒ BuildConfiguration
Returns a new instance of BuildConfiguration.
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/vx/builder/build_configuration.rb', line 72
def initialize(new_attributes = {}, matrix_attributes = {})
new_attributes = {} unless new_attributes.is_a?(Hash)
@is_empty = new_attributes == {}
@env = Env.new new_attributes.delete("env")
@cache = Cache.new new_attributes.delete("cache")
@vexor = Vexor.new new_attributes.delete("vexor")
@matrix = Matrix.new new_attributes.delete("matrix")
@deploy = Deploy.new new_attributes.delete("deploy")
@deploy_modules = new_attributes.delete("deploy_modules") || []
@deploy_modules = Deploy.restore_modules(@deploy_modules)
@matrix_attributes = matrix_attributes.inject({}) do |a, pair|
k,v = pair
if k == 'parallel_job_number'
k = 'parallel'
end
a[k] = v
a
end
build_attributes new_attributes
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 69
def attributes
@attributes
end
|
#cache ⇒ Object
Returns the value of attribute cache.
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 69
def cache
@cache
end
|
#deploy ⇒ Object
Returns the value of attribute deploy.
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 69
def deploy
@deploy
end
|
#deploy_modules ⇒ Object
Returns the value of attribute deploy_modules.
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 69
def deploy_modules
@deploy_modules
end
|
#env ⇒ Object
Returns the value of attribute env.
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 69
def env
@env
end
|
#matrix ⇒ Object
Returns the value of attribute matrix.
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 69
def matrix
@matrix
end
|
#vexor ⇒ Object
Returns the value of attribute vexor.
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 69
def vexor
@vexor
end
|
Class Method Details
.from_file(file) ⇒ Object
62
63
64
65
66
|
# File 'lib/vx/builder/build_configuration.rb', line 62
def from_file(file)
if File.readable? file
from_yaml File.read(file)
end
end
|
.from_yaml(yaml) ⇒ Object
57
58
59
60
|
# File 'lib/vx/builder/build_configuration.rb', line 57
def from_yaml(yaml)
hash = YAML.load(yaml)
new hash
end
|
Instance Method Details
#any? ⇒ Boolean
have any required attributes
103
104
105
106
107
|
# File 'lib/vx/builder/build_configuration.rb', line 103
def any?
REQUIRED_KEYS.any? do |key|
attributes[key].any?
end
end
|
#cached_directories ⇒ Object
187
188
189
|
# File 'lib/vx/builder/build_configuration.rb', line 187
def cached_directories
cache.enabled? and cache.directories
end
|
#database? ⇒ Boolean
171
172
173
|
# File 'lib/vx/builder/build_configuration.rb', line 171
def database?
@attributes['database'].first != false
end
|
#deploy? ⇒ Boolean
127
128
129
|
# File 'lib/vx/builder/build_configuration.rb', line 127
def deploy?
deploy.attributes.any?
end
|
#deploy_modules? ⇒ Boolean
131
132
133
|
# File 'lib/vx/builder/build_configuration.rb', line 131
def deploy_modules?
deploy_modules.any?
end
|
#empty? ⇒ Boolean
nil or empty configuration file
98
99
100
|
# File 'lib/vx/builder/build_configuration.rb', line 98
def empty?
@is_empty
end
|
#env_matrix ⇒ Object
159
160
161
|
# File 'lib/vx/builder/build_configuration.rb', line 159
def env_matrix
env.matrix
end
|
#flat_matrix_attributes ⇒ Object
110
111
112
|
# File 'lib/vx/builder/build_configuration.rb', line 110
def flat_matrix_attributes
@matrix_attributes
end
|
#language ⇒ Object
163
164
165
|
# File 'lib/vx/builder/build_configuration.rb', line 163
def language
@attributes["language"].first
end
|
#matrix_attributes ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/vx/builder/build_configuration.rb', line 114
def matrix_attributes
@matrix_attributes.inject({}) do |a,pair|
k,v = pair
if k == 'env'
v = v["matrix"].first
end
if v
a[k] = v
end
a
end
end
|
#matrix_id ⇒ Object
136
137
138
|
# File 'lib/vx/builder/build_configuration.rb', line 136
def matrix_id
matrix_attributes.to_a.map{|i| i.join(":") }.sort.join(", ")
end
|
#parallel ⇒ Object
167
168
169
|
# File 'lib/vx/builder/build_configuration.rb', line 167
def parallel
@attributes["parallel"].first.to_i
end
|
#parallel? ⇒ Boolean
175
176
177
|
# File 'lib/vx/builder/build_configuration.rb', line 175
def parallel?
parallel > 0
end
|
#parallel_job_number ⇒ Object
179
180
181
|
# File 'lib/vx/builder/build_configuration.rb', line 179
def parallel_job_number
@attributes["parallel_job_number"].first.to_i
end
|
#parallel_job_number? ⇒ Boolean
183
184
185
|
# File 'lib/vx/builder/build_configuration.rb', line 183
def parallel_job_number?
parallel_job_number > 0
end
|
#to_hash ⇒ Object
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/vx/builder/build_configuration.rb', line 140
def to_hash
if empty?
{}
else
attributes.merge(
"env" => env.attributes,
"cache" => cache.attributes,
"vexor" => vexor.attributes,
"matrix" => matrix.attributes,
"deploy" => deploy.attributes,
"deploy_modules" => deploy_modules.map(&:to_hash)
)
end
end
|
#to_yaml ⇒ Object
155
156
157
|
# File 'lib/vx/builder/build_configuration.rb', line 155
def to_yaml
to_hash.to_yaml
end
|