Class: Xccov::Parse

Inherits:
Object
  • Object
show all
Defined in:
lib/xccov-parse/parse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file: nil, json: nil) ⇒ Parse

Returns a new instance of Parse.



7
8
9
10
# File 'lib/xccov-parse/parse.rb', line 7

def initialize(file: nil, json: nil)
  @data = JSON.parse(json) if json
  @data = JSON.parse(File.read(file)) if file
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/xccov-parse/parse.rb', line 5

def data
  @data
end

Instance Method Details

#targets_line_coverageObject



16
17
18
19
20
# File 'lib/xccov-parse/parse.rb', line 16

def targets_line_coverage
  @data.reduce({}) do |memo, data|
    memo.merge({ data["name"] => data["lineCoverage"] })
  end
end

#targets_nameObject



12
13
14
# File 'lib/xccov-parse/parse.rb', line 12

def targets_name
  @data.map { |data| data["name"] }
end