Class: CodeCoverage::CoverageParser

Inherits:
Object
  • Object
show all
Defined in:
lib/code_coverage/coverage_parser.rb

Overview

Parse json files of code-coverage-api plugin and converts it into an array of [CoverageItem]. Empty array if not parseable.

Instance Method Summary collapse

Instance Method Details

#parse(content) ⇒ Array<CoverageItem>

Parse json string into [CoverageItem] array.

Parameters:

  • content

    Json string to parse.

Returns:

  • (Array<CoverageItem>)

    Empty array of filled with [CoverageItem].



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/code_coverage/coverage_parser.rb', line 14

def parse(content)
  raw_json =
    begin
      JSON.parse(content)
      # rubocop:disable Style/RescueStandardError
    rescue
      # rubocop:enable Style/RescueStandardError
      {}
    end
  parse_coverage(raw_json)
end