Class: FastCov::FileTracker

Inherits:
AbstractTracker show all
Defined in:
lib/fast_cov/trackers/file_tracker.rb

Overview

Tracks files read from disk during coverage (JSON, YAML, .rb templates, etc.) via File.read, File.open, and YAML load methods.

YAML methods are patched separately because Bootsnap’s compile cache overrides YAML.load_file/safe_load_file to bypass File.open entirely.

Register via: coverage_map.use(FastCov::FileTracker)

Defined Under Namespace

Modules: FilePatch, YamlPatch

Instance Attribute Summary

Attributes inherited from AbstractTracker

#coverage_map

Instance Method Summary collapse

Methods inherited from AbstractTracker

#initialize, #on_record, #on_start, #on_stop, #record, record, reset, #root, #start, #stop

Constructor Details

This class inherits a constructor from FastCov::AbstractTracker

Instance Method Details

#installObject



14
15
16
17
18
19
20
21
22
# File 'lib/fast_cov/trackers/file_tracker.rb', line 14

def install
  unless File.singleton_class.ancestors.include?(FilePatch)
    File.singleton_class.prepend(FilePatch)
  end

  if defined?(::YAML) && !::YAML.singleton_class.ancestors.include?(YamlPatch)
    ::YAML.singleton_class.prepend(YamlPatch)
  end
end