GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Explain what Merb::Router does and what routes compilation is.
Tue May 13 11:27:37 -0700 2008
commit  0b34508ccc8fe963bddb0635b9e16f363d6a4d12
tree    696f959218a903f729646d2d6518eaea356c30bc
parent  47483086a6e1dddf678597cb2111e999d8d72373
...
3
4
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7
8
9
10
11
 
12
13
14
15
16
 
17
18
19
...
141
142
143
144
 
145
146
...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
25
26
27
28
29
 
30
31
32
33
...
155
156
157
 
158
159
160
0
@@ -3,17 +3,31 @@ require 'merb-core/dispatch/router/behavior'
0
 require 'merb-core/dispatch/router/route'
0
 require 'merb-core/controller/mixins/responder'
0
 module Merb
0
+ # Router stores route definitions and finds first
0
+ # that matches incoming request URL.
0
+ #
0
+ # Then information from route is used by dispatcher to
0
+ # call action on the controller.
0
+ #
0
+ # ==== Routes compilation.
0
+ #
0
+ # Most interesting method of Router (and heart of
0
+ # route matching machinery) is match method generated
0
+ # on fly from routes definitions. It is called routes
0
+ # compilation. Generated match method body contains
0
+ # one if/elsif statement that picks first matching route
0
+ # definition and sets values to named parameters of the route.
0
   class Router
0
     SEGMENT_REGEXP = /(:([a-z_][a-z0-9_]*|:))/
0
     SEGMENT_REGEXP_WITH_BRACKETS = /(:[a-z_]+)(\[(\d+)\])?/
0
     JUST_BRACKETS = /\[(\d+)\]/
0
     PARENTHETICAL_SEGMENT_STRING = "([^\/.,;?]+)".freeze
0
-
0
+
0
     @@named_routes = {}
0
     @@routes = []
0
     @@compiler_mutex = Mutex.new
0
     cattr_accessor :routes, :named_routes
0
-
0
+
0
     class << self
0
 
0
       # Appends the generated routes to the current routes.
0
@@ -141,6 +155,6 @@ module Merb
0
         url
0
       end
0
     end # self
0
-
0
+
0
   end
0
 end

Comments

    No one has commented yet.