Module: Uncov::Report::Context
- Defined in:
- lib/uncov/report/context.rb
Overview
calculate context for important lines,
Class Method Summary collapse
- .add_context(finder, file_name, lines_hash) ⇒ Object
- .calculate(all_line_numbers, important_line_number, context) ⇒ Object
Class Method Details
.add_context(finder, file_name, lines_hash) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/uncov/report/context.rb', line 7 def add_context(finder, file_name, lines_hash) return if Uncov.configuration.context.zero? line_numbers = lines_hash.filter_map do |line_number, line| line_number if line.trigger? end all_line_numbers = finder.file_system_files.lines(file_name).keys context_line_numbers = calculate(all_line_numbers, line_numbers, Uncov.configuration.context) context_line_numbers.each do |line_number| mark_context_line(finder, file_name, lines_hash, line_number) end end |
.calculate(all_line_numbers, important_line_number, context) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/uncov/report/context.rb', line 21 def calculate(all_line_numbers, important_line_number, context) context_line_numbers = {} important_line_number.each do |line_number| (1..context).to_a.each do |offset| context_line_numbers[line_number - offset] = true context_line_numbers[line_number + offset] = true end end (context_line_numbers.keys.sort & all_line_numbers) - important_line_number end |