Class: Coverage::HTMLPrinter::Index
- Inherits:
-
Object
- Object
- Coverage::HTMLPrinter::Index
show all
- Includes:
- Utility
- Defined in:
- lib/coverage/html_printer.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Utility
#coverage_bar, #javascript, #stylesheet
Constructor Details
#initialize(path_settings, project_name, files) ⇒ Index
Returns a new instance of Index.
101
102
103
104
105
|
# File 'lib/coverage/html_printer.rb', line 101
def initialize(path_settings, project_name, files)
@path_settings = path_settings
@project_name = project_name
@files = files
end
|
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
99
100
101
|
# File 'lib/coverage/html_printer.rb', line 99
def files
@files
end
|
#project_name ⇒ Object
Returns the value of attribute project_name.
99
100
101
|
# File 'lib/coverage/html_printer.rb', line 99
def project_name
@project_name
end
|
Instance Method Details
#code_coverage ⇒ Object
133
134
135
136
|
# File 'lib/coverage/html_printer.rb', line 133
def code_coverage
coverage = "%0.2f" % [(lines_of_covered_code / lines_of_code.to_f) * 100]
coverage_bar(coverage)
end
|
#lines_of_code ⇒ Object
120
121
122
|
# File 'lib/coverage/html_printer.rb', line 120
def lines_of_code
@lines_of_code ||= @files.inject(0){|memo, detail| memo + detail.lines_of_code }
end
|
#lines_of_covered_code ⇒ Object
124
125
126
|
# File 'lib/coverage/html_printer.rb', line 124
def lines_of_covered_code
@lines_of_covered_code ||= @files.inject(0){|memo, detail| memo + detail.lines_of_covered_code }
end
|
#print ⇒ Object
107
108
109
110
111
112
113
114
|
# File 'lib/coverage/html_printer.rb', line 107
def print
erb = ERB.new(File.read(template_path), nil, '-')
index_path = @path_settings.output_directory + "index.html"
erb.filename = index_path.to_s
File.open(index_path, "wb+") do |html|
html.puts(erb.result(binding))
end
end
|
#total ⇒ Object
116
117
118
|
# File 'lib/coverage/html_printer.rb', line 116
def total
@total ||= @files.inject(0){|memo, detail| memo + detail.total }
end
|
#total_coverage ⇒ Object
128
129
130
131
|
# File 'lib/coverage/html_printer.rb', line 128
def total_coverage
coverage = "%0.2f" % [(lines_of_covered_code / total.to_f) * 100]
coverage_bar(coverage)
end
|