serverside 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGELOG +10 -0
  2. data/README +3 -3
  3. data/Rakefile +4 -4
  4. data/bin/serverside +4 -4
  5. data/doc/rdoc/classes/Daemon.html +4 -4
  6. data/doc/rdoc/classes/ServerSide.html +14 -74
  7. data/doc/rdoc/classes/ServerSide/Application.html +13 -13
  8. data/doc/rdoc/classes/ServerSide/{Connection.html → HTTP.html} +12 -18
  9. data/doc/rdoc/classes/ServerSide/HTTP/Connection.html +200 -0
  10. data/doc/rdoc/classes/ServerSide/{Connection → HTTP}/Const.html +6 -6
  11. data/doc/rdoc/classes/ServerSide/{Connection/Base.html → HTTP/Request.html} +213 -164
  12. data/doc/rdoc/classes/ServerSide/{Server.html → HTTP/Server.html} +22 -22
  13. data/doc/rdoc/classes/ServerSide/Router.html +496 -0
  14. data/doc/rdoc/classes/ServerSide/StaticFiles.html +31 -30
  15. data/doc/rdoc/classes/ServerSide/Template.html +12 -12
  16. data/doc/rdoc/created.rid +1 -1
  17. data/doc/rdoc/files/CHANGELOG.html +22 -4
  18. data/doc/rdoc/files/COPYING.html +1 -1
  19. data/doc/rdoc/files/README.html +4 -4
  20. data/doc/rdoc/files/lib/serverside/application_rb.html +1 -1
  21. data/doc/rdoc/files/lib/serverside/cluster_rb.html +1 -1
  22. data/doc/rdoc/files/lib/serverside/connection_rb.html +1 -1
  23. data/doc/rdoc/files/lib/serverside/core_ext_rb.html +1 -1
  24. data/doc/rdoc/files/lib/serverside/daemon_rb.html +1 -1
  25. data/doc/rdoc/files/lib/serverside/request_rb.html +101 -0
  26. data/doc/rdoc/files/lib/serverside/routing_rb.html +1 -1
  27. data/doc/rdoc/files/lib/serverside/server_rb.html +1 -1
  28. data/doc/rdoc/files/lib/serverside/static_rb.html +1 -1
  29. data/doc/rdoc/files/lib/serverside/template_rb.html +1 -1
  30. data/doc/rdoc/files/lib/serverside_rb.html +1 -1
  31. data/doc/rdoc/fr_class_index.html +6 -5
  32. data/doc/rdoc/fr_file_index.html +1 -0
  33. data/doc/rdoc/fr_method_index.html +31 -31
  34. data/lib/serverside/application.rb +1 -1
  35. data/lib/serverside/connection.rb +12 -141
  36. data/lib/serverside/request.rb +150 -0
  37. data/lib/serverside/routing.rb +117 -126
  38. data/lib/serverside/server.rb +13 -12
  39. data/lib/serverside/static.rb +1 -1
  40. data/test/functional/primitive_static_server_test.rb +3 -3
  41. data/test/functional/routing_server.rb +1 -1
  42. data/test/functional/routing_server_test.rb +1 -1
  43. data/test/functional/static_profile.rb +1 -1
  44. data/test/functional/static_server_test.rb +2 -2
  45. data/test/unit/connection_test.rb +30 -224
  46. data/test/unit/request_test.rb +248 -0
  47. data/test/unit/routing_test.rb +4 -4
  48. data/test/unit/server_test.rb +10 -8
  49. data/test/unit/static_test.rb +1 -1
  50. metadata +61 -56
  51. data/doc/rdoc/classes/ServerSide/Connection/Router.html +0 -493
