class Coverband::Background
Public Class Methods
running?()
click to toggle source
# File lib/coverband/integrations/background.rb, line 19 def self.running? @thread&.alive? end
start()
click to toggle source
# File lib/coverband/integrations/background.rb, line 23 def self.start return if running? logger = Coverband.configuration.logger @semaphore.synchronize do return if running? logger.debug("Coverband: Starting background reporting") if Coverband.configuration.verbose sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds.to_i @thread = Thread.new { loop do Coverband.report_coverage Coverband.configuration.view_tracker&.report_views_tracked if Coverband.configuration.reporting_wiggle sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds.to_i + rand(Coverband.configuration.reporting_wiggle.to_i) end if Coverband.configuration.verbose logger.debug("Coverband: background reporting coverage (#{Coverband.configuration.store.type}). Sleeping #{sleep_seconds}s") end sleep(sleep_seconds.to_i) end } end end
stop()
click to toggle source
# File lib/coverband/integrations/background.rb, line 8 def self.stop return unless @thread @semaphore.synchronize do if @thread @thread.exit @thread = nil end end end