Class: Xccov::Parse
- Inherits:
-
Object
- Object
- Xccov::Parse
- Defined in:
- lib/xccov-parse/parse.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(file: nil, json: nil) ⇒ Parse
constructor
A new instance of Parse.
- #targets_line_coverage ⇒ Object
- #targets_name ⇒ Object
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
#data ⇒ Object (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_coverage ⇒ Object
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_name ⇒ Object
12 13 14 |
# File 'lib/xccov-parse/parse.rb', line 12 def targets_name @data.map { |data| data["name"] } end |