@@ -1,493 +0,0 @@
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: ServerSide::Connection::Router</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">ServerSide::Connection::Router</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/serverside/routing_rb.html">
59
- lib/serverside/routing.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="Base.html">
69
- Base
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
- The <a href="Router.html">Router</a> class defines a kind of connection
86
- that can route requests to different handlers based on rules that can be
87
- specified either by lambdas or by hashes that contain variable names
88
- corresponding to patterns.
89
- </p>
90
- <p>
91
- The simplest form of a routing rule specifies a path pattern:
92
- </p>
93
- <pre>
94
- ServerSide.route('/static') {serve_static('.'/@path)}
95
- </pre>
96
- <p>
97
- But you can also check for other attributes of the request:
98
- </p>
99
- <pre>
100
- ServerSide.route(:path =&gt; '/static', :host =&gt; '^:subdomain\.mydomain') {
101
- serve_static(@parameters[:subdomain]/@path)
102
- }
103
- </pre>
104
- <p>
105
- It also possible to pass a lambda as a rule:
106
- </p>
107
- <pre>
108
- ServerSide.route(lambda {@headers['Agent'] =~ /Moz/}) {serve_static('moz'/@path)}
109
- </pre>
110
- <p>
111
- Routing rules are evaluated in backwards, so the rules should be ordered
112
- from the general to the specific.
113
- </p>
114
-
115
- </div>
116
-
117
-
118
- </div>
119
-
120
- <div id="method-list">
121
- <h3 class="section-bar">Methods</h3>
122
-
123
- <div class="name-list">
124
- <a href="#M000046">cache_constant</a>&nbsp;&nbsp;
125
- <a href="#M000042">compile_rules</a>&nbsp;&nbsp;
126
- <a href="#M000044">condition_part</a>&nbsp;&nbsp;
127
- <a href="#M000049">default_handler</a>&nbsp;&nbsp;
128
- <a href="#M000045">define_proc</a>&nbsp;&nbsp;
129
- <a href="#M000040">has_routes?</a>&nbsp;&nbsp;
130
- <a href="#M000041">route</a>&nbsp;&nbsp;
131
- <a href="#M000047">route_default</a>&nbsp;&nbsp;
132
- <a href="#M000043">rule_to_statement</a>&nbsp;&nbsp;
133
- <a href="#M000048">unhandled</a>&nbsp;&nbsp;
134
- </div>
135
- </div>
136
-
137
- </div>
138
-
139
-
140
- <!-- if includes -->
141
-
142
- <div id="section">
143
-
144
-
145
- <div id="constants-list">
146
- <h3 class="section-bar">Constants</h3>
147
-
148
- <div class="name-list">
149
- <table summary="Constants">
150
- <tr class="top-aligned-row context-row">
151
- <td class="context-item-name">ParamRegexp</td>
152
- <td>=</td>
153
- <td class="context-item-value">/(?::([a-z]+))/</td>
154
- <td width="3em">&nbsp;</td>
155
- <td class="context-item-desc">
156
- Pattern for finding parameters inside patterns. Parameters are parts of the
157
- pattern, which the routing pre-processor turns into sub-regexp that are
158
- used to extract parameter values from the pattern.
159
-
160
- <p>
161
- For example, matching &#8217;/controller/show&#8217; against
162
- &#8217;/controller/:action&#8217; will give us @parameters[:action] #=&gt;
163
- &quot;show&quot;
164
- </p>
165
- </td>
166
- </tr>
167
- </table>
168
- </div>
169
- </div>
170
-
171
-
172
-
173
-
174
-
175
-
176
- <!-- if method_list -->
177
- <div id="methods">
178
- <h3 class="section-bar">Public Class methods</h3>
179
-
180
- <div id="method-M000046" class="method-detail">
181
- <a name="M000046"></a>
182
-
183
- <div class="method-heading">
184
- <a href="#M000046" class="method-signature">
185
- <span class="method-name">cache_constant</span><span class="method-args">(value)</span>
186
- </a>
187
- </div>
188
-
189
- <div class="method-description">
190
- <p>
191
- Converts a value into a local constant and freezes it. Returns the
192
- constant&#8217;s tag name
193
- </p>
194
- <p><a class="source-toggle" href="#"
195
- onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
196
- <div class="method-source-code" id="M000046-source">
197
- <pre>
198
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 111</span>
199
- 111: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache_constant</span>(<span class="ruby-identifier">value</span>)
200
- 112: <span class="ruby-identifier">tag</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">const_tag</span>
201
- 113: <span class="ruby-identifier">class_eval</span> <span class="ruby-node">&quot;#{tag} = #{value.inspect}.freeze&quot;</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
202
- 114: <span class="ruby-identifier">tag</span>
203
- 115: <span class="ruby-keyword kw">end</span>
204
- </pre>
205
- </div>
206
- </div>
207
- </div>
208
-
209
- <div id="method-M000042" class="method-detail">
210
- <a name="M000042"></a>
211
-
212
- <div class="method-heading">
213
- <a href="#M000042" class="method-signature">
214
- <span class="method-name">compile_rules</span><span class="method-args">()</span>
215
- </a>
216
- </div>
217
-
218
- <div class="method-description">
219
- <p>
220
- Compiles all rules into a respond method that is invoked when a request is
221
- received.
222
- </p>
223
- <p><a class="source-toggle" href="#"
224
- onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
225
- <div class="method-source-code" id="M000042-source">
226
- <pre>
227
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 46</span>
228
- 46: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">compile_rules</span>
229
- 47: <span class="ruby-ivar">@@rules</span> <span class="ruby-operator">||=</span> []
230
- 48: <span class="ruby-identifier">code</span> = <span class="ruby-ivar">@@rules</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value str">'lambda {'</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">r</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">rule_to_statement</span>(<span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">r</span>[<span class="ruby-value">1</span>])}
231
- 49: <span class="ruby-identifier">code</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">'default_handler}'</span>
232
- 50: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">:respond</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">eval</span>(<span class="ruby-identifier">code</span>))
233
- 51: <span class="ruby-keyword kw">end</span>
234
- </pre>
235
- </div>
236
- </div>
237
- </div>
238
-
239
- <div id="method-M000044" class="method-detail">
240
- <a name="M000044"></a>
241
-
242
- <div class="method-heading">
243
- <a href="#M000044" class="method-signature">
244
- <span class="method-name">condition_part</span><span class="method-args">(key, value)</span>
245
- </a>
246
- </div>
247
-
248
- <div class="method-description">
249
- <p>
250
- Returns the condition part for the key and value specified. The key is the
251
- name of an instance variable and the value is a pattern to match against.
252
- If the pattern contains parameters (for example, /controller/:action,) the
253
- method creates a lambda for extracting the parameter values.
254
- </p>
255
- <p><a class="source-toggle" href="#"
256
- onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
257
- <div class="method-source-code" id="M000044-source">
258
- <pre>
259
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 83</span>
260
- 83: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">condition_part</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
261
- 84: <span class="ruby-identifier">p_parse</span>, <span class="ruby-identifier">p_count</span> = <span class="ruby-value str">''</span>, <span class="ruby-value">0</span>
262
- 85: <span class="ruby-keyword kw">while</span> (<span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">value</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">value</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">ParamRegexp</span>)
263
- 86: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">dup</span>
264
- 87: <span class="ruby-identifier">p_name</span> = <span class="ruby-identifier">$1</span>
265
- 88: <span class="ruby-identifier">p_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
266
- 89: <span class="ruby-identifier">value</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-constant">ParamRegexp</span>, <span class="ruby-value str">'(.+)'</span>)
267
- 90: <span class="ruby-identifier">p_parse</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;@parameters[:#{p_name}] = $#{p_count}\n&quot;</span>
268
- 91: <span class="ruby-keyword kw">end</span>
269
- 92: <span class="ruby-identifier">cond</span> = <span class="ruby-node">&quot;(@#{key} =~ #{cache_constant(Regexp.new(value))})&quot;</span>
270
- 93: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">p_count</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
271
- 94: <span class="ruby-identifier">cond</span>
272
- 95: <span class="ruby-keyword kw">else</span>
273
- 96: <span class="ruby-identifier">tag</span> = <span class="ruby-identifier">define_proc</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">eval</span>(
274
- 97: <span class="ruby-node">&quot;lambda {if #{cond}\n#{p_parse}true\nelse\nfalse\nend}&quot;</span>))
275
- 98: <span class="ruby-node">&quot;(#{tag})&quot;</span>
276
- 99: <span class="ruby-keyword kw">end</span>
277
- 100: <span class="ruby-keyword kw">end</span>
278
- </pre>
279
- </div>
280
- </div>
281
- </div>
282
-
283
- <div id="method-M000045" class="method-detail">
284
- <a name="M000045"></a>
285
-
286
- <div class="method-heading">
287
- <a href="#M000045" class="method-signature">
288
- <span class="method-name">define_proc</span><span class="method-args">(&amp;block)</span>
289
- </a>
290
- </div>
291
-
292
- <div class="method-description">
293
- <p>
294
- Converts a proc into a method, returning the method&#8217;s name (as a
295
- symbol)
296
- </p>
297
- <p><a class="source-toggle" href="#"
298
- onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
299
- <div class="method-source-code" id="M000045-source">
300
- <pre>
301
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 103</span>
302
- 103: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">define_proc</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
303
- 104: <span class="ruby-identifier">tag</span> = <span class="ruby-identifier">block</span>.<span class="ruby-identifier">proc_tag</span>
304
- 105: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">tag</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">instance_methods</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">tag</span>)
305
- 106: <span class="ruby-identifier">tag</span>.<span class="ruby-identifier">to_sym</span>
306
- 107: <span class="ruby-keyword kw">end</span>
307
- </pre>
308
- </div>
309
- </div>
310
- </div>
311
-
312
- <div id="method-M000040" class="method-detail">
313
- <a name="M000040"></a>
314
-
315
- <div class="method-heading">
316
- <a href="#M000040" class="method-signature">
317
- <span class="method-name">has_routes?</span><span class="method-args">()</span>
318
- </a>
319
- </div>
320
-
321
- <div class="method-description">
322
- <p>
323
- Returns true if routes were defined.
324
- </p>
325
- <p><a class="source-toggle" href="#"
326
- onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
327
- <div class="method-source-code" id="M000040-source">
328
- <pre>
329
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 25</span>
330
- 25: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">has_routes?</span>
331
- 26: <span class="ruby-ivar">@@rules</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@@rules</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">false</span>
332
- 27: <span class="ruby-keyword kw">end</span>
333
- </pre>
334
- </div>
335
- </div>
336
- </div>
337
-
338
- <div id="method-M000041" class="method-detail">
339
- <a name="M000041"></a>
340
-
341
- <div class="method-heading">
342
- <a href="#M000041" class="method-signature">
343
- <span class="method-name">route</span><span class="method-args">(rule, &amp;block)</span>
344
- </a>
345
- </div>
346
-
347
- <div class="method-description">
348
- <p>
349
- Adds a routing rule. The normalized rule is a hash containing keys (acting
350
- as instance variable names) with patterns as values. If the rule is not a
351
- hash, it is normalized into a pattern checked against the request path.
352
- Pattern values can also be arrays, any member of which is checked as a
353
- pattern. The rule can also be a <a href="../../Proc.html">Proc</a> or
354
- lambda which is run with the connection object&#8217;s binding. A contrived
355
- example:
356
- </p>
357
- <pre>
358
- ServerSide.route(lambda{path = 'mypage'}) {serve_static('mypage.html')}
359
- </pre>
360
- <p><a class="source-toggle" href="#"
361
- onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
362
- <div class="method-source-code" id="M000041-source">
363
- <pre>
364
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 37</span>
365
- 37: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">route</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
366
- 38: <span class="ruby-ivar">@@rules</span> <span class="ruby-operator">||=</span> []
367
- 39: <span class="ruby-identifier">rule</span> = {<span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">rule</span>} <span class="ruby-keyword kw">unless</span> (<span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">rule</span>) <span class="ruby-operator">||</span> (<span class="ruby-constant">Proc</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">rule</span>)
368
- 40: <span class="ruby-ivar">@@rules</span>.<span class="ruby-identifier">unshift</span> [<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">block</span>]
369
- 41: <span class="ruby-identifier">compile_rules</span>
370
- 42: <span class="ruby-keyword kw">end</span>
371
- </pre>
372
- </div>
373
- </div>
374
- </div>
375
-
376
- <div id="method-M000047" class="method-detail">
377
- <a name="M000047"></a>
378
-
379
- <div class="method-heading">
380
- <a href="#M000047" class="method-signature">
381
- <span class="method-name">route_default</span><span class="method-args">(&amp;block)</span>
382
- </a>
383
- </div>
384
-
385
- <div class="method-description">
386
- <p>
387
- Sets the default handler for incoming requests.
388
- </p>
389
- <p><a class="source-toggle" href="#"
390
- onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
391
- <div class="method-source-code" id="M000047-source">
392
- <pre>
393
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 118</span>
394
- 118: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">route_default</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
395
- 119: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">:default_handler</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
396
- 120: <span class="ruby-identifier">compile_rules</span>
397
- 121: <span class="ruby-keyword kw">end</span>
398
- </pre>
399
- </div>
400
- </div>
401
- </div>
402
-
403
- <div id="method-M000043" class="method-detail">
404
- <a name="M000043"></a>
405
-
406
- <div class="method-heading">
407
- <a href="#M000043" class="method-signature">
408
- <span class="method-name">rule_to_statement</span><span class="method-args">(rule, block)</span>
409
- </a>
410
- </div>
411
-
412
- <div class="method-description">
413
- <p>
414
- Converts a rule into an if statement. All keys in the rule are matched
415
- against their respective values.
416
- </p>
417
- <p><a class="source-toggle" href="#"
418
- onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
419
- <div class="method-source-code" id="M000043-source">
420
- <pre>
421
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 55</span>
422
- 55: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rule_to_statement</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">block</span>)
423
- 56: <span class="ruby-identifier">proc_tag</span> = <span class="ruby-identifier">define_proc</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
424
- 57: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Proc</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">rule</span>
425
- 58: <span class="ruby-identifier">cond</span> = <span class="ruby-identifier">define_proc</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">rule</span>).<span class="ruby-identifier">to_s</span>
426
- 59: <span class="ruby-keyword kw">else</span>
427
- 60: <span class="ruby-identifier">cond</span> = <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">kv</span><span class="ruby-operator">|</span>
428
- 61: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">kv</span>[<span class="ruby-value">1</span>]
429
- 62: <span class="ruby-value str">'('</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">kv</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">condition_part</span>(<span class="ruby-identifier">kv</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">v</span>)}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'||'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">')'</span>
430
- 63: <span class="ruby-keyword kw">else</span>
431
- 64: <span class="ruby-identifier">condition_part</span>(<span class="ruby-identifier">kv</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">kv</span>[<span class="ruby-value">1</span>])
432
- 65: <span class="ruby-keyword kw">end</span>
433
- 66: }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'&amp;&amp;'</span>)
434
- 67: <span class="ruby-keyword kw">end</span>
435
- 68: <span class="ruby-node">&quot;return #{proc_tag} if #{cond}\n&quot;</span>
436
- 69: <span class="ruby-keyword kw">end</span>
437
- </pre>
438
- </div>
439
- </div>
440
- </div>
441
-
442
- <h3 class="section-bar">Public Instance methods</h3>
443
-
444
- <div id="method-M000049" class="method-detail">
445
- <a name="M000049"></a>
446
-
447
- <div class="method-heading">
448
- <span class="method-name">default_handler</span><span class="method-args">()</span>
449
- </div>
450
-
451
- <div class="method-description">
452
- <p>
453
- Alias for <a href="Router.html#M000048">unhandled</a>
454
- </p>
455
- </div>
456
- </div>
457
-
458
- <div id="method-M000048" class="method-detail">
459
- <a name="M000048"></a>
460
-
461
- <div class="method-heading">
462
- <a href="#M000048" class="method-signature">
463
- <span class="method-name">unhandled</span><span class="method-args">()</span>
464
- </a>
465
- </div>
466
-
467
- <div class="method-description">
468
- <p><a class="source-toggle" href="#"
469
- onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
470
- <div class="method-source-code" id="M000048-source">
471
- <pre>
472
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 123</span>
473
- 123: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unhandled</span>
474
- 124: <span class="ruby-identifier">send_response</span>(<span class="ruby-value">403</span>, <span class="ruby-value str">'text'</span>, <span class="ruby-value str">'No handler found.'</span>)
475
- 125: <span class="ruby-keyword kw">end</span>
476
- </pre>
477
- </div>
478
- </div>
479
- </div>
480
-
481
-
482
- </div>
483
-
484
-
485
- </div>
486
-
487
-
488
- <div id="validator-badges">
489
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
490
- </div>
491
-
492
- </body>
493
- </html>