class KnapsackPro::TestFlatDistributor
Constants
- DIR_TYPES
Attributes
grouped_test_files[R]
node_total[R]
nodes_hash[R]
test_files[R]
Public Class Methods
new(test_files, node_total)
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 14 def initialize(test_files, node_total) @test_files = test_files @node_total = node_total set_default_nodes_hash set_grouped_test_files end
Public Instance Methods
nodes()
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 21 def nodes group_test_files_by_directory generate_nodes end
test_files_for_node(node_index)
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 26 def test_files_for_node(node_index) nodes[node_index] end
Private Instance Methods
generate_nodes()
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 73 def generate_nodes node_index = 0 grouped_test_files.each do |_type, test_files| test_files.each do |test_file| nodes_hash[node_index] << test_file node_index += 1 node_index %= node_total end end nodes_hash end
group_test_files_by_directory()
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 56 def group_test_files_by_directory sorted_test_files.each do |test_file| found = false DIR_TYPES.each do |type| if test_file['path'].match(/#{type}/) grouped_test_files[type] << test_file found = true break end end unless found grouped_test_files[:other] << test_file end end end
set_default_nodes_hash()
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 37 def set_default_nodes_hash @nodes_hash = {} node_total.times do |index| nodes_hash[index] = [] end end
set_grouped_test_files()
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 44 def set_grouped_test_files @grouped_test_files = {} DIR_TYPES.each do |type| grouped_test_files[type] = [] end grouped_test_files[:other] = [] end
sorted_test_files()
click to toggle source
# File lib/knapsack_pro/test_flat_distributor.rb, line 52 def sorted_test_files test_files.sort_by { |t| t['path'] } end