Module: GemHadar::SimpleCov
- Extended by:
- WarnModule, Term::ANSIColor
- Defined in:
- lib/gem_hadar/simplecov.rb
Overview
A module that provides SimpleCov-related functionality for code coverage analysis.
This module encapsulates the setup and configuration of SimpleCov for Ruby projects, including initialization, formatter selection, and warning message handling. It integrates with the GemHadar framework to provide detailed coverage reporting capabilities while maintaining consistent output formatting and error handling.
Defined Under Namespace
Modules: WarnModule Classes: ContextFormatter
Class Method Summary collapse
-
.start ⇒ Object
The start method initializes and configures SimpleCov for code coverage analysis.
Methods included from WarnModule
Class Method Details
.start ⇒ Object
The start method initializes and configures SimpleCov for code coverage analysis.
This method checks if the START_SIMPLECOV environment variable is set to 1 before proceeding with SimpleCov setup. If disabled, it outputs a message indicating that SimpleCov startup is skipped. When enabled, it requires the simplecov gem, configures coverage to include branch coverage, adds a filter based on the caller’s directory, and sets up multiple formatters including SimpleFormatter, HTMLFormatter, and a custom ContextFormatter.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/gem_hadar/simplecov.rb', line 191 def start if ENV['START_SIMPLECOV'].to_i != 1 STDERR.puts color(226) { "Skip starting Simplecov for code coverage, "\ "enable by setting env var: START_SIMPLECOV=1" } return end require 'simplecov' STDERR.puts color(76) { "Configuring Simplecov for code coverage." } filter = "#{File.basename(File.dirname(caller.first))}/" SimpleCov.start do enable_coverage :branch add_filter filter formatter SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::SimpleFormatter, SimpleCov::Formatter::HTMLFormatter, GemHadar::SimpleCov::ContextFormatter, ]) end rescue LoadError => e warn "Caught #{e.class}: #{e}" STDERR.puts "Install with: gem install simplecov" end |