Class: Klenod::Test::CoverageConfig
- Inherits:
-
Data
- Object
- Data
- Klenod::Test::CoverageConfig
- Defined in:
- lib/klenod/test/config.rb
Instance Attribute Summary collapse
-
#minimum ⇒ Object
readonly
Returns the value of attribute minimum.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Class Method Summary collapse
Instance Attribute Details
#minimum ⇒ Object (readonly)
Returns the value of attribute minimum
9 10 11 |
# File 'lib/klenod/test/config.rb', line 9 def minimum @minimum end |
#report ⇒ Object (readonly)
Returns the value of attribute report
9 10 11 |
# File 'lib/klenod/test/config.rb', line 9 def report @report end |
Class Method Details
.build(report: :brief, minimum: nil) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/klenod/test/config.rb', line 10 def self.build(report: :brief, minimum: nil) report = report.to_s.downcase.to_sym unless COVERAGE_REPORTS.include?(report) raise ConfigError, "Unknown coverage report #{report.inspect}; choose one of: #{COVERAGE_REPORTS.join(", ")}" end new(report, normalize_minimum(minimum)) end |
.normalize_minimum(minimum) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/klenod/test/config.rb', line 19 def self.normalize_minimum(minimum) return unless minimum value = begin Float(minimum) rescue ArgumentError, TypeError raise ConfigError, "Coverage minimum must be a number between 0 and 100" end return value if value.between?(0, 100) raise ConfigError, "Coverage minimum must be between 0 and 100" end |