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/file.rb 76 50
100.0% 
100.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 "time"
 5 require 'digest/md5'
 6 
 7 module Ramaze
 8   module Dispatcher
 9 
10     # First of the dispatchers, looks up the public path and serves the
11     # file if found.
12 
13     class File
14       # These names are checked for serving from public directory.
15       # They take priority over Actions which comes later in the FILTER
16       INDICES = %w[index.htm index.xhtml index.html index]
17 
18       class << self
19         include Trinity
20 
21         # Entry point from Dispatcher::filter.
22         # searches for the file and builds a response with status 200 if found.
23 
24         def process(path)
25           return unless file = open_file(path)
26           if file == :NotModified
27             return response.build([], STATUS_CODE['Not Modified'])
28           end
29           response.build(file, STATUS_CODE['OK'])
30         end
31 
32         # returns file-handle with the open file on success, setting the
33         # Content-Type as found in Tool::MIME
34 
35         def open_file(path)
36           file = resolve_path(path)
37 
38           if ::File.file?(file) or ::File.file?(file=file/'index')
39             response['Content-Type'] = Tool::MIME.type_for(file) unless ::File.extname(file).empty?
40             mtime = ::File.mtime(file)
41             response['Last-Modified'] = mtime.httpdate
42             response['ETag']= Digest::MD5.hexdigest(file+mtime.to_s).inspect
43             if modified_since = request.env['HTTP_IF_MODIFIED_SINCE']
44               return :NotModified unless Time.parse(modified_since) < mtime
45             elsif match = request.env['HTTP_IF_NONE_MATCH']
46               # Should be a unique string enclosed in ""
47               # To avoiding more file reading we use mtime and filepath
48               # we could throw in inode and size for more uniqueness
49               return :NotModified if response['ETag']==match
50             end
51             log(file)
52             ::File.open(file, 'rb')
53           end
54         end
55 
56         def resolve_path(path)
57           joined = ::File.join(Global.public_root, path)
58 
59           if ::File.directory?(joined)
60             Dir[joined/"{#{INDICES.join(',')}}"].first || joined
61           else
62             joined
63           end
64         end
65 
66         def log(file)
67           case file
68           when *Global.boring
69           else
70             Inform.debug("Serving static: #{file}")
71           end
72         end
73       end
74     end
75   end
76 end

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

Valid XHTML 1.0! Valid CSS!