Class: Vx::Builder::Source
- Inherits:
-
Object
- Object
- Vx::Builder::Source
show all
- Includes:
- Serializable
- Defined in:
- lib/vx/builder/source.rb,
lib/vx/builder/source/matrix.rb,
lib/vx/builder/source/constants.rb,
lib/vx/builder/source/serializable.rb
Defined Under Namespace
Modules: Serializable
Classes: Matrix
Constant Summary
collapse
- LANGS =
%w{ rvm scala java go }.freeze
- KEYS =
%w{ services before_script script }.freeze
- AS_ARRAY =
(KEYS + LANGS).freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
included, #to_yaml
Constructor Details
#initialize(attrs = {}) ⇒ Source
Returns a new instance of Source.
14
15
16
|
# File 'lib/vx/builder/source.rb', line 14
def initialize(attrs = {})
@attributes = normalize_attributes attrs
end
|
Instance Attribute Details
#attributes ⇒ Object
Also known as:
to_hash
Returns the value of attribute attributes.
11
12
13
|
# File 'lib/vx/builder/source.rb', line 11
def attributes
@attributes
end
|
Instance Method Details
#[](val) ⇒ Object
18
19
20
|
# File 'lib/vx/builder/source.rb', line 18
def [](val)
public_send(val)
end
|
#env ⇒ Object
43
44
45
|
# File 'lib/vx/builder/source.rb', line 43
def env
attributes["env"]
end
|
#global_env ⇒ Object
51
52
53
|
# File 'lib/vx/builder/source.rb', line 51
def global_env
attributes["env"]["global"]
end
|
#matrix_env ⇒ Object
47
48
49
|
# File 'lib/vx/builder/source.rb', line 47
def matrix_env
attributes["env"]["matrix"]
end
|
#matrix_keys ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/vx/builder/source.rb', line 22
def matrix_keys
@matrix_keys ||=
Matrix::KEYS.inject({}) do |a,k|
k_method, k_name = k.split(":")
k_name ||= k_method
val = send(k_method)
unless val.empty?
a[k_name] = val.first
end
a
end
end
|
#merge(attrs = {}) ⇒ Object
61
62
63
|
# File 'lib/vx/builder/source.rb', line 61
def merge(attrs = {})
self.class.from_attributes self.attributes.merge(attrs)
end
|
#to_matrix_s ⇒ Object
35
36
37
|
# File 'lib/vx/builder/source.rb', line 35
def to_matrix_s
@to_matrix_s ||= matrix_keys.map{|k,v| "#{k}:#{v}" }.sort.join(", ")
end
|
#to_script_builder(build) ⇒ Object
39
40
41
|
# File 'lib/vx/builder/source.rb', line 39
def to_script_builder(build)
ScriptBuilder.new(build, self)
end
|