module SimpleCov::SimulateCoverage
def coverage_stub(path, source_lines)
or parse the file, or when the runtime doesn't expose `line_stub`
falls back to `LinesClassifier` alone — when `Coverage` can't read
`# simplecov:disable line` ranges). Returns nil — and the caller
with `LinesClassifier` (which knows about `# :nocov:` toggles and
Combine `Coverage.line_stub` (which gets multi-line statements right)
def coverage_stub(path, source_lines) return nil unless Coverage.respond_to?(:line_stub) stub = Coverage.line_stub(path) classifier_output = LinesClassifier.new.classify(source_lines) stub.each_index { |idx| stub[idx] = nil if classifier_output[idx].nil? } stub rescue Errno::ENOENT, SyntaxError nil end