123456789_123456789_123456789_123456789_123456789_

Module: SimpleCov::ResultMerger::ResultsetFile

Relationships & Source Files
Defined in: lib/simplecov/result_merger/resultset_file.rb

Overview

Read + parse a .resultset.json file with the same tolerance the historical ::SimpleCov::ResultMerger had: missing file returns {}, an empty or unparseable file warns and returns {}, parse success returns the decoded Hash.

Class Method Summary

Class Method Details

.decode(content) (mod_func)

[ GitHub ]

  
# File 'lib/simplecov/result_merger/resultset_file.rb', line 28

def decode(content)
  return {} unless content

  JSON.parse(content) || {}
rescue StandardError
  warn "[SimpleCov]: Warning! Parsing JSON content of resultset file failed"
  {}
end

.parse(path) (mod_func)

[ GitHub ]

  
# File 'lib/simplecov/result_merger/resultset_file.rb', line 14

def parse(path)
  data = read(path)
  decode(data)
end

.read(path) (mod_func)

[ GitHub ]

  
# File 'lib/simplecov/result_merger/resultset_file.rb', line 19

def read(path)
  return unless File.exist?(path)

  data = File.read(path)
  return if data.nil? || data.length < 2

  data
end