merb 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/README +68 -58
  2. data/Rakefile +7 -6
  3. data/TODO +18 -0
  4. data/bin/merb +2 -2
  5. data/doc/rdoc/classes/Hash.html +148 -0
  6. data/doc/rdoc/classes/Merb/Config.html +161 -0
  7. data/doc/rdoc/classes/Merb/Controller.html +488 -0
  8. data/doc/rdoc/classes/Merb/RouteMatcher.html +354 -0
  9. data/doc/rdoc/classes/Merb/Server.html +288 -0
  10. data/doc/rdoc/classes/Merb.html +143 -0
  11. data/doc/rdoc/classes/MerbHandler.html +404 -0
  12. data/doc/rdoc/classes/MerbHash.html +457 -0
  13. data/doc/rdoc/classes/Noroutefound.html +172 -0
  14. data/doc/rdoc/classes/Object.html +149 -0
  15. data/doc/rdoc/classes/String.html +200 -0
  16. data/doc/rdoc/classes/Symbol.html +172 -0
  17. data/doc/rdoc/created.rid +1 -0
  18. data/doc/rdoc/files/LICENSE.html +129 -0
  19. data/doc/rdoc/files/README.html +330 -0
  20. data/doc/rdoc/files/TODO.html +154 -0
  21. data/doc/rdoc/files/lib/merb/merb_controller_rb.html +101 -0
  22. data/doc/rdoc/files/lib/merb/merb_daemon_rb.html +113 -0
  23. data/doc/rdoc/files/lib/merb/merb_handler_rb.html +108 -0
  24. data/doc/rdoc/files/lib/merb/merb_router_rb.html +101 -0
  25. data/doc/rdoc/files/lib/merb/merb_utils_rb.html +101 -0
  26. data/doc/rdoc/files/lib/merb/noroutefound_rb.html +101 -0
  27. data/doc/rdoc/files/lib/merb_config_rb.html +101 -0
  28. data/doc/rdoc/files/lib/merb_rb.html +112 -0
  29. data/doc/rdoc/fr_class_index.html +38 -0
  30. data/doc/rdoc/fr_file_index.html +38 -0
  31. data/doc/rdoc/fr_method_index.html +78 -0
  32. data/doc/rdoc/index.html +24 -0
  33. data/doc/rdoc/rdoc-style.css +208 -0
  34. data/examples/sample_app/{app → dist/app}/controllers/posts.rb +8 -8
  35. data/examples/sample_app/{app → dist/app}/controllers/test.rb +8 -5
  36. data/examples/sample_app/{app → dist/app}/controllers/upload.rb +13 -5
  37. data/examples/sample_app/dist/app/models/post.rb +13 -0
  38. data/examples/sample_app/dist/app/views/layout/application.rhtml +6 -0
  39. data/examples/sample_app/dist/app/views/layout/foo.rhtml +6 -0
  40. data/examples/sample_app/dist/app/views/layout/posts.rhtml +6 -0
  41. data/examples/sample_app/{app → dist/app}/views/posts/list.rhtml +1 -7
  42. data/examples/sample_app/{app → dist/app}/views/posts/new.rhtml +1 -7
  43. data/examples/sample_app/{app → dist/app}/views/posts/show.rhtml +1 -8
  44. data/examples/sample_app/dist/app/views/test/foo.rhtml +2 -0
  45. data/examples/sample_app/{app → dist/app}/views/test/hello.rhtml +1 -8
  46. data/examples/sample_app/{app → dist/app}/views/upload/start.rhtml +0 -8
  47. data/examples/sample_app/{app → dist/app}/views/upload/upload.rhtml +0 -0
  48. data/examples/sample_app/{conf → dist/conf}/merb_init.rb +5 -2
  49. data/examples/sample_app/{conf → dist/conf}/router.rb +6 -8
  50. data/examples/sample_app/test/test_helper.rb +1 -0
  51. data/examples/skeleton/dist/conf/merb_init.rb +21 -0
  52. data/examples/skeleton/dist/conf/router.rb +23 -0
  53. data/examples/skeleton/test/test_helper.rb +1 -0
  54. data/lib/merb/merb_controller.rb +54 -15
  55. data/lib/merb/merb_daemon.rb +35 -20
  56. data/lib/merb/merb_handler.rb +49 -38
  57. data/lib/merb/merb_router.rb +25 -28
  58. data/lib/merb/merb_utils.rb +98 -9
  59. data/{examples/sample_app/app/controllers → lib/merb}/noroutefound.rb +1 -1
  60. data/lib/merb.rb +4 -4
  61. data/lib/merb_config.rb +1 -1
  62. data/test/unit/route_matcher_test.rb +12 -31
  63. metadata +109 -28
  64. data/examples/sample_app/app/models/post.rb +0 -2
  65. data/examples/sample_app/app/views/test/foo.rhtml +0 -6
