Module: Coverband

Defined in:
lib/coverband/version.rb,
lib/coverband/at_exit.rb,
lib/coverband/utils/result.rb,
lib/coverband/adapters/base.rb,
lib/coverband/configuration.rb,
lib/coverband/reporters/web.rb,
lib/coverband/utils/railtie.rb,
lib/coverband/utils/results.rb,
lib/coverband/reporters/base.rb,
lib/coverband/utils/file_list.rb,
lib/coverband/collectors/delta.rb,
lib/alternative_coverband_patch.rb,
lib/coverband/utils/file_hasher.rb,
lib/coverband/utils/source_file.rb,
lib/coverband/utils/dead_methods.rb,
lib/coverband/adapters/file_store.rb,
lib/coverband/adapters/null_store.rb,
lib/coverband/collectors/coverage.rb,
lib/coverband/integrations/resque.rb,
lib/coverband/adapters/redis_store.rb,
lib/coverband/utils/html_formatter.rb,
lib/coverband/adapters/stdout_store.rb,
lib/coverband/reporters/html_report.rb,
lib/coverband/reporters/json_report.rb,
lib/coverband/utils/lines_classifier.rb,
lib/coverband/collectors/view_tracker.rb,
lib/coverband/integrations/background.rb,
lib/coverband/adapters/memcached_store.rb,
lib/coverband/collectors/route_tracker.rb,
lib/coverband/reporters/console_report.rb,
lib/coverband/adapters/hash_redis_store.rb,
lib/coverband/adapters/web_service_store.rb,
lib/coverband/collectors/abstract_tracker.rb,
lib/coverband/utils/absolute_file_converter.rb,
lib/coverband/utils/relative_file_converter.rb,
lib/coverband/collectors/translation_tracker.rb,
lib/coverband/integrations/rack_server_check.rb,
lib/coverband/integrations/report_middleware.rb,
lib/coverband/collectors/view_tracker_service.rb,
lib/coverband/utils/method_definition_scanner.rb,
lib/coverband/integrations/background_middleware.rb,
lib/coverband.rb

Overview

NOTE: with Ruby 2.6.0 and beyond we can replace this classifier with ::Coverage.line_stub ruby-doc.org/stdlib-2.6.1/libdoc/coverage/rdoc/Coverage.html#method-c-line_stub

Thanks for all the help SimpleCov github.com/colszowka/simplecov-html initial version pulled into Coverband from Simplecov 12/04/2018

Classifies whether lines are relevant for code coverage analysis. Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.

Defined Under Namespace

Modules: Adapters, Collectors, RailsEagerLoad, Reporters, ResqueWorker, Utils Classes: AtExit, Background, BackgroundMiddleware, Configuration, RackServerCheck, Railtie, ReportMiddleware

Constant Summary collapse

VERSION =
"6.1.4"
COVERBAND_ALTERNATE_PATCH =
true
SERVICE_CONFIG =
"./config/coverband_service.rb"
CONFIG_FILE =
"./config/coverband.rb"
RUNTIME_TYPE =
:runtime
EAGER_TYPE =
:eager_loading
MERGED_TYPE =
:merged
TYPES =
[RUNTIME_TYPE, EAGER_TYPE]
ALL_TYPES =
TYPES + [:merged]
@@configured =
false

Class Method Summary collapse

Class Method Details

.configurationObject



73
74
75
# File 'lib/coverband.rb', line 73

def self.configuration
  @configuration ||= Configuration.new
end

.configure(file = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/coverband.rb', line 43

def self.configure(file = nil)
  configuration_file = file || ENV["COVERBAND_CONFIG"]
  if configuration_file.nil?
    configuration_file = coverband_service? ? SERVICE_CONFIG : CONFIG_FILE
  end

  configuration
  if block_given?
    yield(configuration)
  elsif File.exist?(configuration_file)
    load configuration_file
  else
    configuration.logger.debug("using default configuration") if Coverband.configuration.verbose
  end
  @@configured = true
  coverage_instance.reset_instance
end

.configured?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/coverband.rb', line 65

def self.configured?
  @@configured
end

.coverband_service?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/coverband.rb', line 61

def self.coverband_service?
  !!File.exist?(SERVICE_CONFIG)
end

.eager_loading_coverageObject



95
96
97
# File 'lib/coverband.rb', line 95

def self.eager_loading_coverage(...)
  coverage_instance.eager_loading(...)
end

.eager_loading_coverage!Object



91
92
93
# File 'lib/coverband.rb', line 91

def self.eager_loading_coverage!
  coverage_instance.eager_loading!
end

.report_coverageObject



69
70
71
# File 'lib/coverband.rb', line 69

def self.report_coverage
  coverage_instance.report_coverage
end

.runtime_coverage!Object



99
100
101
# File 'lib/coverband.rb', line 99

def self.runtime_coverage!
  coverage_instance.runtime!
end

.startObject



77
78
79
80
81
82
83
# File 'lib/coverband.rb', line 77

def self.start
  Coverband::Collectors::Coverage.instance
  # TODO: Railtie sets up at_exit after forks, via middleware, perhaps this should be
  # added if not rails or if rails but not rackserverrunning
  AtExit.register unless tasks_to_ignore?
  Background.start if configuration.background_reporting_enabled && !RackServerCheck.running? && !tasks_to_ignore?
end

.tasks_to_ignore?Boolean

Returns:

  • (Boolean)


85
86
87
88
89
# File 'lib/coverband.rb', line 85

def self.tasks_to_ignore?
  defined?(Rake) &&
    Rake.respond_to?(:application) &&
    (Rake&.application&.top_level_tasks || []).any? { |task| Coverband::Configuration::IGNORE_TASKS.include?(task) }
end