Class: Coverband::Utils::Results
- Inherits:
-
Object
- Object
- Coverband::Utils::Results
show all
- Defined in:
- lib/coverband/utils/results.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(report) ⇒ Results
Returns a new instance of Results.
11
12
13
14
15
|
# File 'lib/coverband/utils/results.rb', line 11
def initialize(report)
self.report = report
self.type = Coverband::MERGED_TYPE
@results = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/coverband/utils/results.rb', line 64
def method_missing(method, *args)
if get_results(type).respond_to?(method)
get_results(type).send(method, *args)
else
super
end
end
|
Instance Attribute Details
#report ⇒ Object
Returns the value of attribute report.
9
10
11
|
# File 'lib/coverband/utils/results.rb', line 9
def report
@report
end
|
#type ⇒ Object
Returns the value of attribute type.
9
10
11
|
# File 'lib/coverband/utils/results.rb', line 9
def type
@type
end
|
Instance Method Details
#command_name ⇒ Object
85
86
87
|
# File 'lib/coverband/utils/results.rb', line 85
def command_name
@command_name ||= "Coverband"
end
|
#created_at ⇒ Object
81
82
83
|
# File 'lib/coverband/utils/results.rb', line 81
def created_at
@created_at ||= Time.now
end
|
#file_from_path_with_type(full_path, results_type = :merged) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/coverband/utils/results.rb', line 54
def file_from_path_with_type(full_path, results_type = :merged)
return unless get_results(results_type)
@files_from_path_with_type ||= {}
@files_from_path_with_type[results_type] ||= get_results(results_type).source_files.map do |source_file|
[source_file.filename, source_file]
end.to_h
@files_from_path_with_type[results_type][full_path]
end
|
#file_with_type(source_file, results_type) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/coverband/utils/results.rb', line 17
def file_with_type(source_file, results_type)
return unless get_results(results_type)
@files_with_type ||= {}
@files_with_type[results_type] ||= get_results(results_type).source_files.map do |source_file|
[source_file.filename, source_file]
end.to_h
@files_with_type[results_type][source_file.filename]
end
|
#groups ⇒ Object
Note: small set of hacks for static html simplecov report (groups, created_at, & command_name)
77
78
79
|
# File 'lib/coverband/utils/results.rb', line 77
def groups
@groups ||= {}
end
|
#respond_to_missing?(method) ⇒ Boolean
72
73
74
|
# File 'lib/coverband/utils/results.rb', line 72
def respond_to_missing?(method)
get_results(type).respond_to?(method)
end
|
#runtime_relavent_lines(source_file) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/coverband/utils/results.rb', line 41
def runtime_relavent_lines(source_file)
return 0 unless runtime_coverage
eager_file = get_eager_file(source_file)
runtime_file = get_runtime_file(source_file)
return 0 unless runtime_file
return runtime_file.covered_lines_count unless eager_file
eager_file.relevant_lines - eager_file.covered_lines_count
end
|
#runtime_relevant_coverage(source_file) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/coverband/utils/results.rb', line 27
def runtime_relevant_coverage(source_file)
return unless eager_loading_coverage && runtime_coverage
eager_file = get_eager_file(source_file)
runtime_file = get_runtime_file(source_file)
return 0.0 unless runtime_file
return runtime_file.formatted_covered_percent unless eager_file
runtime_relavant_lines = eager_file.relevant_lines - eager_file.covered_lines_count
runtime_file.runtime_relavant_calculations(runtime_relavant_lines) { |file| file.formatted_covered_percent }
end
|