File: allocator_builder.rb

package info (click to toggle)
ruby-knapsack 4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,092 kB
  • sloc: ruby: 2,883; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Knapsack
  class AllocatorBuilder
    def initialize(adapter_class)
      @adapter_class = adapter_class
      set_report_path
    end

    def allocator
      Knapsack::Allocator.new({
        report: Knapsack.report.open,
        test_file_pattern: test_file_pattern,
        ci_node_total: Knapsack::Config::Env.ci_node_total,
        ci_node_index: Knapsack::Config::Env.ci_node_index
      })
    end

    def test_dir
      Knapsack::Config::Env.test_dir || test_file_pattern.split('/').first
    end

    private

    def set_report_path
      Knapsack.report.config({
        report_path: report_path
      })
    end

    def report_path
      Knapsack::Config::Env.report_path || @adapter_class::REPORT_PATH
    end

    def test_file_pattern
      Knapsack::Config::Env.test_file_pattern || @adapter_class::TEST_DIR_PATTERN
    end
  end
end