C0 code coverage information

Generated on Mon Nov 03 16:07:05 +0900 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/twowaysql/node.rb 237 195
98.3%  
97.9%  
 1
    module TwoWaySQL  2
     3 class Context
     4  5 def initialize(data)  6 @data = data  7 @enabled = true  8 @bound_variables = []  9 @sql_fragments = []  10 end  11 attr_reader :bound_variables
     12 attr_reader
    :sql_fragments  13
    attr_reader :data  14
     15 def
    sql(separator="")  16 @sql_fragments.join(separator)  17 end  18  19 def fork_child  20 child = Context.new(@data)  21 child.disable!  22 child  23 end  24  25 def join_child(child_ctx)  26
    @sql_fragments.concat(child_ctx.sql_fragments)  27
    @bound_variables.concat(child_ctx.bound_variables)  28 end  29  30 def add_sql(sql_fragment)  31 @sql_fragments <<
    sql_fragment  32 end
     33  34 def add_value(value)  35 @sql_fragments << '?'
     36 @bound_variables
    << value  37 end
     38  39 def add_values(values)  40 @sql_fragments <<
    Array.new(values.size, '?').join(', ')  41 @bound_variables.concat(values)  42 end  43  44 def enabled?  45 @enabled  46 end  47  48
    def enable!  49 @enabled =
    true  50 end
     51  52 protected  53 def disable!  54 @enabled = false  55 end  56 end  57  58 
    59  60 class Node
     61 protected  62 def exec_list(nodes, ctx)
     63 v = nil  64 nodes.each do |i|  65 v = i.accept(ctx)  66 end  67 v  68 end  69  70
    def do_eval(ctx, exp)  71
    safe_eval(ctx.data, exp)  72 end  73  74
    private  75 def
    safe_eval(ctx, exp)  76
    within_safe_level(4) { eval(exp) }  77 end  78  79
    def within_safe_level(level)  80 result = nil  81 Thread.start {  82 $SAFE = level  83 result = yield  84 }.join  85 result  86 end  87 end  88 
    89  90 class RootNode <
    Node  91 def
    initialize(tree)  92 @tree
    = tree  93 end
     94 def accept(ctx)
     95 exec_list(@tree, ctx)
     96 end  97 end  98  99 100
    class IfNode < Node 101 def initialize(cond, tstmt, fstmt) 102 @condition = cond 103 @tstmt = tstmt 104 @fstmt = fstmt 105 end 106 def accept(ctx) 107 if do_eval(ctx, @condition)
    108 exec_list(@tstmt,
    ctx) 109 ctx.enable!
    110 elsif @fstmt
    111 exec_list(@fstmt,
    ctx) 112 ctx.enable!
    113 end 114 end 115 end 116 117 118 class BeginNode < Node 119 def initialize(tree) 120 @tree = tree 121 end 122 def accept(ctx) 123 child_ctx = ctx.fork_child
    124 exec_list(@tree,
    child_ctx) 125 if
    child_ctx.enabled? 126
    ctx.join_child(child_ctx) 127 end 128 end 129 end 130 131 132 class SubStatementNode < Node 133 def initialize(first_node, tree)
    134 @first_node =
    first_node 135 @tree =
    tree 136 end
    137 def accept(ctx)
    138
    ctx.add_sql(@first_node) if ctx.enabled? 139 exec_list(@tree, ctx) 140 end 141 def each 142 yield self 143 end 144 end 145 146 147 class BindVariableNode < Node 148 def initialize(exp) 149 @exp = exp 150 end 151 def accept(ctx) 152 ctx.add_value(do_eval(ctx, @exp))
    153 end 154 end 155 156 157 class QuestionNode < Node 158 def initialize(num) 159 @num = num 160 end 161 def accept(ctx) 162 ctx.add_value(ctx.data[@num])
    163 end 164 end 165 166 167 class ParenBindVariableNode < Node 168 def initialize(exp) 169 @exp = exp 170 end 171 def accept(ctx) 172 result = do_eval(ctx, @exp)
    173 return if result.nil?
    174 ##TODO: is there
    any better way to handle array-like structure? 175 if result.respond_to?('to_ary')
    176 bind_values(ctx,
    result.to_ary) 177
    else 178
    ctx.add_value(result) 179 end 180 end 181 def bind_values(ctx, ary) 182 return if ary.empty? 183 ctx.add_sql("(")
    184 ctx.add_values(ary)
    185
    ctx.add_sql(")") 186 end 187 end 188 189 190 class EmbedVariableNode < Node 191 def initialize(exp) 192 @exp = exp 193 end 194 def accept(ctx) 195 result = do_eval(ctx, @exp)
    196 ctx.add_sql(result)
    unless result.nil? 197
    end 198 end
    199 200 201 class LiteralNode < Node 202 def initialize(val) 203 @val = val 204 end 205 def accept(ctx) 206 ctx.add_sql(@val) 207 end 208 end 209 210 211 class ActualCommentNode < Node 212 def initialize(delim, content)
    213 @delim = delim
    214 @content = content
    215 end 216 def accept(ctx) 217
    ctx.add_sql("#{@delim}*#{@content}*#{@delim}") 218 end 219 end 220 221 222 class WhiteSpaceNode < Node 223 def initialize(val, preserve)
    224 @val = val
    225 @preserve = preserve
    226 end 227 def accept(ctx) 228 if @preserve 229 ctx.add_sql(@val) 230 else 231 ctx.add_sql(" ")
    232 end 233 end 234 end 235 236 237 end 

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

Valid XHTML 1.0! Valid CSS!