C0 code coverage information

Generated on Sat Feb 02 17:44:29 +0100 2008 with rcov 0.8.1.2


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
lib/ramaze/snippets/ramaze/caller_lines.rb 51 18
100.0% 
100.0% 
 1 #          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
 2 # All files in this distribution are subject to the terms of the Ruby license.
 3 
 4 module Ramaze
 5 
 6   # Gives you some context around a specific line in a file.
 7   # the size argument works in both directions + the actual line,
 8   # size = 2 gives you 5 lines of source, the returned array has the
 9   # following format.
10   #   [
11   #     line = [
12   #              lineno           = Integer,
13   #              line             = String,
14   #              is_searched_line = (lineno == initial_lineno)
15   #            ],
16   #     ...,
17   #     ...
18   #   ]
19   # Example:
20   #  caller_lines('/usr/lib/ruby/1.8/debug.rb', 122, 2) # ->
21   #   [
22   #     [ 120, "  def check_suspend",                               false ],
23   #     [ 121, "    return if Thread.critical",                     false ],
24   #     [ 122, "    while (Thread.critical = true; @suspend_next)", true  ],
25   #     [ 123, "      DEBUGGER__.waiting.push Thread.current",      false ],
26   #     [ 124, "      @suspend_next = false",                       false ]
27   #   ]
28 
29   def self.caller_lines(file, line, size = 4)
30     return [[0, file, true]] if file == '(eval)'
31     lines = File.readlines(File.expand_path(file)) rescue []
32     current = line.to_i - 1
33 
34     first = current - size
35     first = first < 0 ? 0 : first
36 
37     last = current + size
38     last = last > lines.size ? lines.size : last
39 
40     log = lines[first..last] || []
41 
42     area = []
43 
44     log.each_with_index do |line, index|
45       index = index + first + 1
46       area << [index, line.chomp, index == current + 1]
47     end
48 
49     area
50   end
51 end

Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.

Valid XHTML 1.0! Valid CSS!