C0 code coverage information

Generated on Sat Feb 02 17:44:25 +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/dispatcher/directory.rb 116 94
95.7% 
94.7% 
  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   module Dispatcher
  6 
  7     # Generates a directory listing, see Ramaze::Controller::Directory for more
  8     # information and how to create your own directory listing page
  9     class Directory
 10       class << self
 11 
 12         # Entry point from Dispatcher::filter.
 13         # Just a forwarder to build_listing, automatticly exiting if there is
 14         # an error (defined by returning false in build_listing)
 15         def process(path)
 16           if Global.list_directories
 17             response = build_listing(path)
 18             Response.current.build(*response) if response
 19           end
 20         end
 21 
 22         # Makes a request for http://yourserver/dirlist/path and returns the
 23         # result. Due to this method, you can overwrite the action and create your
 24         # own page. See Ramaze::Controller::Directory for more.
 25         def build_listing(path)
 26           dir = ::File.expand_path(Global.public_root/::File.expand_path(path, '/'))
 27 
 28           if ::File.directory?(dir)
 29             Inform.debug("Serving directory listing: #{dir}")
 30 
 31             status = Ramaze::STATUS_CODE['OK']
 32             header = {'Content-Type' => "text/html"}
 33             body = list_for(dir)
 34             [body, status, header]
 35           end
 36         end
 37 
 38         def list_for(path)
 39           root = ::File.expand_path(Global.public_root)
 40           display = path.gsub(/^#{Regexp.escape(root)}\/?/, '/')
 41           wrapper =
 42 %(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 43 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 44 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 45   <head>
 46     <title>Directory listing of #{display}</title>
 47 
 48     <style type="text/css"> /*<![CDATA[*/ a, a:active {text-decoration: none; color: blue;} a:visited {color: #48468F;} a:hover, a:focus {text-decoration: underline; color: red;} body {background-color: #F5F5F5;} h2 {margin-bottom: 12px;} table {margin-left: 12px;} th, td { font-family: "Courier New", Courier, monospace; font-size: 10pt; text-align: left;} th { font-weight: bold; padding-right: 14px; padding-bottom: 3px;} td {padding-right: 14px;} td.s, th.s {text-align: right;} div.list { background-color: white; border-top: 1px solid #646464; border-bottom: 1px solid #646464; padding-top: 10px; padding-bottom: 14px;} div.foot { font-family: "Courier New", Courier, monospace; font-size: 10pt; color: #787878; padding-top: 4px;} /*]]>*/ </style>
 49   </head>
 50   <body>
 51     <h2>Directory listing of #{display}</h2>
 52     <div class="list">
 53       <table summary="Directory Listing" cellpadding="0" cellspacing="0">
 54         <thead>
 55           <tr>
 56             <th class="n">Name</th>
 57             <th class="m">Last Modified</th>
 58             <th class="s">Size</th>
 59             <th class="t">Type</th>
 60           </tr>
 61         </thead>
 62         <tbody>
 63           <tr>
 64             <td class="n"><a href="#{display/'..'}/">Parent Directory</a>/</td>
 65             <td class="m">&nbsp;</td>
 66             <td class="s">- &nbsp;</td>
 67             <td class="t">Directory</td>
 68           </tr>
 69           %s
 70           %s
 71         </tbody>
 72       </table>
 73     </div>
 74     <div class="foot">%s</div>
 75   </body>
 76 </html>
 77 )
 78 
 79           dirs, files = Dir[path/'*'].partition{|file| ::File.directory?(file) }
 80           dir_body, file_body = [], []
 81 
 82           dirs.sort.each do |dir|
 83             basename = ::File.basename(dir)
 84             dir_body << %[<tr>
 85             <td class="n"><a href="#{display/basename}">#{basename}/</a></td>
 86             <td class="m">&nbsp;</td>
 87             <td class="s">- &nbsp;</td>
 88             <td class="t">Directory</td>
 89           </tr>]
 90           end
 91 
 92           time_format = "%Y-%b-%d %H:%M:%S"
 93           files.sort.each do |file|
 94             basename = ::File.basename(file)
 95             time = ::File.mtime(file).strftime(time_format)
 96             size = ::File.size(file).filesize_format
 97             mime = Tool::MIME.type_for(file)
 98             file_body << %[<tr>
 99             <td class="n"><a href="#{display/basename}">#{basename}</a></td>
100             <td class="m">#{time}</td>
101             <td class="s">#{size}</td>
102             <td class="t">#{mime}</td>
103           </tr>]
104           end
105 
106           version = "ramaze/#{Ramaze::VERSION}"
107           wrapper % [
108             dir_body. join("\n          "),
109             file_body.join("\n          "),
110             version
111           ]
112         end
113       end
114     end
115   end
116 end

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

Valid XHTML 1.0! Valid CSS!