C0 code coverage information

Generated on Sat Feb 02 17:44:24 +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/cache.rb 89 50
95.5% 
92.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 require 'ramaze/cache/memory'
 5 
 6 module Ramaze
 7   autoload :YAMLStoreCache, "ramaze/cache/yaml_store.rb"
 8   autoload :MemcachedCache, "ramaze/cache/memcached.rb"
 9 
10   # This is the wrapper of all caches, providing mechanism
11   # for switching caching from one adapter to another.
12 
13   class Cache
14     include Enumerable
15 
16     # Holds all the instances of Cache that are being added.
17     CACHES = {} unless defined?(CACHES)
18 
19     attr_accessor :cache
20 
21     class << self
22 
23       # Initializes the Cache for the general caches Ramaze uses.
24       # Cache#startup is called by Ramaze#startup, when initializing the
25       # Ramaze.trait(:essentials).
26 
27       def startup(options)
28         Cache.add :compiled, :actions, :patterns,
29                   :resolved, :shield, :action_methods
30       end
31 
32       # This will define a method to access a new cache directly over
33       # singleton-methods on Cache.
34       #---
35       # The @cache_name is internally used for caches which do not save
36       # different caches in different namespaces, for example memcached.
37       #+++
38 
39       def add *keys
40         keys.each{|key|
41           klass = Global.cache_alternative.fetch(key, self)
42           add_on(key, klass)
43         }
44         Inform.dev("Added caches for: #{keys.join(', ')}")
45       end
46 
47       def add_on(key, cache_class)
48         CACHES[key] = new(cache_class)
49         CACHES[key].instance_variable_set("@cache_name", key)
50         self.class.class_eval do
51           define_method(key){ CACHES[key] }
52         end
53       end
54 
55     end
56 
57     # Initializes the cache, defined by Global.cache
58     def initialize(cache = Global.cache)
59       @cache = cache.new
60     end
61 
62     # Get key.
63     def [](key)
64       @cache["#{@cache_name}:#{key}"]
65     end
66 
67     # Set key to value.
68     def []=(key, value)
69       @cache["#{@cache_name}:#{key}"] = value
70     end
71 
72     # deletes the keys of each argument passed from Cache instance.
73     def delete(*args)
74       args.each do |arg|
75         @cache.delete("#{@cache_name}:#{arg}")
76       end
77     end
78 
79     # Empty this cache
80     def clear
81       @cache.clear
82     end
83 
84     # Answers with value for each key.
85     def values_at(*keys)
86       @cache.values_at(*keys.map {|key| "#{@cache_name}:#{key}" })
87     end
88   end
89 end

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

Valid XHTML 1.0! Valid CSS!