C0 code coverage information generated on Wed Mar 15 10:52:01 MST 2006


Marked code looks like this.
This line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this.
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
./lib/dblib.rb 44 44
95.5% 
100.0% 
 1 # Routines for doing some common database tasks
 2 
 3 def quote(str)
 4   return "'#{str.gsub("'", "''")}'"
 5 end
 6 
 7 def quote_all(list)
 8     quoted_fields = []
 9     list.each do |field|
10       quoted_fields << quote(field)
11     end
12     return quoted_fields
13 end
14 
15 def record_exists?(db_connection, table_name, field_values)
16   query = "SELECT count(*) FROM #{table_name} WHERE "
17   first = true
18   field_values.keys.each do |key|
19     if first 
20       first = false
21     else
22       query += "AND "
23     end
24     value = field_values[key]
25     if value
26       query += "#{key} = #{quote(field_values[key])} "
27     else
28       query += "#{key} is null "
29     end
30   end
31   puts query
32 
33   num_rows = 0
34   db_connection.exec(query) do |r|
35     if r != nil and r.length > 0
36       num_rows = r[0].to_i
37     end
38     break
39   end
40 
41   return num_rows > 0
42 end
43 
44 

Valid XHTML 1.0!Valid CSS!