Class: Teaspoon::Coverage
- Inherits:
-
Object
- Object
- Teaspoon::Coverage
- Defined in:
- lib/teaspoon/coverage.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check_thresholds(&block) ⇒ Object
- #generate_reports(&block) ⇒ Object
-
#initialize(suite_name, data) ⇒ Coverage
constructor
A new instance of Coverage.
Constructor Details
#initialize(suite_name, data) ⇒ Coverage
Returns a new instance of Coverage.
13 14 15 16 17 18 19 20 |
# File 'lib/teaspoon/coverage.rb', line 13 def initialize(suite_name, data) @suite_name = suite_name @data = data @executable = Teaspoon::Instrumentation.executable @config = self.class.configuration raise Teaspoon::CoverageResultsNotFoundError unless @data end |
Class Method Details
.configuration(name = Teaspoon.configuration.use_coverage) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/teaspoon/coverage.rb', line 5 def self.configuration(name = Teaspoon.configuration.use_coverage) name = normalize_config_name(name) config = Teaspoon.configuration.coverage_configs[name] raise Teaspoon::UnknownCoverage.new(name: name) unless config.present? config[:instance] ||= Teaspoon::Configuration::Coverage.new(&config[:block]) end |
Instance Method Details
#check_thresholds(&block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/teaspoon/coverage.rb', line 33 def check_thresholds(&block) args = threshold_args return if args.blank? input_path do |input| result, st = Open3.capture2e(@executable, "check-coverage", *args, input.shellescape) return if st.exitstatus.zero? result = result.scan(/ERROR: .*$/).join("\n").gsub("ERROR: ", "") block.call(result) unless result.blank? end end |
#generate_reports(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/teaspoon/coverage.rb', line 22 def generate_reports(&block) input_path do |input| results = [] @config.reports.each do |format| result = generate_report(input, format) results << result if ["text", "text-summary"].include?(format.to_s) end block.call(results.join("\n\n")) unless results.blank? end end |