merb 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +68 -58
- data/Rakefile +7 -6
- data/TODO +18 -0
- data/bin/merb +2 -2
- data/doc/rdoc/classes/Hash.html +148 -0
- data/doc/rdoc/classes/Merb/Config.html +161 -0
- data/doc/rdoc/classes/Merb/Controller.html +488 -0
- data/doc/rdoc/classes/Merb/RouteMatcher.html +354 -0
- data/doc/rdoc/classes/Merb/Server.html +288 -0
- data/doc/rdoc/classes/Merb.html +143 -0
- data/doc/rdoc/classes/MerbHandler.html +404 -0
- data/doc/rdoc/classes/MerbHash.html +457 -0
- data/doc/rdoc/classes/Noroutefound.html +172 -0
- data/doc/rdoc/classes/Object.html +149 -0
- data/doc/rdoc/classes/String.html +200 -0
- data/doc/rdoc/classes/Symbol.html +172 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/LICENSE.html +129 -0
- data/doc/rdoc/files/README.html +330 -0
- data/doc/rdoc/files/TODO.html +154 -0
- data/doc/rdoc/files/lib/merb/merb_controller_rb.html +101 -0
- data/doc/rdoc/files/lib/merb/merb_daemon_rb.html +113 -0
- data/doc/rdoc/files/lib/merb/merb_handler_rb.html +108 -0
- data/doc/rdoc/files/lib/merb/merb_router_rb.html +101 -0
- data/doc/rdoc/files/lib/merb/merb_utils_rb.html +101 -0
- data/doc/rdoc/files/lib/merb/noroutefound_rb.html +101 -0
- data/doc/rdoc/files/lib/merb_config_rb.html +101 -0
- data/doc/rdoc/files/lib/merb_rb.html +112 -0
- data/doc/rdoc/fr_class_index.html +38 -0
- data/doc/rdoc/fr_file_index.html +38 -0
- data/doc/rdoc/fr_method_index.html +78 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/sample_app/{app → dist/app}/controllers/posts.rb +8 -8
- data/examples/sample_app/{app → dist/app}/controllers/test.rb +8 -5
- data/examples/sample_app/{app → dist/app}/controllers/upload.rb +13 -5
- data/examples/sample_app/dist/app/models/post.rb +13 -0
- data/examples/sample_app/dist/app/views/layout/application.rhtml +6 -0
- data/examples/sample_app/dist/app/views/layout/foo.rhtml +6 -0
- data/examples/sample_app/dist/app/views/layout/posts.rhtml +6 -0
- data/examples/sample_app/{app → dist/app}/views/posts/list.rhtml +1 -7
- data/examples/sample_app/{app → dist/app}/views/posts/new.rhtml +1 -7
- data/examples/sample_app/{app → dist/app}/views/posts/show.rhtml +1 -8
- data/examples/sample_app/dist/app/views/test/foo.rhtml +2 -0
- data/examples/sample_app/{app → dist/app}/views/test/hello.rhtml +1 -8
- data/examples/sample_app/{app → dist/app}/views/upload/start.rhtml +0 -8
- data/examples/sample_app/{app → dist/app}/views/upload/upload.rhtml +0 -0
- data/examples/sample_app/{conf → dist/conf}/merb_init.rb +5 -2
- data/examples/sample_app/{conf → dist/conf}/router.rb +6 -8
- data/examples/sample_app/test/test_helper.rb +1 -0
- data/examples/skeleton/dist/conf/merb_init.rb +21 -0
- data/examples/skeleton/dist/conf/router.rb +23 -0
- data/examples/skeleton/test/test_helper.rb +1 -0
- data/lib/merb/merb_controller.rb +54 -15
- data/lib/merb/merb_daemon.rb +35 -20
- data/lib/merb/merb_handler.rb +49 -38
- data/lib/merb/merb_router.rb +25 -28
- data/lib/merb/merb_utils.rb +98 -9
- data/{examples/sample_app/app/controllers → lib/merb}/noroutefound.rb +1 -1
- data/lib/merb.rb +4 -4
- data/lib/merb_config.rb +1 -1
- data/test/unit/route_matcher_test.rb +12 -31
- metadata +109 -28
- data/examples/sample_app/app/models/post.rb +0 -2
- data/examples/sample_app/app/views/test/foo.rhtml +0 -6
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
3
|
+
<!DOCTYPE html
|
4
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
5
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
<!--
|
8
|
+
|
9
|
+
Methods
|
10
|
+
|
11
|
+
-->
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
13
|
+
<head>
|
14
|
+
<title>Methods</title>
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
16
|
+
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
|
17
|
+
<base target="docwin" />
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="index">
|
21
|
+
<h1 class="section-bar">Methods</h1>
|
22
|
+
<div id="index-entries">
|
23
|
+
<a href="classes/MerbHash.html#M000011">[]= (MerbHash)</a><br />
|
24
|
+
<a href="classes/Merb/RouteMatcher.html#M000032">add (Merb::RouteMatcher)</a><br />
|
25
|
+
<a href="classes/String.html#M000027">camel_case (String)</a><br />
|
26
|
+
<a href="classes/Merb/RouteMatcher.html#M000034">compile (Merb::RouteMatcher)</a><br />
|
27
|
+
<a href="classes/Merb/RouteMatcher.html#M000033">compile_router (Merb::RouteMatcher)</a><br />
|
28
|
+
<a href="classes/Merb/RouteMatcher.html#M000031">compiled_statement (Merb::RouteMatcher)</a><br />
|
29
|
+
<a href="classes/Merb/Server.html#M000052">config (Merb::Server)</a><br />
|
30
|
+
<a href="classes/MerbHash.html#M000020">convert_key (MerbHash)</a><br />
|
31
|
+
<a href="classes/MerbHash.html#M000021">convert_value (MerbHash)</a><br />
|
32
|
+
<a href="classes/Merb/Controller.html#M000039">cookies (Merb::Controller)</a><br />
|
33
|
+
<a href="classes/Merb/Controller.html#M000045">current_method_name (Merb::Controller)</a><br />
|
34
|
+
<a href="classes/MerbHash.html#M000010">default (MerbHash)</a><br />
|
35
|
+
<a href="classes/MerbHash.html#M000018">delete (MerbHash)</a><br />
|
36
|
+
<a href="classes/MerbHash.html#M000016">dup (MerbHash)</a><br />
|
37
|
+
<a href="classes/Merb/Controller.html#M000042">escape (Merb::Controller)</a><br />
|
38
|
+
<a href="classes/MerbHandler.html#M000007">exception (MerbHandler)</a><br />
|
39
|
+
<a href="classes/Merb/Server.html#M000051">exit (Merb::Server)</a><br />
|
40
|
+
<a href="classes/MerbHash.html#M000014">fetch (MerbHash)</a><br />
|
41
|
+
<a href="classes/MerbHandler.html#M000005">handle (MerbHandler)</a><br />
|
42
|
+
<a href="classes/Merb/Controller.html#M000040">headers (Merb::Controller)</a><br />
|
43
|
+
<a href="classes/String.html#M000025">import (String)</a><br />
|
44
|
+
<a href="classes/MerbHandler.html#M000006">instantiate_controller (MerbHandler)</a><br />
|
45
|
+
<a href="classes/MerbHash.html#M000013">key? (MerbHash)</a><br />
|
46
|
+
<a href="classes/Merb/Controller.html#M000046">layout (Merb::Controller)</a><br />
|
47
|
+
<a href="classes/Merb/Server.html#M000049">merb_config (Merb::Server)</a><br />
|
48
|
+
<a href="classes/MerbHash.html#M000017">merge (MerbHash)</a><br />
|
49
|
+
<a href="classes/MerbHash.html#M000019">method_missing (MerbHash)</a><br />
|
50
|
+
<a href="classes/Noroutefound.html#M000022">method_missing (Noroutefound)</a><br />
|
51
|
+
<a href="classes/Merb/RouteMatcher.html#M000029">new (Merb::RouteMatcher)</a><br />
|
52
|
+
<a href="classes/MerbHandler.html#M000003">new (MerbHandler)</a><br />
|
53
|
+
<a href="classes/MerbHash.html#M000009">new (MerbHash)</a><br />
|
54
|
+
<a href="classes/Merb/Controller.html#M000038">params (Merb::Controller)</a><br />
|
55
|
+
<a href="classes/Merb/RouteMatcher.html#M000028">prepare (Merb::RouteMatcher)</a><br />
|
56
|
+
<a href="classes/MerbHandler.html#M000004">process (MerbHandler)</a><br />
|
57
|
+
<a href="classes/Merb/Controller.html#M000041">query_parse (Merb::Controller)</a><br />
|
58
|
+
<a href="classes/Merb/Controller.html#M000036">redirect (Merb::Controller)</a><br />
|
59
|
+
<a href="classes/Merb/Controller.html#M000048">render (Merb::Controller)</a><br />
|
60
|
+
<a href="classes/Merb/Controller.html#M000047">render_no_layout (Merb::Controller)</a><br />
|
61
|
+
<a href="classes/Object.html#M000024">returning (Object)</a><br />
|
62
|
+
<a href="classes/Merb/RouteMatcher.html#M000030">routes (Merb::RouteMatcher)</a><br />
|
63
|
+
<a href="classes/Merb/Server.html#M000050">run (Merb::Server)</a><br />
|
64
|
+
<a href="classes/Merb/Controller.html#M000037">send_file (Merb::Controller)</a><br />
|
65
|
+
<a href="classes/Merb/Config.html#M000035">setup (Merb::Config)</a><br />
|
66
|
+
<a href="classes/String.html#M000026">snake_case (String)</a><br />
|
67
|
+
<a href="classes/Merb/Controller.html#M000044">template_dir (Merb::Controller)</a><br />
|
68
|
+
<a href="classes/Symbol.html#M000002">to_proc (Symbol)</a><br />
|
69
|
+
<a href="classes/Noroutefound.html#M000023">to_s (Noroutefound)</a><br />
|
70
|
+
<a href="classes/Symbol.html#M000001">to_s (Symbol)</a><br />
|
71
|
+
<a href="classes/Merb/Controller.html#M000043">unescape (Merb::Controller)</a><br />
|
72
|
+
<a href="classes/MerbHash.html#M000012">update (MerbHash)</a><br />
|
73
|
+
<a href="classes/MerbHash.html#M000015">values_at (MerbHash)</a><br />
|
74
|
+
<a href="classes/Hash.html#M000008">with_indifferent_access (Hash)</a><br />
|
75
|
+
</div>
|
76
|
+
</div>
|
77
|
+
</body>
|
78
|
+
</html>
|
data/doc/rdoc/index.html
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
5
|
+
|
6
|
+
<!--
|
7
|
+
|
8
|
+
Merb Documentation
|
9
|
+
|
10
|
+
-->
|
11
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
12
|
+
<head>
|
13
|
+
<title>Merb Documentation</title>
|
14
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
15
|
+
</head>
|
16
|
+
<frameset rows="20%, 80%">
|
17
|
+
<frameset cols="25%,35%,45%">
|
18
|
+
<frame src="fr_file_index.html" title="Files" name="Files" />
|
19
|
+
<frame src="fr_class_index.html" name="Classes" />
|
20
|
+
<frame src="fr_method_index.html" name="Methods" />
|
21
|
+
</frameset>
|
22
|
+
<frame src="files/README.html" name="docwin" />
|
23
|
+
</frameset>
|
24
|
+
</html>
|
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|
@@ -1,22 +1,22 @@
|
|
1
1
|
|
2
2
|
class Posts < Merb::Controller
|
3
|
-
|
4
|
-
|
5
|
-
def new(args={})
|
3
|
+
|
4
|
+
def new
|
6
5
|
unless params.to_s.empty?
|
7
6
|
@post = Post.create( :title => params[:title], :body => params[:body])
|
8
|
-
|
7
|
+
redirect "/posts/show/#{@post.id}"
|
9
8
|
else
|
10
9
|
render
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
|
-
def show
|
15
|
-
@post = Post.find
|
13
|
+
def show
|
14
|
+
@post = Post.find params[:id]
|
15
|
+
layout 'foo'
|
16
16
|
render
|
17
17
|
end
|
18
18
|
|
19
|
-
def list
|
19
|
+
def list
|
20
20
|
@posts = Post.find :all
|
21
21
|
render
|
22
22
|
end
|
@@ -24,4 +24,4 @@ class Posts < Merb::Controller
|
|
24
24
|
def to_s
|
25
25
|
"<html><body>Post controller, no mathing action</body></html>"
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
@@ -1,16 +1,19 @@
|
|
1
1
|
|
2
2
|
class Test < Merb::Controller
|
3
|
-
template_dir :test
|
4
3
|
|
5
|
-
def hello
|
4
|
+
def hello
|
6
5
|
# Assign the parameter to an instance variable
|
7
|
-
@name =
|
6
|
+
@name = params[:id]
|
8
7
|
render
|
9
8
|
end
|
10
9
|
|
11
|
-
def
|
10
|
+
def glob
|
11
|
+
"<html><body><h2>#{params[:rest]}</h2></body></html>"
|
12
|
+
end
|
13
|
+
|
14
|
+
def foo
|
12
15
|
|
13
|
-
@args =
|
16
|
+
@args = params
|
14
17
|
render
|
15
18
|
end
|
16
19
|
|
@@ -1,20 +1,28 @@
|
|
1
1
|
class Upload < Merb::Controller
|
2
|
-
template_dir :upload
|
3
2
|
|
4
|
-
def start
|
3
|
+
def start
|
5
4
|
# Assign the parameter to an instance variable
|
6
|
-
@args =
|
5
|
+
@args = params
|
7
6
|
render
|
8
7
|
end
|
9
8
|
|
10
|
-
def
|
9
|
+
def index
|
10
|
+
@args = params
|
11
|
+
render 'start'
|
12
|
+
end
|
13
|
+
|
14
|
+
def upload
|
11
15
|
puts params[:file].inspect
|
12
16
|
|
13
|
-
FileUtils.mv params[:file][:tempfile].path, ::Merb::Server.config[:
|
17
|
+
FileUtils.mv params[:file][:tempfile].path, ::Merb::Server.config[:dist_root]+"/public/files/#{params[:file][:filename]}"
|
14
18
|
|
15
19
|
render
|
16
20
|
end
|
17
21
|
|
22
|
+
def file
|
23
|
+
send_file MERB_ROOT+'/public/files/'+params[:file]
|
24
|
+
end
|
25
|
+
|
18
26
|
def to_s
|
19
27
|
"<html><body>Upload controller, no mathing action</body></html>"
|
20
28
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Post < ActiveRecord::Base
|
2
|
+
end
|
3
|
+
|
4
|
+
=begin
|
5
|
+
CREATE TABLE `posts` (
|
6
|
+
`id` int(11) NOT NULL auto_increment,
|
7
|
+
`title` varchar(255),
|
8
|
+
`body` text,
|
9
|
+
`created_at` datetime default NULL,
|
10
|
+
`updated_at` datetime default NULL,
|
11
|
+
PRIMARY KEY (`id`)
|
12
|
+
) ENGINE=InnoDB
|
13
|
+
=end
|
File without changes
|
@@ -7,8 +7,11 @@ require 'active_record'
|
|
7
7
|
ActiveRecord::Base.establish_connection(
|
8
8
|
:adapter => 'mysql',
|
9
9
|
:username => 'root',
|
10
|
-
:password => '
|
10
|
+
:password => 'xxx',
|
11
11
|
:database => 'merb'
|
12
12
|
)
|
13
13
|
|
14
|
-
|
14
|
+
MERB_ROOT = Merb::Server.config[:merb_root]
|
15
|
+
DIST_ROOT = Merb::Server.config[:dist_root]
|
16
|
+
|
17
|
+
Dir[DIST_ROOT+"/app/models/*.rb"].each { |m| require m }
|
@@ -5,17 +5,15 @@
|
|
5
5
|
# use the class Bar as your merb controller and call the foo method on it.
|
6
6
|
# the foo method will recieve a hash with {:bar => '123', :id => '456'}
|
7
7
|
# as the content. So the :placeholders sections of your routes become
|
8
|
-
# a hash of arguments to your controller methods.
|
9
|
-
#
|
10
|
-
|
11
|
-
# r.add '/:class/:method/:id', {}
|
12
|
-
# r.add '/:class/:method', {}
|
8
|
+
# a hash of arguments to your controller methods.
|
9
|
+
# The default route is installed
|
10
|
+
|
13
11
|
|
14
12
|
puts "Compiling routes: \n"
|
15
13
|
Merb::RouteMatcher.prepare do |r|
|
16
|
-
r.add '/foo/:bar/baz/:id', :
|
17
|
-
r.add '/:
|
18
|
-
r.add '
|
14
|
+
r.add '/foo/:bar/baz/:id', :controller => 'Test', :action => 'foo'
|
15
|
+
r.add '/:controller/:action/:id'
|
16
|
+
r.add '/bar/:*rest', :controller => 'Test', :action => 'glob'
|
19
17
|
end
|
20
18
|
|
21
19
|
m = Merb::RouteMatcher.new
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'test/unit'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
puts "merb init called"
|
2
|
+
|
3
|
+
MERB_ROOT = Merb::Server.config[:merb_root]
|
4
|
+
DIST_ROOT = Merb::Server.config[:dist_root]
|
5
|
+
|
6
|
+
# add your own ruby code here for app initialization and load path stuff
|
7
|
+
|
8
|
+
# comment out this whole part if you dont use active_record
|
9
|
+
require 'active_record'
|
10
|
+
|
11
|
+
ActiveRecord::Base.establish_connection(
|
12
|
+
:adapter => 'mysql',
|
13
|
+
:username => 'root',
|
14
|
+
:password => 'xxxx',
|
15
|
+
:database => 'merb'
|
16
|
+
)
|
17
|
+
|
18
|
+
|
19
|
+
# leave this uncommented even without activerecord in case
|
20
|
+
# you want to have models that don't inherit from AR
|
21
|
+
Dir[DIST_ROOT+"/app/models/*.rb"].each { |m| require m }
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Merb::RouteMatcher is the request routing mapper for the merb framework.
|
2
|
+
# You can define placeholder parts of the url with the :symbol notation.
|
3
|
+
# so r.add '/foo/:bar/baz/:id', :class => 'Bar', :method => 'foo'
|
4
|
+
# will match against a request to /foo/123/baz/456. It will then
|
5
|
+
# use the class Bar as your merb controller and call the foo method on it.
|
6
|
+
# the foo method will recieve a hash with {:bar => '123', :id => '456'}
|
7
|
+
# as the content. So the :placeholders sections of your routes become
|
8
|
+
# a hash of arguments to your controller methods. This method maps
|
9
|
+
# the default /controller/action and /controller/action/id urls you will
|
10
|
+
# use. so leave r.add '/:controller/:action/:id' in near the bottom
|
11
|
+
# of your routes. They match in the order they are defined. You can also
|
12
|
+
# use a :* to glob up the rest of a pth and send it to a controller:
|
13
|
+
# r.add '/bar/:*rest', :controller => 'Test', :action => 'glob'
|
14
|
+
|
15
|
+
|
16
|
+
puts "Compiling routes: \n"
|
17
|
+
Merb::RouteMatcher.prepare do |r|
|
18
|
+
r.add '/foo/:bar/baz/:id', :controller => 'Test', :action => 'foo'
|
19
|
+
r.add '/:controller/:action/:id'
|
20
|
+
end
|
21
|
+
|
22
|
+
m = Merb::RouteMatcher.new
|
23
|
+
puts m.compiled_statement
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'test/unit'
|