Class: Evilution::Config
- Inherits:
-
Object
- Object
- Evilution::Config
- Defined in:
- lib/evilution/config.rb
Constant Summary collapse
- CONFIG_FILES =
%w[.evilution.yml config/evilution.yml].freeze
- DEFAULTS =
{ timeout: 30, format: :text, target: nil, min_score: 0.0, integration: :rspec, verbose: false, quiet: false, jobs: 1, fail_fast: nil, baseline: true, isolation: :auto, incremental: false, line_ranges: {}, spec_files: [] }.freeze
Instance Attribute Summary collapse
-
#baseline ⇒ Object
readonly
Returns the value of attribute baseline.
-
#fail_fast ⇒ Object
readonly
Returns the value of attribute fail_fast.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#incremental ⇒ Object
readonly
Returns the value of attribute incremental.
-
#integration ⇒ Object
readonly
Returns the value of attribute integration.
-
#isolation ⇒ Object
readonly
Returns the value of attribute isolation.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#line_ranges ⇒ Object
readonly
Returns the value of attribute line_ranges.
-
#min_score ⇒ Object
readonly
Returns the value of attribute min_score.
-
#quiet ⇒ Object
readonly
Returns the value of attribute quiet.
-
#spec_files ⇒ Object
readonly
Returns the value of attribute spec_files.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#target_files ⇒ Object
readonly
Returns the value of attribute target_files.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Class Method Summary collapse
-
.default_template ⇒ Object
Generates a default config file template.
- .file_options ⇒ Object
Instance Method Summary collapse
- #baseline? ⇒ Boolean
- #fail_fast? ⇒ Boolean
- #html? ⇒ Boolean
- #incremental? ⇒ Boolean
-
#initialize(**options) ⇒ Config
constructor
A new instance of Config.
- #json? ⇒ Boolean
- #line_ranges? ⇒ Boolean
- #target? ⇒ Boolean
- #text? ⇒ Boolean
Constructor Details
Instance Attribute Details
#baseline ⇒ Object (readonly)
Returns the value of attribute baseline.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def baseline @baseline end |
#fail_fast ⇒ Object (readonly)
Returns the value of attribute fail_fast.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def fail_fast @fail_fast end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def format @format end |
#incremental ⇒ Object (readonly)
Returns the value of attribute incremental.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def incremental @incremental end |
#integration ⇒ Object (readonly)
Returns the value of attribute integration.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def integration @integration end |
#isolation ⇒ Object (readonly)
Returns the value of attribute isolation.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def isolation @isolation end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def jobs @jobs end |
#line_ranges ⇒ Object (readonly)
Returns the value of attribute line_ranges.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def line_ranges @line_ranges end |
#min_score ⇒ Object (readonly)
Returns the value of attribute min_score.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def min_score @min_score end |
#quiet ⇒ Object (readonly)
Returns the value of attribute quiet.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def quiet @quiet end |
#spec_files ⇒ Object (readonly)
Returns the value of attribute spec_files.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def spec_files @spec_files end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def target @target end |
#target_files ⇒ Object (readonly)
Returns the value of attribute target_files.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def target_files @target_files end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def timeout @timeout end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
26 27 28 |
# File 'lib/evilution/config.rb', line 26 def verbose @verbose end |
Class Method Details
.default_template ⇒ Object
Generates a default config file template.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/evilution/config.rb', line 85 def self.default_template <<~YAML # Evilution configuration # See: https://github.com/marinazzio/evilution # Per-mutation timeout in seconds (default: 30) # timeout: 30 # Output format: text or json (default: text) # format: text # Minimum mutation score to pass (0.0 to 1.0, default: 0.0) # min_score: 0.0 # Test integration: rspec (default: rspec) # integration: rspec # Number of parallel workers (default: 1) # jobs: 1 # Stop after N surviving mutants (default: disabled) # fail_fast: 1 YAML end |
.file_options ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/evilution/config.rb', line 69 def self. CONFIG_FILES.each do |path| next unless File.exist?(path) data = YAML.safe_load_file(path, symbolize_names: true) return data.is_a?(Hash) ? data : {} rescue Psych::SyntaxError, Psych::DisallowedClass => e raise ConfigError.new("failed to parse config file #{path}: #{e.}", file: path) rescue SystemCallError => e raise ConfigError.new("cannot read config file #{path}: #{e.}", file: path) end {} end |
Instance Method Details
#baseline? ⇒ Boolean
61 62 63 |
# File 'lib/evilution/config.rb', line 61 def baseline? baseline end |
#fail_fast? ⇒ Boolean
57 58 59 |
# File 'lib/evilution/config.rb', line 57 def fail_fast? !fail_fast.nil? end |
#html? ⇒ Boolean
45 46 47 |
# File 'lib/evilution/config.rb', line 45 def html? format == :html end |
#incremental? ⇒ Boolean
65 66 67 |
# File 'lib/evilution/config.rb', line 65 def incremental? incremental end |
#json? ⇒ Boolean
37 38 39 |
# File 'lib/evilution/config.rb', line 37 def json? format == :json end |
#line_ranges? ⇒ Boolean
49 50 51 |
# File 'lib/evilution/config.rb', line 49 def line_ranges? !line_ranges.empty? end |
#target? ⇒ Boolean
53 54 55 |
# File 'lib/evilution/config.rb', line 53 def target? !target.nil? end |
#text? ⇒ Boolean
41 42 43 |
# File 'lib/evilution/config.rb', line 41 def text? format == :text end |