Module: SimpleCov::CoverageJSON
- Defined in:
- lib/simplecov/coverage_json.rb
Overview
Shared parser for coverage.json consumers. It enforces the encoding and stable outermost shape while leaving command- or viewer-specific fields to their respective callers.
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Class Method Details
.load(path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/simplecov/coverage_json.rb', line 12 def self.load(path) source = File.binread(path).force_encoding(Encoding::UTF_8) raise Error, "input is not valid UTF-8" unless source.valid_encoding? document = JSON.parse(source) return document if document.is_a?(Hash) raise Error, "top-level value must be an object" rescue JSON::ParserError => e raise Error, e. end |