C0 code coverage information

Generated on Tue May 30 23:34:44 CEST 2006 with rcov 0.5.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/login_system.rb 85 34
60.0% 
23.5% 
 1 module LoginSystem 
 2   
 3   protected
 4   
 5   # overwrite this if you want to restrict access to only a few actions
 6   # or if you want to check if the user has the correct rights  
 7   # example:
 8   #
 9   #  # only allow nonbobs
10   #  def authorize?(user)
11   #    user.login != "bob"
12   #  end
13   def authorize?(user)
14      true
15   end
16   
17   # overwrite this method if you only want to protect certain actions of the controller
18   # example:
19   # 
20   #  # don't protect the login and the about method
21   #  def protect?(action)
22   #    if ['action', 'about'].include?(action)
23   #       return false
24   #    else
25   #       return true
26   #    end
27   #  end
28   def protect?(action)
29     true
30   end
31    
32   # login_required filter. add 
33   #
34   #   before_filter :login_required
35   #
36   # if the controller should be under any rights management. 
37   # for finer access control you can overwrite
38   #   
39   #   def authorize?(user)
40   # 
41   def login_required
42     
43     if not protect?(action_name)
44       return true  
45     end
46 
47     if session[:user] and authorize?(session[:user])
48       return true
49     end
50 
51     # store current location so that we can 
52     # come back after the user logged in
53     store_location
54   
55     # call overwriteable reaction to unauthorized access
56     access_denied
57     return false 
58   end
59 
60   # overwrite if you want to have special behavior in case the user is not authorized
61   # to access the current operation. 
62   # the default action is to redirect to the login screen
63   # example use :
64   # a popup window might just close itself for instance
65   def access_denied
66     redirect_to :controller=>"/accounts", :action =>"login"
67   end  
68   
69   # store current uri in  the session.
70   # we can return to this location by calling return_location
71   def store_location
72     session[:return_to] = request.request_uri
73   end
74 
75   # move to the last store_location call or to the passed default one
76   def redirect_back_or_default(default)
77     if session[:return_to].nil?
78       redirect_to default
79     else
80       redirect_to_url session[:return_to]
81       session[:return_to] = nil
82     end
83   end
84 
85 end

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

Valid XHTML 1.0! Valid CSS!