Module: OyenCov::SimplecovResultsetTranslator
- Defined in:
- lib/oyencov/simplecov_resultset_translator.rb
Constant Summary collapse
- PWD =
Dir.pwd
Class Method Summary collapse
Class Method Details
.translate(resultset_json_path, persist: false) ⇒ String
Returns JSON file.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/oyencov/simplecov_resultset_translator.rb', line 28 def self.translate(resultset_json_path, persist: false) # Open up the JSON resultset = JSON.parse(File.read(resultset_json_path)) # binding.irb # Loop through all the files # Set {"method" => runs, ...} all_methods_hits = resultset[resultset.keys[0]]["coverage"].each_pair.map do |file_path, file_attr| # file_path = file_path.gsub(/#{PWD}\//o, "") line_hits = file_attr["lines"] MethodRangeParser[file_path]&.each_pair&.map do |method_name, line_num| next if line_num.nil? || line_hits[line_num].nil? [method_name, line_hits[line_num]] end&.compact.to_h # methods_hits end.reduce(:merge) # Persist to existing oyencov report? if persist OyenCov::TestReportMerger.create_or_append!(method_hits: all_methods_hits) end all_methods_hits end |