C0 code coverage information
Generated on Sun Oct 26 11:17:55 -0500 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.
1 module Aquarium
2 module Utils
3 module TypeUtils
4 def self.is_type? type_or_object
5 type_or_object.kind_of?(Class) or type_or_object.kind_of?(Module)
6 end
7
8 def self.descendents clazz
9 visited = [Class, Object, Module, clazz]
10 result = [clazz]
11 Module.constants.each do |const|
12 mod = Module.class_eval(const)
13 if mod.respond_to?(:ancestors)
14 result << mod if mod.ancestors.include?(clazz)
15 do_descendents clazz, mod, visited, result
16 end
17 end
18 result.uniq
19 end
20
21 def self.nested clazz
22 result = [clazz]
23 clazz.constants.each do |const|
24 mod = clazz.class_eval(const)
25 next unless is_type?(mod)
26 result << mod
27 result << nested(mod)
28 end
29 result.flatten.uniq
30 end
31
32 protected
33
34 # For JRuby classes, we have to "__x__" forms of the reflection methods that don't end in '?'.
35 # That includes "send", so we do some ugly switching, rather than call "mod.send(method_name)"
36 # or "mod.__send__(method_name)"!
37 def self.do_descendents clazz, visiting_module, visited, result
38 visited << visiting_module
39 use_underscore_methods = use_underscore_methods? visiting_module
40 nested_constants = use_underscore_methods ? visiting_module.__constants__ : visiting_module.constants
41 nested_constants.each do |const|
42 next unless visiting_module.const_defined?(const)
43 nested_module = use_underscore_methods ? visiting_module.__const_get__(const) : visiting_module.const_get(const)
44 next if visited.include?(nested_module)
45 next unless responds_to_ancestors?(nested_module)
46 use_underscore_methods2 = use_underscore_methods? nested_module
47 modules_ancestors = use_underscore_methods2 ? nested_module.__ancestors__ : nested_module.ancestors
48 result << nested_module if modules_ancestors.include?(clazz)
49 do_descendents clazz, nested_module, visited, result
50 end
51 end
52
53 def self.use_underscore_methods? mod
54 mod.respond_to?(:__constants__)
55 end
56
57 def self.responds_to_ancestors? mod
58 mod.respond_to?(:ancestors) or mod.respond_to?(:__ancestors__)
59 end
60 end
61 end
62 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.