Module: SimpleCov::CoverageJSON
- Defined in:
- lib/simplecov/coverage_json.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Class Method Details
.load(path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/simplecov/coverage_json.rb', line 9 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.instance_of?(Hash) raise Error, "top-level value must be an object" rescue JSON::ParserError => e raise Error, e end |