C0 code coverage information

Generated on Sat Feb 02 17:44:27 +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/redirect.rb 70 31
88.6% 
74.2% 
 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   # RedirectHelper actually takes advantage of LinkHelper.link_raw to build the links
 7   # it redirects to.
 8   # It doesn't do much else than this:
 9   #     setting a status-code of 303 and a response['Location'] = link
10   # returning some nice text for visitors who insist on ignoring those hints :P
11   #
12   # Usage:
13   #   redirect Rs()
14   #   redirect R(MainController)
15   #   redirect R(MainController, :foo)
16   #   redirect 'foo/bar'
17   #   redirect 'foo/bar', :status => 301
18   #
19   # TODO:
20   #   - maybe some more options, like a delay
21   #
22 
23   module RedirectHelper
24 
25     private
26 
27     # render to the browser directly, ignoring any templates
28     def respond *args
29       response.build(*args)
30       throw :respond
31     end
32 
33     # Usage:
34     #   redirect Rs()
35     #   redirect R(MainController)
36     #   redirect R(MainController, :foo)
37     #   redirect 'foo/bar'
38     #   redirect 'foo/bar', :status => 301
39 
40     def redirect target, opts = {}
41       target = target.to_s
42 
43       unless target =~ %r!^https?://!
44         target[0,0] = '/' unless target =~ %r!^/!
45         if host = request.env['HTTP_HOST']
46           target[0,0] = "http://#{host}"
47         end
48       end
49 
50       raw_redirect(target, opts)
51     end
52 
53     def raw_redirect(target, opts = {})
54       target = target.to_s
55       header = {'Location' => target}
56       status = opts[:status] || STATUS_CODE["See Other"]
57       body = %{You are being redirected, please follow <a href="#{target}">this link to: #{target}</a>!}
58 
59       Inform.info("Redirect to '#{target}'")
60       throw(:redirect, [body, status, header])
61     end
62 
63     # redirect to the location the browser says it's coming from.
64 
65     def redirect_referer
66       redirect request.referer
67     end
68     alias redirect_referrer redirect_referer
69   end
70 end

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

Valid XHTML 1.0! Valid CSS!