Class: Matrixeval::Context
- Inherits:
-
Object
- Object
- Matrixeval::Context
show all
- Defined in:
- lib/matrixeval/context.rb,
lib/matrixeval/context/find_by_command_options.rb,
lib/matrixeval/context/build_docker_compose_extend.rb
Defined Under Namespace
Classes: BuildDockerComposeExtend, FindByCommandOptions
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(main_variant:, rest_variants:) ⇒ Context
Returns a new instance of Context.
30
31
32
33
34
35
|
# File 'lib/matrixeval/context.rb', line 30
def initialize(main_variant:, rest_variants:)
@main_variant = main_variant
@rest_variants = (rest_variants || []).sort do |v1, v2|
v1.id <=> v2.id
end
end
|
Instance Attribute Details
#main_variant ⇒ Object
Returns the value of attribute main_variant.
28
29
30
|
# File 'lib/matrixeval/context.rb', line 28
def main_variant
@main_variant
end
|
#rest_variants ⇒ Object
Returns the value of attribute rest_variants.
28
29
30
|
# File 'lib/matrixeval/context.rb', line 28
def rest_variants
@rest_variants
end
|
Class Method Details
.all ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/matrixeval/context.rb', line 13
def all
Config.variant_combinations.map do |variants|
Context.new(
main_variant: variants.find { |v| v.vector.main? },
rest_variants: variants.reject { |v| v.vector.main? }
)
end.select do |context|
Config.exclusions.none? do |exclusion|
context.match_exclusion?(exclusion)
end
end
end
|
.find_by_command_options!(options) ⇒ Object
9
10
11
|
# File 'lib/matrixeval/context.rb', line 9
def find_by_command_options!(options)
FindByCommandOptions.call(options)
end
|
Instance Method Details
#docker_compose_extend ⇒ Object
#docker_compose_file_path ⇒ Object
54
55
56
|
# File 'lib/matrixeval/context.rb', line 54
def docker_compose_file_path
Matrixeval.working_dir.join(".matrixeval/docker-compose/#{id}.yml")
end
|
#docker_compose_service_name ⇒ Object
50
51
52
|
# File 'lib/matrixeval/context.rb', line 50
def docker_compose_service_name
main_variant.id
end
|
#env ⇒ Object
45
46
47
48
|
# File 'lib/matrixeval/context.rb', line 45
def env
rest_variants.map(&:env).reduce({}, &:merge)
.merge(main_variant.env)
end
|
#id ⇒ Object
41
42
43
|
# File 'lib/matrixeval/context.rb', line 41
def id
[[main_variant.id] + rest_variants.map(&:id)].join("_")
end
|
#match_exclusion?(exclusion) ⇒ Boolean
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/matrixeval/context.rb', line 62
def match_exclusion?(exclusion)
return false if exclusion.empty?
variants.all? do |variant|
vector_key = variant.vector.key
if exclusion.key?(vector_key)
exclusion[vector_key].to_s == variant.key
else
true
end
end
end
|
#name ⇒ Object
37
38
39
|
# File 'lib/matrixeval/context.rb', line 37
def name
variants.map(&:name).join(", ")
end
|
#variants ⇒ Object
58
59
60
|
# File 'lib/matrixeval/context.rb', line 58
def variants
[main_variant] + rest_variants
end
|