class XCPerfect::Parser
Parser
is used by `Formatter`s to extract information from the JSON file generated by xccov
Constants
- KEY_COVERED_LINES
- KEY_EXECUTABLE_LINES
- KEY_TARGETS
Attributes
json[RW]
Public Class Methods
new(json)
click to toggle source
# File lib/xcperfect/parser.rb, line 11 def initialize(json) @json = json end
Public Instance Methods
all_targets()
click to toggle source
# File lib/xcperfect/parser.rb, line 15 def all_targets @json[KEY_TARGETS] end
coverage_percentage(target)
click to toggle source
# File lib/xcperfect/parser.rb, line 41 def coverage_percentage(target) target['lineCoverage'].round(2) end
covered_line_num(target)
click to toggle source
# File lib/xcperfect/parser.rb, line 45 def covered_line_num(target) target['coveredLines'] end
extract_coverage_info(target)
click to toggle source
# File lib/xcperfect/parser.rb, line 32 def extract_coverage_info(target) [ target['name'], covered_line_num(target), total_line_num(target), coverage_percentage(target) ] end
extract_targets(desirables)
click to toggle source
# File lib/xcperfect/parser.rb, line 19 def extract_targets(desirables) if desirables.length.zero? all_targets else all_targets.select do |target_info| pure_name = target_info['name'].split('.') pure_name.pop(1) pure_name = pure_name.join('.') desirables.include?(pure_name) end end end
total_line_num(target)
click to toggle source
# File lib/xcperfect/parser.rb, line 49 def total_line_num(target) target['executableLines'] end