Class: CoverRage::Recorder
- Inherits:
-
Object
- Object
- CoverRage::Recorder
- Defined in:
- lib/cover_rage/recorder.rb
Constant Summary collapse
- SLEEP_DURATION =
Config.sleep_duration
- COVERAGE_STOP_STATES =
%i[idle suspended].freeze
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
-
#initialize(root_path:, store:) ⇒ Recorder
constructor
A new instance of Recorder.
- #start ⇒ Object
Constructor Details
#initialize(root_path:, store:) ⇒ Recorder
Returns a new instance of Recorder.
13 14 15 16 17 18 |
# File 'lib/cover_rage/recorder.rb', line 13 def initialize(root_path:, store:) @store = store @root_path = root_path.end_with?('/') ? root_path : "#{root_path}/" @digest = Digest::MD5.new @file_cache = {} end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
11 12 13 |
# File 'lib/cover_rage/recorder.rb', line 11 def store @store end |
Instance Method Details
#start ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cover_rage/recorder.rb', line 20 def start return if @thread&.alive? Coverage.start if COVERAGE_STOP_STATES.include?(Coverage.state) @thread = Thread.new do loop do sleep(rand(SLEEP_DURATION)) save(Coverage.result(stop: false, clear: true)) end ensure save(Coverage.result) end end |