Class: Travis::Yaml::Matrix
- Inherits:
-
Array
- Object
- Array
- Travis::Yaml::Matrix
- Defined in:
- lib/travis/yaml/matrix.rb
Defined Under Namespace
Classes: Entry
Constant Summary collapse
- EXPAND_KEYS =
[ :compiler, :gemfile, :ghc, :go, :jdk, :lein, :node_js, :otp_release, :perl, :php, :python, :ruby, :scala, :xcode_scheme, :xcode_sdk, :os ]
- KEYS =
EXPAND_KEYS + [:env]
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #axes ⇒ Object
- #entries ⇒ Object
-
#initialize(root) ⇒ Matrix
constructor
A new instance of Matrix.
- #values_for(key) ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
28 29 30 |
# File 'lib/travis/yaml/matrix.rb', line 28 def root @root end |
Instance Method Details
#axes ⇒ Object
35 36 37 38 39 40 |
# File 'lib/travis/yaml/matrix.rb', line 35 def axes @axes ||= KEYS.select do |key| next true if values_for(key) and values_for(key).size > 1 root.matrix.include.any? { |i| i[key] } if root.matrix and root.matrix.include end end |
#entries ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/travis/yaml/matrix.rb', line 42 def entries @entries ||= begin first, *rest = axes.map { |k| values_for(k) || [nil] } entries = Array(first).product(*rest).map { |list| Hash[axes.zip(list)] } if m = root.matrix entries.delete_if { |e| m.exclude.any? { |p| p.all? { |k,v| e[k.to_sym] == v } } } if m.exclude m.include.each { |i| entries << Hash[axes.map { |k| [k, i[k]] }] } if m.include end entries.map! { |attributes| Entry.new(root, attributes) } entries.any? ? entries : [Entry.new(root, {})] end end |