Class: DeepCover::Reporter::Istanbul
- Inherits:
-
Struct
- Object
- Struct
- DeepCover::Reporter::Istanbul
show all
- Includes:
- Converters
- Defined in:
- lib/deep_cover/reporter/istanbul.rb
Defined Under Namespace
Modules: Converters
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Converters
#convert_block, #convert_branch, #convert_def, #convert_function, #convert_list, #convert_range
Instance Attribute Details
#covered_code ⇒ Object
Returns the value of attribute covered_code
7
8
9
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 7
def covered_code
@covered_code
end
|
#options ⇒ Object
Returns the value of attribute options
7
8
9
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 7
def options
@options
end
|
Class Method Details
.available? ⇒ Boolean
148
149
150
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 148
def available?
`nyc --version` >= '11.' rescue false
end
|
Instance Method Details
#branch_map ⇒ Object
93
94
95
96
97
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 93
def branch_map
branches.map do |node, branches_runs|
convert_branch(node, branches_runs.keys)
end
end
|
#branch_runs ⇒ Object
104
105
106
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 104
def branch_runs
branches.values.map { |r| zero_to_something(r.values) }
end
|
#branches ⇒ Object
89
90
91
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 89
def branches
@branches ||= Analyser::Branch.new(node_analyser, **options).results
end
|
#convert ⇒ Object
135
136
137
138
139
140
141
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 135
def convert
{covered_code.name => {
path: covered_code.path,
**data.transform_values { |l| convert_list(l) },
},
}
end
|
#data ⇒ Object
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 124
def data
{
statementMap: statement_map,
s: statement_runs,
fnMap: function_map,
f: function_runs,
branchMap: branch_map,
b: branch_runs,
}
end
|
#function_map ⇒ Object
116
117
118
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 116
def function_map
functions.keys.map { |n| convert_function(n) }
end
|
#function_runs ⇒ Object
120
121
122
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 120
def function_runs
functions.values
end
|
#functions ⇒ Object
81
82
83
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 81
def functions
@functions ||= Analyser::Function.new(node_analyser, **options).results
end
|
#node_analyser ⇒ Object
73
74
75
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 73
def node_analyser
@node_analyser ||= Analyser::Node.new(covered_code, **options)
end
|
#node_runs ⇒ Object
77
78
79
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 77
def node_runs
@node_runs ||= node_analyser.results
end
|
#report ⇒ Object
143
144
145
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 143
def report
convert.to_json
end
|
#statement_map ⇒ Object
108
109
110
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 108
def statement_map
statements.keys.map { |range| convert_range(range) }
end
|
#statement_runs ⇒ Object
112
113
114
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 112
def statement_runs
statements.values
end
|
#statements ⇒ Object
85
86
87
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 85
def statements
@statements ||= Analyser::Statement.new(node_analyser, **options).results
end
|
#zero_to_something(values) ⇒ Object
Istanbul doesn’t understand how to ignore a branch…
100
101
102
|
# File 'lib/deep_cover/reporter/istanbul.rb', line 100
def zero_to_something(values)
values.map { |v| v || 1 }
end
|