Class: Slather::ProfdataCoverageFile
Instance Attribute Summary collapse
Instance Method Summary
collapse
#as_json
#branch_coverage_data_for_statement_on_line, #num_branch_hits_for_statement_on_line, #num_branches_for_statement_on_line, #num_branches_testable, #num_branches_tested, #num_lines_testable, #num_lines_tested, #percentage_branch_coverage_for_statement_on_line, #percentage_lines_tested, #rate_branch_coverage_for_statement_on_line, #rate_branches_tested, #rate_lines_tested, #source_file_pathname_relative_to_repo_root
Constructor Details
Returns a new instance of ProfdataCoverageFile.
12
13
14
15
16
|
# File 'lib/slather/profdata_coverage_file.rb', line 12
def initialize(project, source)
self.project = project
self.source = source
create_line_data
end
|
Instance Attribute Details
#line_data ⇒ Object
Returns the value of attribute line_data.
10
11
12
|
# File 'lib/slather/profdata_coverage_file.rb', line 10
def line_data
@line_data
end
|
#project ⇒ Object
Returns the value of attribute project.
10
11
12
|
# File 'lib/slather/profdata_coverage_file.rb', line 10
def project
@project
end
|
#source ⇒ Object
Returns the value of attribute source.
10
11
12
|
# File 'lib/slather/profdata_coverage_file.rb', line 10
def source
@source
end
|
Instance Method Details
#all_lines ⇒ Object
54
55
56
57
58
59
|
# File 'lib/slather/profdata_coverage_file.rb', line 54
def all_lines
if @all_lines == nil
@all_lines = source_code_lines
end
@all_lines
end
|
#branch_coverage_data ⇒ Object
127
128
129
130
131
|
# File 'lib/slather/profdata_coverage_file.rb', line 127
def branch_coverage_data
@branch_coverage_data ||= begin
Hash.new
end
end
|
#cleaned_gcov_data ⇒ Object
61
62
63
|
# File 'lib/slather/profdata_coverage_file.rb', line 61
def cleaned_gcov_data
source_data
end
|
#coverage_for_line(line) ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/slather/profdata_coverage_file.rb', line 98
def coverage_for_line(line)
line = line.gsub(":", "|")
line =~ /^(\s*)(\d*)\|/
if $2 == nil
did_match = line =~ /^(\s*)(\d+\.\d+)(k|M)\|/
if did_match
count = $2.strip
units = $3 == 'k' ? 1000 : 1000000
(count.to_f * units).to_i
else
return nil
end
else
match = $2.strip
case match
when /[0-9]+/
match.to_i
when /#+/
0
when "-"
nil
end
end
end
|
#ignored? ⇒ Boolean
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/slather/profdata_coverage_file.rb', line 146
def ignored?
ignore = false
platform_ignore_list.map do |ignore_suffix|
ignore = source_file_pathname.to_s.end_with? ignore_suffix
if ignore
break
end
end
ignore ? ignore : super
end
|
#line_coverage_data ⇒ Object
92
93
94
95
96
|
# File 'lib/slather/profdata_coverage_file.rb', line 92
def line_coverage_data
source_code_lines.map do |line|
coverage_for_line(line)
end
end
|
#line_number_in_line(line) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/slather/profdata_coverage_file.rb', line 69
def line_number_in_line(line)
line =~ /^(\s*)(\d*)\|(\s*)(\d+)\|/
if $4 != nil
match = $4.strip
case match
when /[0-9]+/
return match.to_i
end
else
did_match = line =~ /^(\s*)(\d+\.\d+)(k|M)\|(\s*)(\d+)\|/
if did_match
match = $5.strip
case match
when /[0-9]+/
return match.to_i
end
end
end
0
end
|
#line_number_separator ⇒ Object
137
138
139
|
# File 'lib/slather/profdata_coverage_file.rb', line 137
def line_number_separator
"|"
end
|
#path_on_first_line? ⇒ Boolean
26
27
28
29
|
# File 'lib/slather/profdata_coverage_file.rb', line 26
def path_on_first_line?
path = self.source.split("\n")[0].sub ":", ""
!path.include?("1|//")
end
|
#raw_data ⇒ Object
65
66
67
|
# File 'lib/slather/profdata_coverage_file.rb', line 65
def raw_data
self.source
end
|
#source_code_lines ⇒ Object
46
47
48
|
# File 'lib/slather/profdata_coverage_file.rb', line 46
def source_code_lines
self.source.split("\n")[(path_on_first_line? ? 1 : 0)..-1]
end
|
#source_data ⇒ Object
50
51
52
|
# File 'lib/slather/profdata_coverage_file.rb', line 50
def source_data
all_lines.join("\n")
end
|
#source_file ⇒ Object
42
43
44
|
# File 'lib/slather/profdata_coverage_file.rb', line 42
def source_file
File.new(source_file_pathname)
end
|
#source_file_basename ⇒ Object
133
134
135
|
# File 'lib/slather/profdata_coverage_file.rb', line 133
def source_file_basename
File.basename(source_file_pathname, '.swift')
end
|
#source_file_pathname ⇒ Object
31
32
33
34
35
36
|
# File 'lib/slather/profdata_coverage_file.rb', line 31
def source_file_pathname
@source_file_pathname ||= begin
path = self.source.split("\n")[0].sub ":", ""
path &&= Pathname(path)
end
end
|
#source_file_pathname=(source_file_pathname) ⇒ Object
38
39
40
|
# File 'lib/slather/profdata_coverage_file.rb', line 38
def source_file_pathname= (source_file_pathname)
@source_file_pathname = source_file_pathname
end
|