Class: Binpacker::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/binpacker/config.rb,
sig/binpacker/config.rbs

Constant Summary collapse

DEFAULTS =
{
  "test_runner" => "rspec",
  "workers" => "auto",
  "test_granularity" => "file",
  "timing_file" => "binpacker.timings",
  "test_pattern" => "spec/**/*_spec.rb",
  "test_exclude" => [],
  "report_file" => nil,
  "scheduler" => {
    "strategy" => "static",
    "steal_enabled" => false,
    "algorithm" => "multifit"
  }
}.freeze
CI_ENV_VARS =
%w[CI GITHUB_ACTIONS GITLAB_CI JENKINS_HOME].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile: nil, config_path: nil) ⇒ Config



27
28
29
30
31
32
# File 'lib/binpacker/config.rb', line 27

def initialize(profile: nil, config_path: nil)
  @config_path = config_path || find_config
  @raw = load_config
  @profile = resolve_profile(profile)
  @merged = build_profile(@profile)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/binpacker/config.rb', line 34

def method_missing(name, *)
  key = name.to_s
  if @merged.key?(key)
    @merged[key]
  else
    super
  end
end

Instance Attribute Details

#profileString (readonly)

Returns the value of attribute profile.



8
9
10
# File 'lib/binpacker/config.rb', line 8

def profile
  @profile
end

Instance Method Details

#report_fileString?



10
# File 'sig/binpacker/config.rbs', line 10

def report_file: () -> String?

#respond_to_missing?(name) ⇒ Boolean



43
44
45
# File 'lib/binpacker/config.rb', line 43

def respond_to_missing?(name, *)
  @merged.key?(name.to_s) || super
end

#schedulerObject



47
48
49
# File 'lib/binpacker/config.rb', line 47

def scheduler
  @merged["scheduler"]
end

#test_excludeArray[String]



8
# File 'sig/binpacker/config.rbs', line 8

def test_exclude: () -> Array[String]

#test_granularityString



9
# File 'sig/binpacker/config.rbs', line 9

def test_granularity: () -> String

#test_patternString



7
# File 'sig/binpacker/config.rbs', line 7

def test_pattern: () -> String

#test_runnerString



5
# File 'sig/binpacker/config.rbs', line 5

def test_runner: () -> String

#timing_fileString



6
# File 'sig/binpacker/config.rbs', line 6

def timing_file: () -> String

#worker_countInteger



51
52
53
54
55
# File 'lib/binpacker/config.rb', line 51

def worker_count
  workers = @merged["workers"]
  return Etc.nprocessors if workers == "auto"
  Integer(workers)
end