C0 code coverage information

Generated on Fri Aug 10 13:52:34 -0300 2007 with rcov 0.7.0


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/metric_listeners.rb 106 96
100.0% 
100.0% 
  1 require "rexml/parsers/baseparser"
  2 require "rexml/parsers/streamparser"
  3 require "rexml/streamlistener"
  4 include REXML
  5 
  6 class ListenerAdapter
  7   include StreamListener
  8   
  9   def initialize(metricId, collector, listeners = {"MetricDescriptions" => :FullListener, "Cycle" => :FlatListener})
 10     super()
 11     @metricId = metricId
 12     @collector = collector
 13     @listeners = listeners
 14     @strategy = nil
 15   end
 16   
 17   def tag_start(name, attributes)
 18     @strategy.tag_start(name, attributes) unless @strategy.nil?
 19   end
 20   
 21   def tag_end(name)
 22     if @strategy.nil?
 23       if @listeners.has_key? name
 24         @strategy = Object.const_get(@listeners[name]).new(@metricId, @collector)
 25       end
 26     else
 27       @strategy.tag_end(name)
 28     end
 29   end
 30 end
 31 
 32 class FullListener
 33   def initialize(metricId, collector)
 34     @metricId = metricId
 35     @collector = collector
 36     @inType = nil
 37     @inPackage = nil
 38     @inMethod = false
 39   end
 40   
 41   def tag_start(name, attributes)
 42     if name == "Type"
 43       @inType = attributes["handle"]
 44     elsif name == "Package"
 45       @inPackage = attributes["handle"]
 46     elsif name == "Method"
 47       @inMethod = true
 48     elsif name == "Metric" && attributes["id"] == @metricId
 49       if !@inMethod && @inType != nil
 50         @collector.new_metric(@inType, attributes["value"].tr(',','.').to_f)
 51       elsif @inPackage != nil && attributes["per"].nil?
 52         @collector.new_metric(@inPackage, attributes["value"].tr(',','.').to_f)
 53       end
 54     end
 55   end
 56   
 57   def tag_end(name)
 58     if name == "Type"
 59       @inType = nil
 60     elsif name == "Package"
 61       @inPackage = nil
 62     elsif name == "Method"
 63       @inMethod = false
 64     end
 65   end
 66 end
 67 
 68 class FlatListener
 69   def initialize(metricId, collector)
 70     @metricId = metricId
 71     @collector = collector
 72     @inMetric = false
 73     @perMethod = false
 74     @perPackage = false
 75   end
 76   
 77   def tag_start(name, attributes)
 78     if name == "Metric" && attributes["id"] == @metricId
 79       @inMetric = true
 80     elsif name == "Values" && @inMetric
 81       if attributes["per"] == "method"
 82         @perMethod = true
 83       elsif attributes["per"] == "packageFragment"
 84         @perPackage = true
 85       end
 86     elsif name == "Value" && @inMetric
 87       type = "#{attributes['package']}.#{attributes['source']}"
 88       if @perMethod
 89         @collector.add_metric(type, attributes["value"].tr(',','.').to_f)
 90       elsif @perPackage
 91         @collector.new_metric(attributes['package'], attributes["value"].tr(',','.').to_f)
 92       else
 93         @collector.new_metric(type, attributes["value"].tr(',','.').to_f)
 94       end
 95     end
 96   end
 97   
 98   def tag_end(name)
 99     if name == "Metric"
100       @inMetric = false
101     elsif name == "Values"
102       @perMethod = false
103       @perPackage = false
104     end
105   end
106 end

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

Valid XHTML 1.0! Valid CSS!