Sha256: b6f72a69541ac76e3f93d0540d86a0cd18c86ec88a3a6591bc886c96607d7a74

Contents?: true

Size: 717 Bytes

Versions: 1

Compression:

Stored size: 717 Bytes

Contents

module LeftoverSpecs
  def self.select(all_leftover_specs, thread_count, thread_index)
    all_leftover_specs = sort_by_size(all_leftover_specs)

    return [] if all_leftover_specs.empty?

    specs = all_leftover_specs
      .each_slice(thread_count)
      .reduce{|acc, slice| acc.map{|a| a}.zip(slice.reverse)}
      .map{|f| if f.kind_of?(Array) then f.flatten else [f] end} [thread_index]

    if    specs.nil?            then []
    elsif specs.kind_of?(Array) then specs.compact
    end
  end

  def self.sort_by_size(specs) # descending
    specs
      .map{|f| if File.file?(f) then f else nil end}
      .compact
      .map{|f| [f, File.size(f)]}
      .sort_by{|a| a[1]}.map{|a| a[0]}.reverse
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
semaphore_test_boosters-0.3.0 lib/test_boosters/leftover_specs.rb