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/deploy/base.rb,
lib/vx/builder/build_configuration/deploy/shell.rb
Defined Under Namespace
Classes: Cache, Deploy, Env, Vexor
Constant Summary
collapse
- REQUIRED_KEYS =
%w{
rvm
scala
jdk
go
language
script
}
- ATTRIBUTES =
%w{
rvm
scala
jdk
go
language
gemfile
services
image
bundler_args
before_install
install
before_script
script
after_success
before_deploy
after_deploy
}
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.
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/vx/builder/build_configuration.rb', line 57
def initialize(new_attributes = {}, matrix_attributes = {})
new_attributes = {} unless new_attributes.is_a?(Hash)
@env = Env.new new_attributes.delete("env")
@cache = Cache.new new_attributes.delete("cache")
@vexor = Vexor.new new_attributes.delete("vexor")
@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
build_attributes new_attributes
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
55
56
57
|
# File 'lib/vx/builder/build_configuration.rb', line 55
def attributes
@attributes
end
|
#cache ⇒ Object
Returns the value of attribute cache.
55
56
57
|
# File 'lib/vx/builder/build_configuration.rb', line 55
def cache
@cache
end
|
#deploy ⇒ Object
Returns the value of attribute deploy.
55
56
57
|
# File 'lib/vx/builder/build_configuration.rb', line 55
def deploy
@deploy
end
|
#deploy_modules ⇒ Object
Returns the value of attribute deploy_modules.
55
56
57
|
# File 'lib/vx/builder/build_configuration.rb', line 55
def deploy_modules
@deploy_modules
end
|
#env ⇒ Object
Returns the value of attribute env.
55
56
57
|
# File 'lib/vx/builder/build_configuration.rb', line 55
def env
@env
end
|
#vexor ⇒ Object
Returns the value of attribute vexor.
55
56
57
|
# File 'lib/vx/builder/build_configuration.rb', line 55
def vexor
@vexor
end
|
Class Method Details
.from_file(file) ⇒ Object
48
49
50
51
52
|
# File 'lib/vx/builder/build_configuration.rb', line 48
def from_file(file)
if File.readable? file
from_yaml File.read(file)
end
end
|
.from_yaml(yaml) ⇒ Object
43
44
45
46
|
# File 'lib/vx/builder/build_configuration.rb', line 43
def from_yaml(yaml)
hash = YAML.load(yaml)
new hash
end
|
Instance Method Details
#any? ⇒ Boolean
73
74
75
76
77
|
# File 'lib/vx/builder/build_configuration.rb', line 73
def any?
REQUIRED_KEYS.any? do |key|
attributes[key].any?
end
end
|
#cached_directories ⇒ Object
132
133
134
|
# File 'lib/vx/builder/build_configuration.rb', line 132
def cached_directories
cache.enabled? and cache.directories
end
|
#deploy? ⇒ Boolean
97
98
99
|
# File 'lib/vx/builder/build_configuration.rb', line 97
def deploy?
deploy.attributes.any?
end
|
#deploy_modules? ⇒ Boolean
101
102
103
|
# File 'lib/vx/builder/build_configuration.rb', line 101
def deploy_modules?
deploy_modules.any?
end
|
#env_matrix ⇒ Object
124
125
126
|
# File 'lib/vx/builder/build_configuration.rb', line 124
def env_matrix
env.matrix
end
|
#flat_matrix_attributes ⇒ Object
80
81
82
|
# File 'lib/vx/builder/build_configuration.rb', line 80
def flat_matrix_attributes
@matrix_attributes
end
|
#language ⇒ Object
128
129
130
|
# File 'lib/vx/builder/build_configuration.rb', line 128
def language
@attributes["language"].first
end
|
#matrix_attributes ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/vx/builder/build_configuration.rb', line 84
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
106
107
108
|
# File 'lib/vx/builder/build_configuration.rb', line 106
def matrix_id
matrix_attributes.to_a.map{|i| i.join(":") }.sort.join(", ")
end
|
#to_hash ⇒ Object
110
111
112
113
114
115
116
117
118
|
# File 'lib/vx/builder/build_configuration.rb', line 110
def to_hash
attributes.merge(
"env" => env.attributes,
"cache" => cache.attributes,
"vexor" => vexor.attributes,
"deploy" => deploy.attributes,
"deploy_modules" => deploy_modules.map(&:to_hash)
)
end
|
#to_yaml ⇒ Object
120
121
122
|
# File 'lib/vx/builder/build_configuration.rb', line 120
def to_yaml
to_hash.to_yaml
end
|