C0 code coverage information

Generated on Sat Feb 02 17:44:26 +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/helper/aspect.rb 92 52
73.9% 
53.8% 
 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   # A helper that provides the means to wrap actions of the controller with
 7   # other methods.
 8   #
 9   # For examples please look at the spec/ramaze/helper/aspect.rb
10   #
11   # This is not a default helper due to the possible performance-issues.
12   # However, it should be only an overhead of about 6-8 calls, so if you
13   # want this feature it shouldn't have too large impact ;)
14   #
15   # Like every other helper, you can use it in your controller with:
16   #
17   #   helper :aspect
18 
19   module AspectHelper
20 
21     # Define traits on class this module is included into.
22 
23     def self.included(klass)
24       klass.trait[:aspects] ||= { :before => {}, :after => {} }
25     end
26 
27     private
28 
29     # run block before given actions.
30     def before(*meths, &block)
31       aspects = trait[:aspects][:before]
32       meths.each do |meth|
33         aspects[meth.to_s] = block
34       end
35     end
36     alias pre before
37 
38     # Run block before all actions.
39     def before_all(&block)
40       trait[:aspects][:before][:all] = block
41     end
42     alias pre_all before_all
43 
44     # run block after given actions.
45     def after(*meths, &block)
46       aspects = trait[:aspects][:after]
47       meths.each do |meth|
48         aspects[meth.to_s] = block
49       end
50     end
51     alias post after
52 
53     # Run block after all actions.
54     def after_all(&block)
55       trait[:aspects][:after][:all] = block
56     end
57     alias post_all after_all
58 
59     # run block before and after given actions.
60     def wrap(*meths, &block)
61       before(*meths, &block)
62       after(*meths, &block)
63     end
64 
65     # run block before and after all actions.
66     def wrap_all(&block)
67       trait[:aspects][:before][:all] = block
68       trait[:aspects][:after][:all] = block
69     end
70   end
71 
72   class Action
73 
74     # overwrites the default Action hook and runs the neccesary blocks in its
75     # scope.
76     def before_process
77       return unless path and aspects = controller.ancestral_trait[:aspects]
78       [ aspects[:before][name], aspects[:before][:all] ].compact.map do |block|
79         instance.instance_eval(&block) if block
80       end
81     end
82 
83     # overwrites the default Action hook and runs the neccesary blocks in its
84     # scope.
85     def after_process
86       return unless path and aspects = controller.ancestral_trait[:aspects]
87       [ aspects[:after][name], aspects[:after][:all] ].compact.map do |block|
88         instance.instance_eval(&block) if block
89       end
90     end
91   end
92 end

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

Valid XHTML 1.0! Valid CSS!