Class: Vx::Builder::Source
- Inherits:
-
Object
- Object
- Vx::Builder::Source
show all
- Includes:
- Source::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 jdk }.freeze
- KEYS =
%w{ gemfile services before_script script before_install image
after_success }.freeze
- AS_ARRAY =
(KEYS + LANGS).freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
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
|
#cached_directories ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/vx/builder/source.rb', line 55
def cached_directories
if attributes["cache"] == false
false
else
(attributes["cache"] && attributes["cache"]["directories"]) || []
end
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
|
#language ⇒ Object
63
64
65
|
# File 'lib/vx/builder/source.rb', line 63
def language
attributes["language"]
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
73
74
75
|
# File 'lib/vx/builder/source.rb', line 73
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
|