Class: Coverband::AtExit

Inherits:
Object
  • Object
show all
Defined in:
lib/coverband/at_exit.rb

Class Method Summary collapse

Class Method Details

.registerObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/coverband/at_exit.rb', line 8

def self.register
  return if ENV["COVERBAND_DISABLE_AT_EXIT"]
  return if @at_exit_registered

  @semaphore.synchronize do
    return if @at_exit_registered

    @at_exit_registered = true
    at_exit do
      ::Coverband::Background.stop

      if !Coverband.configuration.report_on_exit
        # skip reporting
      else
        Coverband.report_coverage
        # to ensure we track mailer views we now need to report views tracking
        # at exit as well for rake tasks and background tasks that can trigger email
        Coverband.configuration.view_tracker&.save_report
        Coverband.configuration.translations_tracker&.save_report
      end
    end
  end
end