Class: Binpacker::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/binpacker/config.rb
Constant Summary
collapse
- DEFAULTS =
{
"test_runner" => "rspec",
"workers" => "auto",
"timing_file" => "binpacker.timings",
"test_pattern" => "spec/**/*_spec.rb",
"test_exclude" => [],
"scheduler" => {
"strategy" => "static",
"steal_enabled" => false,
"algorithm" => "lpt"
}
}.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
Returns a new instance of Config.
25
26
27
28
29
30
|
# File 'lib/binpacker/config.rb', line 25
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
32
33
34
35
36
37
38
39
|
# File 'lib/binpacker/config.rb', line 32
def method_missing(name, *)
key = name.to_s
if @merged.key?(key)
@merged[key]
else
super
end
end
|
Instance Attribute Details
#profile ⇒ Object
Returns the value of attribute profile.
8
9
10
|
# File 'lib/binpacker/config.rb', line 8
def profile
@profile
end
|
Instance Method Details
#respond_to_missing?(name) ⇒ Boolean
41
42
43
|
# File 'lib/binpacker/config.rb', line 41
def respond_to_missing?(name, *)
@merged.key?(name.to_s) || super
end
|
#scheduler ⇒ Object
45
46
47
|
# File 'lib/binpacker/config.rb', line 45
def scheduler
@merged["scheduler"]
end
|
#worker_count ⇒ Object
49
50
51
52
53
|
# File 'lib/binpacker/config.rb', line 49
def worker_count
workers = @merged["workers"]
return Etc.nprocessors if workers == "auto"
Integer(workers)
end
|