@@ -0,0 +1,354 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Merb::RouteMatcher</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Merb::RouteMatcher</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/merb/merb_router_rb.html">
59
+ lib/merb/merb_router.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="../Object.html">
69
+ Object
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ <a href="RouteMatcher.html">Merb::RouteMatcher</a> is the request routing
86
+ mapper for the merb framework. You can define placeholder parts of the url
87
+ with the :symbol notation. so r.add &#8217;/foo/:bar/baz/:id&#8217;, :class
88
+ =&gt; &#8216;Bar&#8217;, :method =&gt; &#8216;foo&#8217; will match against
89
+ a request to /foo/123/baz/456. It will then use the class Bar as your merb
90
+ controller and call the foo method on it. the foo method will recieve a
91
+ hash with {:bar =&gt; &#8216;123&#8217;, :id =&gt; &#8216;456&#8217;} as
92
+ the content. So the :placeholders sections of your <a
93
+ href="RouteMatcher.html#M000030">routes</a> become a hash of arguments to
94
+ your controller methods. This route maps the default /controller/action and
95
+ /controller/action/id urls: r.add &#8217;/:class/:method/:id&#8216;
96
+ </p>
97
+
98
+ </div>
99
+
100
+
101
+ </div>
102
+
103
+ <div id="method-list">
104
+ <h3 class="section-bar">Methods</h3>
105
+
106
+ <div class="name-list">
107
+ <a href="#M000032">add</a>&nbsp;&nbsp;
108
+ <a href="#M000034">compile</a>&nbsp;&nbsp;
109
+ <a href="#M000033">compile_router</a>&nbsp;&nbsp;
110
+ <a href="#M000031">compiled_statement</a>&nbsp;&nbsp;
111
+ <a href="#M000029">new</a>&nbsp;&nbsp;
112
+ <a href="#M000028">prepare</a>&nbsp;&nbsp;
113
+ <a href="#M000030">routes</a>&nbsp;&nbsp;
114
+ </div>
115
+ </div>
116
+
117
+ </div>
118
+
119
+
120
+ <!-- if includes -->
121
+
122
+ <div id="section">
123
+
124
+
125
+
126
+
127
+
128
+ <div id="attribute-list">
129
+ <h3 class="section-bar">Attributes</h3>
130
+
131
+ <div class="name-list">
132
+ <table>
133
+ <tr class="top-aligned-row context-row">
134
+ <td class="context-item-name">sections</td>
135
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
136
+ <td class="context-item-desc"></td>
137
+ </tr>
138
+ </table>
139
+ </div>
140
+ </div>
141
+
142
+
143
+
144
+ <!-- if method_list -->
145
+ <div id="methods">
146
+ <h3 class="section-bar">Public Class methods</h3>
147
+
148
+ <div id="method-M000032" class="method-detail">
149
+ <a name="M000032"></a>
150
+
151
+ <div class="method-heading">
152
+ <a href="#M000032" class="method-signature">
153
+ <span class="method-name">add</span><span class="method-args">(*route)</span>
154
+ </a>
155
+ </div>
156
+
157
+ <div class="method-description">
158
+ <p><a class="source-toggle" href="#"
159
+ onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
160
+ <div class="method-source-code" id="M000032-source">
161
+ <pre>
162
+ <span class="ruby-comment cmt"># File lib/merb/merb_router.rb, line 37</span>
163
+ 37: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">add</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">route</span>)
164
+ 38: <span class="ruby-ivar">@@routes</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>], (<span class="ruby-identifier">route</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">||</span> {})]
165
+ 39: <span class="ruby-keyword kw">end</span>
166
+ </pre>
167
+ </div>
168
+ </div>
169
+ </div>
170
+
171
+ <div id="method-M000034" class="method-detail">
172
+ <a name="M000034"></a>
173
+
174
+ <div class="method-heading">
175
+ <a href="#M000034" class="method-signature">
176
+ <span class="method-name">compile</span><span class="method-args">(route)</span>
177
+ </a>
178
+ </div>
179
+
180
+ <div class="method-description">
181
+ <p><a class="source-toggle" href="#"
182
+ onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
183
+ <div class="method-source-code" id="M000034-source">
184
+ <pre>
185
+ <span class="ruby-comment cmt"># File lib/merb/merb_router.rb, line 49</span>
186
+ 49: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">compile</span>(<span class="ruby-identifier">route</span>)
187
+ 50: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>]
188
+ 51: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'/:controller/:action/:id'</span>
189
+ 52: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">' when /\A\/([^\/;.,?]+)(?:\/?\Z|\/([^\/;.,?]+)\/?)(?:\/?\Z|\/([^\/;.,?]+)\/?)\Z/
190
+ 53: @sections[:controller] = $1
191
+ 54: @sections[:action] = $2 || \'index\'
192
+ 55: @sections[:id] = $3 || nil
193
+ 56: return @sections'</span><span class="ruby-operator">&lt;&lt;</span><span class="ruby-value str">&quot;\n&quot;</span>
194
+ 57: <span class="ruby-keyword kw">end</span>
195
+ 58: <span class="ruby-identifier">code</span>, <span class="ruby-identifier">count</span> = <span class="ruby-value str">''</span>, <span class="ruby-value">0</span>
196
+ 59: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">=~</span> <span class="ruby-ivar">@@section_regexp</span>
197
+ 60: <span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">dup</span>
198
+ 61: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">$1</span>
199
+ 62: (<span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(\*+)(\w+)/</span>) <span class="ruby-operator">?</span> (<span class="ruby-identifier">flag</span> = <span class="ruby-keyword kw">true</span>; <span class="ruby-identifier">name</span> = <span class="ruby-identifier">$2</span>) <span class="ruby-operator">:</span> (<span class="ruby-identifier">flag</span> = <span class="ruby-keyword kw">false</span>)
200
+ 63: <span class="ruby-identifier">count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
201
+ 64: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flag</span>
202
+ 65: <span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">sub!</span>(<span class="ruby-ivar">@@section_regexp</span>, <span class="ruby-value str">&quot;([^;.,?]+)&quot;</span>)
203
+ 66: <span class="ruby-keyword kw">else</span>
204
+ 67: <span class="ruby-identifier">route</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">sub!</span>(<span class="ruby-ivar">@@section_regexp</span>, <span class="ruby-value str">&quot;([^\/;.,?]+)&quot;</span>)
205
+ 68: <span class="ruby-keyword kw">end</span>
206
+ 69: <span class="ruby-identifier">code</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; @sections[:#{name}] = $#{count}\n&quot;</span>
207
+ 70: <span class="ruby-keyword kw">end</span>
208
+ 71: <span class="ruby-identifier">condition</span> = <span class="ruby-node">&quot; when Regexp.new('#{route[0]}')&quot;</span>
209
+ 72: <span class="ruby-identifier">statement</span> = <span class="ruby-node">&quot;#{condition}\n#{code}&quot;</span>
210
+ 73: <span class="ruby-identifier">statement</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; return #{route[1].inspect}.merge(@sections)\n&quot;</span>
211
+ 74: <span class="ruby-identifier">statement</span>
212
+ 75: <span class="ruby-keyword kw">end</span>
213
+ </pre>
214
+ </div>
215
+ </div>
216
+ </div>
217
+
218
+ <div id="method-M000033" class="method-detail">
219
+ <a name="M000033"></a>
220
+
221
+ <div class="method-heading">
222
+ <a href="#M000033" class="method-signature">
223
+ <span class="method-name">compile_router</span><span class="method-args">()</span>
224
+ </a>
225
+ </div>
226
+
227
+ <div class="method-description">
228
+ <p><a class="source-toggle" href="#"
229
+ onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
230
+ <div class="method-source-code" id="M000033-source">
231
+ <pre>
232
+ <span class="ruby-comment cmt"># File lib/merb/merb_router.rb, line 41</span>
233
+ 41: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">compile_router</span>
234
+ 42: <span class="ruby-identifier">router_lambda</span> = <span class="ruby-ivar">@@routes</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value str">&quot;lambda{|path| \n case path\n&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span>,<span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
235
+ 43: <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">r</span>)
236
+ 44: } <span class="ruby-operator">&lt;&lt;</span><span class="ruby-value str">&quot; else\n return {:controller=&gt;'Noroutefound', :action=&gt;'noroute'}\n end\n}&quot;</span>
237
+ 45: <span class="ruby-ivar">@@compiled_statement</span> = <span class="ruby-identifier">router_lambda</span>
238
+ 46: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">:route_request</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">eval</span>(<span class="ruby-identifier">router_lambda</span>))
239
+ 47: <span class="ruby-keyword kw">end</span>
240
+ </pre>
241
+ </div>
242
+ </div>
243
+ </div>
244
+
245
+ <div id="method-M000029" class="method-detail">
246
+ <a name="M000029"></a>
247
+
248
+ <div class="method-heading">
249
+ <a href="#M000029" class="method-signature">
250
+ <span class="method-name">new</span><span class="method-args">()</span>
251
+ </a>
252
+ </div>
253
+
254
+ <div class="method-description">
255
+ <p><a class="source-toggle" href="#"
256
+ onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
257
+ <div class="method-source-code" id="M000029-source">
258
+ <pre>
259
+ <span class="ruby-comment cmt"># File lib/merb/merb_router.rb, line 25</span>
260
+ 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
261
+ 26: <span class="ruby-ivar">@sections</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
262
+ 27: <span class="ruby-keyword kw">end</span>
263
+ </pre>
264
+ </div>
265
+ </div>
266
+ </div>
267
+
268
+ <div id="method-M000028" class="method-detail">
269
+ <a name="M000028"></a>
270
+
271
+ <div class="method-heading">
272
+ <a href="#M000028" class="method-signature">
273
+ <span class="method-name">prepare</span><span class="method-args">() {|self| ...}</span>
274
+ </a>
275
+ </div>
276
+
277
+ <div class="method-description">
278
+ <p><a class="source-toggle" href="#"
279
+ onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
280
+ <div class="method-source-code" id="M000028-source">
281
+ <pre>
282
+ <span class="ruby-comment cmt"># File lib/merb/merb_router.rb, line 18</span>
283
+ 18: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">prepare</span>
284
+ 19: <span class="ruby-ivar">@@routes</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
285
+ 20: <span class="ruby-ivar">@@compiled_statement</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>
286
+ 21: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
287
+ 22: <span class="ruby-identifier">compile_router</span>
288
+ 23: <span class="ruby-keyword kw">end</span>
289
+ </pre>
290
+ </div>
291
+ </div>
292
+ </div>
293
+
294
+ <h3 class="section-bar">Public Instance methods</h3>
295
+
296
+ <div id="method-M000031" class="method-detail">
297
+ <a name="M000031"></a>
298
+
299
+ <div class="method-heading">
300
+ <a href="#M000031" class="method-signature">
301
+ <span class="method-name">compiled_statement</span><span class="method-args">()</span>
302
+ </a>
303
+ </div>
304
+
305
+ <div class="method-description">
306
+ <p><a class="source-toggle" href="#"
307
+ onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
308
+ <div class="method-source-code" id="M000031-source">
309
+ <pre>
310
+ <span class="ruby-comment cmt"># File lib/merb/merb_router.rb, line 33</span>
311
+ 33: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compiled_statement</span>
312
+ 34: <span class="ruby-ivar">@@compiled_statement</span>
313
+ 35: <span class="ruby-keyword kw">end</span>
314
+ </pre>
315
+ </div>
316
+ </div>
317
+ </div>
318
+
319
+ <div id="method-M000030" class="method-detail">
320
+ <a name="M000030"></a>
321
+
322
+ <div class="method-heading">
323
+ <a href="#M000030" class="method-signature">
324
+ <span class="method-name">routes</span><span class="method-args">()</span>
325
+ </a>
326
+ </div>
327
+
328
+ <div class="method-description">
329
+ <p><a class="source-toggle" href="#"
330
+ onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
331
+ <div class="method-source-code" id="M000030-source">
332
+ <pre>
333
+ <span class="ruby-comment cmt"># File lib/merb/merb_router.rb, line 29</span>
334
+ 29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">routes</span>
335
+ 30: <span class="ruby-ivar">@@routes</span>
336
+ 31: <span class="ruby-keyword kw">end</span>
337
+ </pre>
338
+ </div>
339
+ </div>
340
+ </div>
341
+
342
+
343
+ </div>
344
+
345
+
346
+ </div>
347
+
348
+
349
+ <div id="validator-badges">
350
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
351
+ </div>
352
+
353
+ </body>
354
+ </html>