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) ⇒ Object
- .record(root:, output:) ⇒ Object
Instance Method Summary collapse
-
#initialize(root:, output:, merge: false, run_id: nil) ⇒ CoverageCollector
constructor
A new instance of CoverageCollector.
- #install_at_exit ⇒ Object
- #record ⇒ Object
Constructor Details
#initialize(root:, output:, merge: false, run_id: nil) ⇒ CoverageCollector
Returns a new instance of CoverageCollector.
20 21 22 23 24 25 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 20 def initialize(root:, output:, merge: false, run_id: nil) @root = File.(root) @output = output @merge = merge @run_id = run_id end |
Class Method Details
.install_at_exit(root:, output:, merge: false, run_id: nil) ⇒ Object
16 17 18 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 16 def self.install_at_exit(root:, output:, merge: false, run_id: nil) new(root: root, output: output, merge: merge, run_id: run_id).install_at_exit end |
.record(root:, output:) ⇒ Object
12 13 14 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 12 def self.record(root:, output:, &) new(root: root, output: output).record(&) end |
Instance Method Details
#install_at_exit ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 36 def install_at_exit started_at = Time.now.utc started = start_coverage at_exit do finished_at = Time.now.utc 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
27 28 29 30 31 32 33 34 |
# File 'lib/necropsy/analyzers/dynamic/coverage_collector.rb', line 27 def record started_at = Time.now.utc Coverage.start(methods: true) yield write_payload(result: Coverage.result, started_at: started_at, finished_at: Time.now.utc) ensure Coverage.result(stop: true, clear: true) if Coverage.running? end |