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/object/traits.rb 76 25
98.7% 
96.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 Traits = Hash.new{|h,k| h[k] = {}} unless defined?(Traits)
 5 
 6 # Extensions for Object
 7 
 8 class Object
 9 
10   # Adds a method to Object to annotate your objects with certain traits.
11   # It's basically a simple Hash that takes the current object as key
12   #
13   # Example:
14   #
15   #   class Foo
16   #     trait :instance => false
17   #
18   #     def initialize
19   #       trait :instance => true
20   #     end
21   #   end
22   #
23   #   Foo.trait[:instance]
24   #   # false
25   #
26   #   foo = Foo.new
27   #   foo.trait[:instance]
28   #   # true
29 
30   def trait hash = nil
31     if hash
32       Traits[self].merge! hash
33     else
34       Traits[self]
35     end
36   end
37 
38   # builds a trait from all the ancestors, closer ancestors
39   # overwrite distant ancestors
40   #
41   # class Foo
42   #   trait :one => :eins
43   #   trait :first => :erstes
44   # end
45   #
46   # class Bar < Foo
47   #   trait :two => :zwei
48   # end
49   #
50   # class Foobar < Bar
51   #   trait :three => :drei
52   #   trait :first => :overwritten
53   # end
54   #
55   # Foobar.ancestral_trait
56   # {:three=>:drei, :two=>:zwei, :one=>:eins, :first=>:overwritten}
57 
58   def ancestral_trait
59     if respond_to?(:ancestors)
60       ancs = ancestors
61     else
62       ancs = self.class.ancestors
63     end
64     ancs.reverse.inject({}){|s,v| s.merge(v.trait)}.merge(trait)
65   end
66 
67   # trait for self.class
68 
69   def class_trait
70     if respond_to?(:ancestors)
71       trait
72     else
73       self.class.trait
74     end
75   end
76 end

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

Valid XHTML 1.0! Valid CSS!