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.
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 # Ramaze support simple routing using string, regex and lambda based routers.
5 # Route are stored in a dictionary, which supports hash-like access but
6 # preserves order, so routes are evaluated in the order they are added.
7 #
8 # String routers are the simplest way to route in Ramaze. One path is
9 # translated into another:
10 #
11 # Ramaze::Route[ '/foo' ] = '/bar'
12 # '/foo' => '/bar'
13 #
14 # Regex routers allow matching against paths using regex. Matches within
15 # your regex using () are substituted in the new path using printf-like
16 # syntax.
17 #
18 # Ramaze::Route[ %r!^/(\d+)\.te?xt$! ] = "/text/%d"
19 # '/123.txt' => '/text/123'
20 # '/789.text' => '/text/789'
21 #
22 # For more complex routing, lambda routers can be used. Lambda routers are
23 # passed in the current path and request object, and must return either a new
24 # path string, or nil.
25 #
26 # Ramaze::Route[ 'name of route' ] = lambda{ |path, request|
27 # '/bar' if path == '/foo' and request[:bar] == '1'
28 # }
29 # '/foo' => '/foo'
30 # '/foo?bar=1' => '/bar'
31 #
32 # Lambda routers can also use this alternative syntax:
33 #
34 # Ramaze::Route('name of route') do |path, request|
35 # '/bar' if path == '/foo' and request[:bar] == '1'
36 # end
37
38 module Ramaze
39 class Route
40 trait :routes => Dictionary.new
41
42 class << self
43 def [](key)
44 trait[:routes][key]
45 end
46
47 def []=(key, value)
48 trait[:routes][key] = value
49 end
50 end
51 end
52
53 def self.Route(name, &block)
54 Route[name] = block
55 end
56 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.