merb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/doc/rdoc/classes/Merb.html +128 -0
- data/doc/rdoc/classes/Merb/Config.html +159 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/LICENSE.html +129 -0
- data/doc/rdoc/files/README.html +297 -0
- data/doc/rdoc/files/lib/merb_config_rb.html +101 -0
- data/doc/rdoc/files/lib/merb_rb.html +113 -0
- data/doc/rdoc/files/server_rb.html +122 -0
- data/doc/rdoc/fr_class_index.html +28 -0
- data/doc/rdoc/fr_file_index.html +31 -0
- data/doc/rdoc/fr_method_index.html +27 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/sample_app/app/controllers/noroutefound.rb +4 -0
- data/examples/sample_app/app/controllers/posts.rb +27 -0
- data/examples/sample_app/app/models/post.rb +2 -0
- data/examples/sample_app/app/views/posts/list.rhtml +13 -0
- data/examples/sample_app/app/views/posts/new.rhtml +36 -0
- data/examples/sample_app/app/views/posts/show.rhtml +12 -0
- data/examples/sample_app/conf/merb_init.rb +12 -1
- data/examples/sample_app/conf/router.rb +8 -2
- data/lib/merb.rb +1 -1
- data/lib/merb/merb_controller.rb +1 -3
- data/lib/merb/merb_handler.rb +43 -13
- data/test/unit/route_matcher_test.rb +16 -11
- metadata +27 -2
data/Rakefile
CHANGED
@@ -0,0 +1,128 @@
|
|
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>Module: Merb</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>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">Merb</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/merb_rb.html">
|
59
|
+
lib/merb.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../files/lib/merb_config_rb.html">
|
63
|
+
lib/merb_config.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
|
69
|
+
</table>
|
70
|
+
</div>
|
71
|
+
<!-- banner header -->
|
72
|
+
|
73
|
+
<div id="bodyContent">
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<div id="contextContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
<!-- if includes -->
|
88
|
+
|
89
|
+
<div id="section">
|
90
|
+
|
91
|
+
<div id="class-list">
|
92
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
93
|
+
|
94
|
+
Class <a href="Merb/Config.html" class="link">Merb::Config</a><br />
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<div id="constants-list">
|
99
|
+
<h3 class="section-bar">Constants</h3>
|
100
|
+
|
101
|
+
<div class="name-list">
|
102
|
+
<table summary="Constants">
|
103
|
+
<tr class="top-aligned-row context-row">
|
104
|
+
<td class="context-item-name">VERSION</td>
|
105
|
+
<td>=</td>
|
106
|
+
<td class="context-item-value">'0.0.2' unless defined?VERSION</td>
|
107
|
+
</tr>
|
108
|
+
</table>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<!-- if method_list -->
|
118
|
+
|
119
|
+
|
120
|
+
</div>
|
121
|
+
|
122
|
+
|
123
|
+
<div id="validator-badges">
|
124
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
</body>
|
128
|
+
</html>
|
@@ -0,0 +1,159 @@
|
|
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::Config</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::Config</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/merb_config_rb.html">
|
59
|
+
lib/merb_config.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
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000001">setup</a>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
<!-- if includes -->
|
97
|
+
|
98
|
+
<div id="section">
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if method_list -->
|
108
|
+
<div id="methods">
|
109
|
+
<h3 class="section-bar">Public Class methods</h3>
|
110
|
+
|
111
|
+
<div id="method-M000001" class="method-detail">
|
112
|
+
<a name="M000001"></a>
|
113
|
+
|
114
|
+
<div class="method-heading">
|
115
|
+
<a href="#M000001" class="method-signature">
|
116
|
+
<span class="method-name">setup</span><span class="method-args">()</span>
|
117
|
+
</a>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div class="method-description">
|
121
|
+
<p><a class="source-toggle" href="#"
|
122
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
123
|
+
<div class="method-source-code" id="M000001-source">
|
124
|
+
<pre>
|
125
|
+
<span class="ruby-comment cmt"># File lib/merb_config.rb, line 5</span>
|
126
|
+
5: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">setup</span>
|
127
|
+
6: <span class="ruby-identifier">defaults</span> = {
|
128
|
+
7: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"0.0.0.0"</span>,
|
129
|
+
8: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"4000"</span>,
|
130
|
+
9: <span class="ruby-identifier">:allow_reloading</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>,
|
131
|
+
10: <span class="ruby-identifier">:merb_root</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
|
132
|
+
11: }
|
133
|
+
12:
|
134
|
+
13: <span class="ruby-keyword kw">begin</span>
|
135
|
+
14: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">IO</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">"#{defaults[:merb_root]}/conf/merb.yml"</span>)).<span class="ruby-identifier">result</span>))
|
136
|
+
15: <span class="ruby-keyword kw">rescue</span>
|
137
|
+
16: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>
|
138
|
+
17: <span class="ruby-keyword kw">end</span>
|
139
|
+
18:
|
140
|
+
19: <span class="ruby-identifier">options</span>
|
141
|
+
20: <span class="ruby-keyword kw">end</span>
|
142
|
+
</pre>
|
143
|
+
</div>
|
144
|
+
</div>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
</div>
|
149
|
+
|
150
|
+
|
151
|
+
</div>
|
152
|
+
|
153
|
+
|
154
|
+
<div id="validator-badges">
|
155
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
</body>
|
159
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
Mon Oct 16 20:09:10 -0700 2006
|
@@ -0,0 +1,129 @@
|
|
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>File: LICENSE</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="fileHeader">
|
50
|
+
<h1>LICENSE</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>LICENSE
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Sat Oct 14 14:18:28 -0700 2006</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
Copyright (c) 2006 Ezra Zygmuntowicz
|
74
|
+
</p>
|
75
|
+
<p>
|
76
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
77
|
+
copy of this software and associated documentation files (the
|
78
|
+
"Software"), to deal in the Software without restriction,
|
79
|
+
including without limitation the rights to use, copy, modify, merge,
|
80
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
81
|
+
permit persons to whom the Software is furnished to do so, subject to the
|
82
|
+
following conditions:
|
83
|
+
</p>
|
84
|
+
<p>
|
85
|
+
The above copyright notice and this permission notice shall be included in
|
86
|
+
all copies or substantial portions of the Software.
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
90
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
91
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
92
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
93
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
94
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
95
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
96
|
+
</p>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if includes -->
|
108
|
+
|
109
|
+
<div id="section">
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<!-- if method_list -->
|
119
|
+
|
120
|
+
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
<div id="validator-badges">
|
125
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
</body>
|
129
|
+
</html>
|
@@ -0,0 +1,297 @@
|
|
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>File: README</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="fileHeader">
|
50
|
+
<h1>README</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>README
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Sun Oct 15 16:21:25 -0700 2006</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
<html><body> <pre> Copyright (c) 2006 Ezra Zygmuntowicz
|
74
|
+
</p>
|
75
|
+
<p>
|
76
|
+
<a href="../classes/Merb.html">Merb</a>. Mongrel+Erb
|
77
|
+
</p>
|
78
|
+
<p>
|
79
|
+
Little bitty lightweight ruby app server. FOr when you really need
|
80
|
+
performance for simple dynamic pages.
|
81
|
+
</p>
|
82
|
+
<p>
|
83
|
+
**Sample APP included**
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
Unpack the gem and grab the sample app
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
$ gem unpack merb
|
90
|
+
</p>
|
91
|
+
<p>
|
92
|
+
cd merb* cd examples/smaple_app
|
93
|
+
</p>
|
94
|
+
<p>
|
95
|
+
$ merb start -t
|
96
|
+
</p>
|
97
|
+
<p>
|
98
|
+
then the sample app will be running on port 4000 in the foreground. you can
|
99
|
+
go to a few urls:
|
100
|
+
</p>
|
101
|
+
<p>
|
102
|
+
<a
|
103
|
+
href="http://localhost:4000/upload/start">localhost:4000/upload/start</a>
|
104
|
+
</p>
|
105
|
+
<p>
|
106
|
+
<a
|
107
|
+
href="http://localhost:4000/foo/123/baz/12234345">localhost:4000/foo/123/baz/12234345</a>
|
108
|
+
</p>
|
109
|
+
<p>
|
110
|
+
*<b>FEATURES</b>* 1. Mongrel handler built in that parses incoming requests
|
111
|
+
including multipart uploads and post as well as ?query=strings. Puts the
|
112
|
+
params into @params and the cookies into @cookies when it instantiates your
|
113
|
+
controller class.
|
114
|
+
</p>
|
115
|
+
<ol>
|
116
|
+
<li>New RouteMatcher and route compiler. Reads your route definition and
|
117
|
+
compiles
|
118
|
+
|
119
|
+
</li>
|
120
|
+
</ol>
|
121
|
+
<p>
|
122
|
+
a method on the fly that will match the request path against each route and
|
123
|
+
do the right thing. So the following routes:
|
124
|
+
</p>
|
125
|
+
<p>
|
126
|
+
Merb::RouteMatcher.prepare do |r|
|
127
|
+
</p>
|
128
|
+
<pre>
|
129
|
+
r.add '/foo/:bar/baz/:id', :class => 'Test', :method => 'foo'
|
130
|
+
r.add '/hey/:there/you/:guys', :class => 'Test', :method => 'hello'
|
131
|
+
r.add '/:class/:method/:id', {}
|
132
|
+
r.add '/:class/:method', {}
|
133
|
+
r.add '.*', {:class => 'NoRouteFound', :method => 'noroute'}
|
134
|
+
</pre>
|
135
|
+
<p>
|
136
|
+
end
|
137
|
+
</p>
|
138
|
+
<p>
|
139
|
+
Will be compiled and defined as a method with this lambda as the body:
|
140
|
+
</p>
|
141
|
+
<p>
|
142
|
+
lambda{|path|
|
143
|
+
</p>
|
144
|
+
<pre>
|
145
|
+
if Regexp.new('/foo/(.+)/baz/(.+)') =~ path
|
146
|
+
@sections[:bar] = $1
|
147
|
+
@sections[:id] = $2
|
148
|
+
return {:class=>"Test", :method=>"foo"}.merge(@sections)
|
149
|
+
end
|
150
|
+
|
151
|
+
if Regexp.new('/hey/(.+)/you/(.+)') =~ path
|
152
|
+
@sections[:there] = $1
|
153
|
+
@sections[:guys] = $2
|
154
|
+
return {:class=>"Test", :method=>"hello"}.merge(@sections)
|
155
|
+
end
|
156
|
+
|
157
|
+
if Regexp.new('/(.+)/(.+)/(.+)') =~ path
|
158
|
+
@sections[:class] = $1
|
159
|
+
@sections[:method] = $2
|
160
|
+
@sections[:id] = $3
|
161
|
+
return {}.merge(@sections)
|
162
|
+
end
|
163
|
+
|
164
|
+
if Regexp.new('/(.+)/(.+)') =~ path
|
165
|
+
@sections[:class] = $1
|
166
|
+
@sections[:method] = $2
|
167
|
+
return {}.merge(@sections)
|
168
|
+
end
|
169
|
+
|
170
|
+
if Regexp.new('.*') =~ path
|
171
|
+
return {:class=>"NoRouteFound", :method=>"noroute"}.merge(@sections)
|
172
|
+
end
|
173
|
+
|
174
|
+
return default_route
|
175
|
+
</pre>
|
176
|
+
<p>
|
177
|
+
}
|
178
|
+
</p>
|
179
|
+
<ol>
|
180
|
+
<li>Simple controller classes with built in render method and template handling
|
181
|
+
|
182
|
+
</li>
|
183
|
+
</ol>
|
184
|
+
<p>
|
185
|
+
with instance vars available in the views automatically.
|
186
|
+
</p>
|
187
|
+
<p>
|
188
|
+
class Test < Merb::Controller
|
189
|
+
</p>
|
190
|
+
<pre>
|
191
|
+
template_dir :test
|
192
|
+
|
193
|
+
def hello(args)
|
194
|
+
# args is a hash of the remaining templated
|
195
|
+
# parameters from the url matched in routing.
|
196
|
+
# @params and @cookies are avaialable here. string
|
197
|
+
# keys and not symbols just yet.
|
198
|
+
# Assign the parameter to an instance variable
|
199
|
+
@name = args[:name]
|
200
|
+
render
|
201
|
+
end
|
202
|
+
</pre>
|
203
|
+
<p>
|
204
|
+
end
|
205
|
+
</p>
|
206
|
+
<p>
|
207
|
+
<html>
|
208
|
+
</p>
|
209
|
+
<pre>
|
210
|
+
<head>
|
211
|
+
<title>Hello, <%= @name %></title>
|
212
|
+
</head>
|
213
|
+
<body>
|
214
|
+
<h1><%= @params.inspect %></h1>
|
215
|
+
<h1><%= @cookies.inspect %></h1>
|
216
|
+
<% 5.times do %>
|
217
|
+
<h1>Hello, <%= @name %>!</h1>
|
218
|
+
<% end %>
|
219
|
+
</body>
|
220
|
+
</pre>
|
221
|
+
<p>
|
222
|
+
</html>
|
223
|
+
</p>
|
224
|
+
<ol>
|
225
|
+
<li>the server. right now you add your routes in
|
226
|
+
|
227
|
+
</li>
|
228
|
+
</ol>
|
229
|
+
<p>
|
230
|
+
the appdir/conf/router.rb file. So by default it runs on port 4000
|
231
|
+
</p>
|
232
|
+
<p>
|
233
|
+
$ cd /path/to/your/merb/app $ merb start
|
234
|
+
</p>
|
235
|
+
<ol>
|
236
|
+
<li>File uploads. This is the thing that <a
|
237
|
+
href="../classes/Merb.html">Merb</a> was written for. Rails doesn‘t
|
238
|
+
allow
|
239
|
+
|
240
|
+
</li>
|
241
|
+
</ol>
|
242
|
+
<p>
|
243
|
+
multiple concurrent file uploads at once without blocking an entire rails
|
244
|
+
backend for each file upload. <a href="../classes/Merb.html">Merb</a>
|
245
|
+
allows multiple file uploads at once. Start the server and browse to <a
|
246
|
+
href="http://localhost:4000/upload/start">localhost:4000/upload/start</a>
|
247
|
+
and you will get a file upload form. There is a very simple upload
|
248
|
+
controller example that handles this upload. When a file is uploaded with
|
249
|
+
<a href="../classes/Merb.html">Merb</a>, it gets put in a Tempfile. So you
|
250
|
+
just want to copy it to the right place on the filesystem.
|
251
|
+
</p>
|
252
|
+
<p>
|
253
|
+
def upload(args)
|
254
|
+
</p>
|
255
|
+
<pre>
|
256
|
+
puts @params[:file].inspect
|
257
|
+
|
258
|
+
FileUtils.mv @params[:file][:tempfile].path, MERB_ROOT+"/uploads/#{@params[:file][:filename]}"
|
259
|
+
|
260
|
+
render
|
261
|
+
</pre>
|
262
|
+
<p>
|
263
|
+
end </pre> </body> </html>
|
264
|
+
</p>
|
265
|
+
|
266
|
+
</div>
|
267
|
+
|
268
|
+
|
269
|
+
</div>
|
270
|
+
|
271
|
+
|
272
|
+
</div>
|
273
|
+
|
274
|
+
|
275
|
+
<!-- if includes -->
|
276
|
+
|
277
|
+
<div id="section">
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
<!-- if method_list -->
|
287
|
+
|
288
|
+
|
289
|
+
</div>
|
290
|
+
|
291
|
+
|
292
|
+
<div id="validator-badges">
|
293
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
294
|
+
</div>
|
295
|
+
|
296
|
+
</body>
|
297
|
+
</html>
|