class TravisBuildMatrix::TravisFile

Public Class Methods

new(test_buckets, travis_yml_file, &block) click to toggle source
# File lib/spec_tiller/distribute_spec_files.rb, line 77
def initialize(test_buckets, travis_yml_file, &block)
  rewrite_content(test_buckets, travis_yml_file)
  block.call(travis_yml_file) if block
end

Private Instance Methods

rewrite_content(test_buckets, content) click to toggle source
# File lib/spec_tiller/distribute_spec_files.rb, line 84
def rewrite_content(test_buckets, content)
  content['env']['matrix'] ||= [] # initialize env if not already set

  env_matrix = BuildMatrixParser.parse_env_matrix(content)

  if env_matrix.length > test_buckets.length
    env_matrix = env_matrix.slice(0, test_buckets.length)
  elsif env_matrix.length < test_buckets.length
    (test_buckets.length - env_matrix.length).times {env_matrix.push({ })}
  end

  env_matrix.each do |var_hash|
    test_bucket = test_buckets.shift

    spec_file_list = test_bucket.spec_files.map(&:file_path).join(' ')
    var_hash['TEST_SUITE'] = "#{spec_file_list}"
  end

  content['env']['matrix'] = BuildMatrixParser.format_matrix(env_matrix)
end