Class: Necropsy::Analyzers::Dynamic::CoverageCollector
- Inherits:
-
Object
- Object
- Necropsy::Analyzers::Dynamic::CoverageCollector
- Defined in:
- lib/necropsy/analyzers/dynamic/coverage_collector.rb
Class Method Summary collapse
- .install_at_exit(root:, output:, merge: false, run_id: nil, clock: nil) ⇒ Object
- .record(root:, output:, clock: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(root:, output:, merge: false, run_id: nil, clock: nil) ⇒ CoverageCollector
constructor
A new instance of CoverageCollector.
- #install_at_exit ⇒ Object
- #record ⇒ Object
Constructor Details
#initialize(root:, output:, merge: false, run_id: nil, clock: nil) ⇒ CoverageCollector
Returns a new instance of CoverageCollector.
23 24 25 26 27 28 29 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 23 def initialize(root:, output:, merge: false, run_id: nil, clock: nil) @root = File.(root) @output = output @merge = merge @run_id = run_id @clock = clock || -> { Clock.new.time } end |
Class Method Details
.install_at_exit(root:, output:, merge: false, run_id: nil, clock: nil) ⇒ Object
19 20 21 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 19 def self.install_at_exit(root:, output:, merge: false, run_id: nil, clock: nil) new(root: root, output: output, merge: merge, run_id: run_id, clock: clock).install_at_exit end |
.record(root:, output:, clock: nil) ⇒ Object
15 16 17 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 15 def self.record(root:, output:, clock: nil, &) new(root: root, output: output, clock: clock).record(&) end |
Instance Method Details
#install_at_exit ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 40 def install_at_exit started_at = current_time started = start_coverage at_exit do finished_at = current_time result = coverage_result(started: started) write_payload(result: result, started_at: started_at, finished_at: finished_at) rescue StandardError => e warn "Necropsy coverage collector failed: #{e.}" end end |
#record ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 31 def record started_at = current_time Coverage.start(methods: true) yield write_payload(result: Coverage.result, started_at: started_at, finished_at: current_time) ensure Coverage.result(stop: true, clear: true) if Coverage.running? end |