Class: SchemaDev::MatrixExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_dev/matrix_executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matrix) ⇒ MatrixExecutor

Returns a new instance of MatrixExecutor.



7
8
9
# File 'lib/schema_dev/matrix_executor.rb', line 7

def initialize(matrix)
  @matrix = matrix
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/schema_dev/matrix_executor.rb', line 5

def errors
  @errors
end

Instance Method Details

#run(cmd, dry_run: false) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/schema_dev/matrix_executor.rb', line 11

def run(cmd, dry_run: false)
  @errors = []
  @matrix.each_with_index do |tuple, i|
    ruby = tuple[:ruby]
    rails = tuple[:rails]
    db = tuple[:db]

    label = "ruby #{ruby} - rails #{rails} - db #{db}"
    msg = "#{label} [#{i+1} of #{@matrix.size}]"
    puts "\n\n*** #{msg}\n\n"

    if not Executor.new(ruby: ruby, rails: rails, db: db).run(cmd, dry_run: dry_run)
      @errors << label
    end
  end
  return @errors.empty?
end