merb 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +41 -2
- data/Rakefile +4 -2
- data/TODO +3 -3
- data/bin/merb +157 -3
- data/doc/rdoc/classes/Hash.html +4 -4
- data/doc/rdoc/classes/Merb.html +2 -12
- data/doc/rdoc/classes/Merb/Controller.html +347 -156
- data/doc/rdoc/classes/Merb/RouteMatcher.html +93 -59
- data/doc/rdoc/classes/MerbHandler.html +117 -107
- data/doc/rdoc/classes/MerbHash.html +64 -58
- data/doc/rdoc/classes/Noroutefound.html +16 -10
- data/doc/rdoc/classes/Object.html +5 -5
- data/doc/rdoc/classes/String.html +28 -16
- data/doc/rdoc/classes/Symbol.html +15 -8
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +56 -4
- data/doc/rdoc/files/TODO.html +4 -4
- data/doc/rdoc/files/lib/merb/merb_controller_rb.html +1 -1
- data/doc/rdoc/files/lib/merb/merb_handler_rb.html +1 -1
- data/doc/rdoc/files/lib/merb/merb_router_rb.html +1 -1
- data/doc/rdoc/files/lib/merb/merb_utils_rb.html +1 -1
- data/doc/rdoc/files/lib/merb_rb.html +30 -2
- data/doc/rdoc/files/lib/{merb_config_rb.html → merb_tasks_rb.html} +4 -4
- data/doc/rdoc/fr_class_index.html +0 -2
- data/doc/rdoc/fr_file_index.html +1 -3
- data/doc/rdoc/fr_method_index.html +21 -21
- data/examples/app_skeleton/Rakefile +81 -0
- data/examples/app_skeleton/dist/conf/merb_init.rb +15 -0
- data/examples/{skeleton → app_skeleton}/dist/conf/router.rb +5 -7
- data/examples/app_skeleton/scripts/merb_stop +5 -0
- data/examples/app_skeleton/scripts/new_migration +21 -0
- data/examples/{skeleton → app_skeleton}/test/test_helper.rb +0 -0
- data/examples/sample_app/Rakefile +81 -0
- data/examples/sample_app/dist/app/controllers/posts.rb +26 -10
- data/examples/sample_app/dist/app/models/comment.rb +3 -0
- data/examples/sample_app/dist/app/models/post.rb +2 -11
- data/examples/sample_app/dist/app/views/layout/application.rhtml +59 -4
- data/examples/sample_app/dist/app/views/posts/_comments.rhtml +11 -0
- data/examples/sample_app/dist/app/views/posts/comment.merbjs +1 -0
- data/examples/sample_app/dist/app/views/posts/list.rhtml +2 -4
- data/examples/sample_app/dist/app/views/posts/new.rhtml +2 -2
- data/examples/sample_app/dist/app/views/posts/show.rhtml +35 -3
- data/examples/sample_app/dist/conf/merb_init.rb +2 -4
- data/examples/sample_app/dist/conf/router.rb +3 -4
- data/examples/sample_app/dist/public/images/bg.jpg +0 -0
- data/examples/sample_app/dist/public/images/book.gif +0 -0
- data/examples/sample_app/dist/public/images/booksmall.gif +0 -0
- data/examples/sample_app/dist/public/images/greenright.jpg +0 -0
- data/examples/sample_app/dist/public/images/louiecon.gif +0 -0
- data/examples/sample_app/dist/public/images/menu.gif +0 -0
- data/examples/sample_app/dist/public/images/menuleft.gif +0 -0
- data/examples/sample_app/dist/public/images/menuright.gif +0 -0
- data/examples/sample_app/dist/public/images/mountain.jpg +0 -0
- data/examples/sample_app/dist/public/images/n3.jpg +0 -0
- data/examples/sample_app/dist/public/images/nautica.jpg +0 -0
- data/examples/sample_app/dist/public/javascripts/application.js +0 -0
- data/examples/sample_app/dist/public/javascripts/effects.js +975 -0
- data/examples/sample_app/dist/public/javascripts/prototype.js +2264 -0
- data/examples/sample_app/dist/public/stylesheets/merb.css +277 -0
- data/examples/sample_app/dist/schema/migrations/001_add_comments_to_posts.rb +22 -0
- data/examples/sample_app/dist/schema/schema.rb +22 -0
- data/examples/sample_app/log/merb.log +164394 -0
- data/examples/sample_app/script/merb_stop +9 -0
- data/examples/sample_app/script/new_migration +21 -0
- data/lib/merb.rb +7 -4
- data/lib/merb/merb_controller.rb +83 -4
- data/lib/merb/merb_handler.rb +20 -9
- data/lib/merb/merb_router.rb +18 -1
- data/lib/merb/merb_utils.rb +11 -1
- data/lib/merb_tasks.rb +7 -0
- data/lib/tasks/db.rake +53 -0
- metadata +67 -34
- data/doc/rdoc/classes/Merb/Config.html +0 -161
- data/doc/rdoc/classes/Merb/Server.html +0 -288
- data/doc/rdoc/files/lib/merb/merb_daemon_rb.html +0 -113
- data/doc/rdoc/files/lib/merb/noroutefound_rb.html +0 -101
- data/examples/sample_app/dist/app/views/layout/posts.rhtml +0 -6
- data/examples/skeleton/dist/conf/merb_init.rb +0 -21
- data/lib/merb/merb_daemon.rb +0 -91
- data/lib/merb/noroutefound.rb +0 -11
- data/lib/merb_config.rb +0 -21
data/doc/rdoc/files/TODO.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Mon Oct 30 18:55:04 -0800 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -76,13 +76,13 @@
|
|
76
76
|
<li>Irb Console *<b>DONE</b>*
|
77
77
|
|
78
78
|
</li>
|
79
|
-
<li>Migrations
|
79
|
+
<li>Migrations *<b>DONE</b>*
|
80
80
|
|
81
81
|
</li>
|
82
82
|
<li>Helpers
|
83
83
|
|
84
84
|
</li>
|
85
|
-
<li>config file
|
85
|
+
<li>config file *<b>DONE</b>*
|
86
86
|
|
87
87
|
</li>
|
88
88
|
<li>merg args and params *<b>DONE</b>*
|
@@ -103,7 +103,7 @@
|
|
103
103
|
<li>plugins support(rails plugins too?)
|
104
104
|
|
105
105
|
</li>
|
106
|
-
<li>Layouts
|
106
|
+
<li>Layouts *<b>DONE</b>*
|
107
107
|
|
108
108
|
</li>
|
109
109
|
<li>auto template_dir
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Mon Oct 30 17:31:53 -0800 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -77,7 +77,7 @@
|
|
77
77
|
mongrel
|
78
78
|
fileutils
|
79
79
|
erubis
|
80
|
-
|
80
|
+
logger
|
81
81
|
</div>
|
82
82
|
</div>
|
83
83
|
|
@@ -92,6 +92,34 @@
|
|
92
92
|
<div id="section">
|
93
93
|
|
94
94
|
|
95
|
+
<div id="constants-list">
|
96
|
+
<h3 class="section-bar">Constants</h3>
|
97
|
+
|
98
|
+
<div class="name-list">
|
99
|
+
<table summary="Constants">
|
100
|
+
<tr class="top-aligned-row context-row">
|
101
|
+
<td class="context-item-name">MERB_FRAMEWORK_ROOT</td>
|
102
|
+
<td>=</td>
|
103
|
+
<td class="context-item-value">File.dirname(__FILE__)</td>
|
104
|
+
</tr>
|
105
|
+
<tr class="top-aligned-row context-row">
|
106
|
+
<td class="context-item-name">MERB_ROOT</td>
|
107
|
+
<td>=</td>
|
108
|
+
<td class="context-item-value">Merb::Server.config[:merb_root] rescue Dir.pwd</td>
|
109
|
+
</tr>
|
110
|
+
<tr class="top-aligned-row context-row">
|
111
|
+
<td class="context-item-name">DIST_ROOT</td>
|
112
|
+
<td>=</td>
|
113
|
+
<td class="context-item-value">Merb::Server.config[:dist_root] rescue Dir.pwd+'/dist'</td>
|
114
|
+
</tr>
|
115
|
+
<tr class="top-aligned-row context-row">
|
116
|
+
<td class="context-item-name">MERB_LOGGER</td>
|
117
|
+
<td>=</td>
|
118
|
+
<td class="context-item-value">Logger.new("#{MERB_ROOT}/log/merb.log")</td>
|
119
|
+
</tr>
|
120
|
+
</table>
|
121
|
+
</div>
|
122
|
+
</div>
|
95
123
|
|
96
124
|
|
97
125
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>File:
|
8
|
+
<title>File: merb_tasks.rb</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
11
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
@@ -47,16 +47,16 @@
|
|
47
47
|
|
48
48
|
|
49
49
|
<div id="fileHeader">
|
50
|
-
<h1>
|
50
|
+
<h1>merb_tasks.rb</h1>
|
51
51
|
<table class="header-table">
|
52
52
|
<tr class="top-aligned-row">
|
53
53
|
<td><strong>Path:</strong></td>
|
54
|
-
<td>lib/
|
54
|
+
<td>lib/merb_tasks.rb
|
55
55
|
</td>
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Mon Oct 30 17:07:43 -0800 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -22,10 +22,8 @@
|
|
22
22
|
<div id="index-entries">
|
23
23
|
<a href="classes/Hash.html">Hash</a><br />
|
24
24
|
<a href="classes/Merb.html">Merb</a><br />
|
25
|
-
<a href="classes/Merb/Config.html">Merb::Config</a><br />
|
26
25
|
<a href="classes/Merb/Controller.html">Merb::Controller</a><br />
|
27
26
|
<a href="classes/Merb/RouteMatcher.html">Merb::RouteMatcher</a><br />
|
28
|
-
<a href="classes/Merb/Server.html">Merb::Server</a><br />
|
29
27
|
<a href="classes/MerbHandler.html">MerbHandler</a><br />
|
30
28
|
<a href="classes/MerbHash.html">MerbHash</a><br />
|
31
29
|
<a href="classes/Noroutefound.html">Noroutefound</a><br />
|
data/doc/rdoc/fr_file_index.html
CHANGED
@@ -26,12 +26,10 @@
|
|
26
26
|
<a href="files/TODO.html">TODO</a><br />
|
27
27
|
<a href="files/lib/merb_rb.html">lib/merb.rb</a><br />
|
28
28
|
<a href="files/lib/merb/merb_controller_rb.html">lib/merb/merb_controller.rb</a><br />
|
29
|
-
<a href="files/lib/merb/merb_daemon_rb.html">lib/merb/merb_daemon.rb</a><br />
|
30
29
|
<a href="files/lib/merb/merb_handler_rb.html">lib/merb/merb_handler.rb</a><br />
|
31
30
|
<a href="files/lib/merb/merb_router_rb.html">lib/merb/merb_router.rb</a><br />
|
32
31
|
<a href="files/lib/merb/merb_utils_rb.html">lib/merb/merb_utils.rb</a><br />
|
33
|
-
<a href="files/lib/
|
34
|
-
<a href="files/lib/merb_config_rb.html">lib/merb_config.rb</a><br />
|
32
|
+
<a href="files/lib/merb_tasks_rb.html">lib/merb_tasks.rb</a><br />
|
35
33
|
</div>
|
36
34
|
</div>
|
37
35
|
</body>
|
@@ -26,49 +26,49 @@
|
|
26
26
|
<a href="classes/Merb/RouteMatcher.html#M000034">compile (Merb::RouteMatcher)</a><br />
|
27
27
|
<a href="classes/Merb/RouteMatcher.html#M000033">compile_router (Merb::RouteMatcher)</a><br />
|
28
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
29
|
<a href="classes/MerbHash.html#M000020">convert_key (MerbHash)</a><br />
|
31
30
|
<a href="classes/MerbHash.html#M000021">convert_value (MerbHash)</a><br />
|
32
|
-
<a href="classes/Merb/Controller.html#
|
33
|
-
<a href="classes/Merb/Controller.html#
|
31
|
+
<a href="classes/Merb/Controller.html#M000038">cookies (Merb::Controller)</a><br />
|
32
|
+
<a href="classes/Merb/Controller.html#M000046">current_method_name (Merb::Controller)</a><br />
|
34
33
|
<a href="classes/MerbHash.html#M000010">default (MerbHash)</a><br />
|
35
34
|
<a href="classes/MerbHash.html#M000018">delete (MerbHash)</a><br />
|
36
35
|
<a href="classes/MerbHash.html#M000016">dup (MerbHash)</a><br />
|
37
|
-
<a href="classes/Merb/Controller.html#
|
36
|
+
<a href="classes/Merb/Controller.html#M000041">escape (Merb::Controller)</a><br />
|
37
|
+
<a href="classes/Merb/Controller.html#M000043">escape_js (Merb::Controller)</a><br />
|
38
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
39
|
<a href="classes/MerbHash.html#M000014">fetch (MerbHash)</a><br />
|
41
40
|
<a href="classes/MerbHandler.html#M000005">handle (MerbHandler)</a><br />
|
42
|
-
<a href="classes/Merb/Controller.html#
|
41
|
+
<a href="classes/Merb/Controller.html#M000039">headers (Merb::Controller)</a><br />
|
43
42
|
<a href="classes/String.html#M000025">import (String)</a><br />
|
44
43
|
<a href="classes/MerbHandler.html#M000006">instantiate_controller (MerbHandler)</a><br />
|
44
|
+
<a href="classes/Merb/Controller.html#M000044">js (Merb::Controller)</a><br />
|
45
45
|
<a href="classes/MerbHash.html#M000013">key? (MerbHash)</a><br />
|
46
|
-
<a href="classes/Merb/Controller.html#
|
47
|
-
<a href="classes/Merb/Server.html#M000049">merb_config (Merb::Server)</a><br />
|
46
|
+
<a href="classes/Merb/Controller.html#M000048">layout (Merb::Controller)</a><br />
|
48
47
|
<a href="classes/MerbHash.html#M000017">merge (MerbHash)</a><br />
|
49
|
-
<a href="classes/MerbHash.html#M000019">method_missing (MerbHash)</a><br />
|
50
48
|
<a href="classes/Noroutefound.html#M000022">method_missing (Noroutefound)</a><br />
|
51
|
-
<a href="classes/
|
49
|
+
<a href="classes/MerbHash.html#M000019">method_missing (MerbHash)</a><br />
|
52
50
|
<a href="classes/MerbHandler.html#M000003">new (MerbHandler)</a><br />
|
51
|
+
<a href="classes/Merb/RouteMatcher.html#M000029">new (Merb::RouteMatcher)</a><br />
|
53
52
|
<a href="classes/MerbHash.html#M000009">new (MerbHash)</a><br />
|
54
|
-
<a href="classes/Merb/Controller.html#
|
53
|
+
<a href="classes/Merb/Controller.html#M000037">params (Merb::Controller)</a><br />
|
54
|
+
<a href="classes/Merb/Controller.html#M000051">partial (Merb::Controller)</a><br />
|
55
55
|
<a href="classes/Merb/RouteMatcher.html#M000028">prepare (Merb::RouteMatcher)</a><br />
|
56
56
|
<a href="classes/MerbHandler.html#M000004">process (MerbHandler)</a><br />
|
57
|
-
<a href="classes/Merb/Controller.html#
|
58
|
-
<a href="classes/Merb/Controller.html#
|
59
|
-
<a href="classes/Merb/Controller.html#
|
60
|
-
<a href="classes/Merb/Controller.html#M000047">
|
57
|
+
<a href="classes/Merb/Controller.html#M000040">query_parse (Merb::Controller)</a><br />
|
58
|
+
<a href="classes/Merb/Controller.html#M000035">redirect (Merb::Controller)</a><br />
|
59
|
+
<a href="classes/Merb/Controller.html#M000052">render (Merb::Controller)</a><br />
|
60
|
+
<a href="classes/Merb/Controller.html#M000047">render_js (Merb::Controller)</a><br />
|
61
|
+
<a href="classes/Merb/Controller.html#M000050">render_no_layout (Merb::Controller)</a><br />
|
62
|
+
<a href="classes/Merb/Controller.html#M000049">render_nothing (Merb::Controller)</a><br />
|
61
63
|
<a href="classes/Object.html#M000024">returning (Object)</a><br />
|
62
64
|
<a href="classes/Merb/RouteMatcher.html#M000030">routes (Merb::RouteMatcher)</a><br />
|
63
|
-
<a href="classes/Merb/
|
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 />
|
65
|
+
<a href="classes/Merb/Controller.html#M000036">send_file (Merb::Controller)</a><br />
|
66
66
|
<a href="classes/String.html#M000026">snake_case (String)</a><br />
|
67
|
-
<a href="classes/Merb/Controller.html#
|
67
|
+
<a href="classes/Merb/Controller.html#M000045">template_dir (Merb::Controller)</a><br />
|
68
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
69
|
<a href="classes/Symbol.html#M000001">to_s (Symbol)</a><br />
|
71
|
-
<a href="classes/
|
70
|
+
<a href="classes/Noroutefound.html#M000023">to_s (Noroutefound)</a><br />
|
71
|
+
<a href="classes/Merb/Controller.html#M000042">unescape (Merb::Controller)</a><br />
|
72
72
|
<a href="classes/MerbHash.html#M000012">update (MerbHash)</a><br />
|
73
73
|
<a href="classes/MerbHash.html#M000015">values_at (MerbHash)</a><br />
|
74
74
|
<a href="classes/Hash.html#M000008">with_indifferent_access (Hash)</a><br />
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'code_statistics'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'merb'
|
8
|
+
require MERB_FRAMEWORK_ROOT+'/merb_tasks'
|
9
|
+
include FileUtils
|
10
|
+
|
11
|
+
|
12
|
+
#desc "Packages up Merb."
|
13
|
+
#task :default => [:package]
|
14
|
+
|
15
|
+
desc "load merb_init.rb"
|
16
|
+
task :merb_init do
|
17
|
+
require 'merb'
|
18
|
+
require File.dirname(__FILE__)+'/dist/conf/merb_init.rb'
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Run schema morphing"
|
22
|
+
task :schema => [:merb_init] do
|
23
|
+
require File.dirname(__FILE__)+'/dist/schema/schema1.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
task :uninstall => [:clean] do
|
27
|
+
sh %{sudo gem uninstall #{NAME}}
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run unit tests'
|
31
|
+
Rake::TestTask.new('test_unit') do |t|
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/unit/*_test.rb'
|
34
|
+
t.verbose = true
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Run functional tests'
|
38
|
+
Rake::TestTask.new('test_functional') do |t|
|
39
|
+
t.libs << 'test'
|
40
|
+
t.pattern = 'test/functional/*_test.rb'
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Run all tests'
|
45
|
+
Rake::TestTask.new('test') do |t|
|
46
|
+
t.libs << 'test'
|
47
|
+
t.pattern = 'test/**/*_test.rb'
|
48
|
+
t.verbose = true
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Run all tests, specs and finish with rcov'
|
52
|
+
task :aok do
|
53
|
+
sh %{rake rcov}
|
54
|
+
sh %{rake spec}
|
55
|
+
end
|
56
|
+
|
57
|
+
##############################################################################
|
58
|
+
# Statistics
|
59
|
+
##############################################################################
|
60
|
+
|
61
|
+
STATS_DIRECTORIES = [
|
62
|
+
%w(Code lib/),
|
63
|
+
%w(Unit\ tests test/unit),
|
64
|
+
%w(Functional\ tests test/functional)
|
65
|
+
].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
66
|
+
|
67
|
+
desc "Report code statistics (KLOCs, etc) from the application"
|
68
|
+
task :stats do
|
69
|
+
#require 'extra/stats'
|
70
|
+
verbose = true
|
71
|
+
CodeStatistics.new(*STATS_DIRECTORIES).to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
##############################################################################
|
75
|
+
# SVN
|
76
|
+
##############################################################################
|
77
|
+
|
78
|
+
desc "Add new files to subversion"
|
79
|
+
task :svn_add do
|
80
|
+
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
|
81
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
puts "merb init called"
|
2
|
+
|
3
|
+
# add your own ruby code here for app initialization and load path stuff
|
4
|
+
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
ActiveRecord::Base.logger = MERB_LOGGER
|
8
|
+
ActiveRecord::Base.establish_connection(
|
9
|
+
:adapter => 'mysql',
|
10
|
+
:username => 'root',
|
11
|
+
:password => 'xxx',
|
12
|
+
:database => 'merb'
|
13
|
+
)
|
14
|
+
|
15
|
+
Dir[DIST_ROOT+"/app/models/*.rb"].each { |m| require m }
|
@@ -1,22 +1,20 @@
|
|
1
1
|
# Merb::RouteMatcher is the request routing mapper for the merb framework.
|
2
|
-
# You can define placeholder parts of the url with the :
|
2
|
+
# You can define placeholder parts of the url with the :smbol notation.
|
3
3
|
# so r.add '/foo/:bar/baz/:id', :class => 'Bar', :method => 'foo'
|
4
4
|
# will match against a request to /foo/123/baz/456. It will then
|
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
|
-
# 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'
|
8
|
+
# a hash of arguments to your controller methods.
|
9
|
+
# The default route is installed
|
14
10
|
|
15
11
|
|
16
12
|
puts "Compiling routes: \n"
|
17
13
|
Merb::RouteMatcher.prepare do |r|
|
18
14
|
r.add '/foo/:bar/baz/:id', :controller => 'Test', :action => 'foo'
|
19
15
|
r.add '/:controller/:action/:id'
|
16
|
+
r.add '/bar/:*rest', :controller => 'Test', :action => 'glob'
|
17
|
+
r.add '', :controller => 'posts', :action =>'index'
|
20
18
|
end
|
21
19
|
|
22
20
|
m = Merb::RouteMatcher.new
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'merb'
|
4
|
+
|
5
|
+
TMPL = <<EOF
|
6
|
+
class <%= class_name.snake_case.camel_case %> < ActiveRecord::Migration
|
7
|
+
def self.up
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.down
|
11
|
+
end
|
12
|
+
end
|
13
|
+
EOF
|
14
|
+
|
15
|
+
class_name = ARGV[0]
|
16
|
+
highest_migration = Dir[Dir.pwd+'/dist/schema/migrations/*'].map{|f| File.basename(f) =~ /^(\d+)/; $1}.max
|
17
|
+
filename = format("%03d_%s", (highest_migration.to_i+1), class_name.snake_case)
|
18
|
+
|
19
|
+
File.open(Dir.pwd+"/dist/schema/migrations/#{filename}.rb", 'w+') do |file|
|
20
|
+
file.write Erubis::Eruby.new(TMPL).result(binding)
|
21
|
+
end
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'code_statistics'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'merb'
|
8
|
+
require MERB_FRAMEWORK_ROOT+'/merb_tasks'
|
9
|
+
include FileUtils
|
10
|
+
|
11
|
+
|
12
|
+
#desc "Packages up Merb."
|
13
|
+
#task :default => [:package]
|
14
|
+
|
15
|
+
desc "load merb_init.rb"
|
16
|
+
task :merb_init do
|
17
|
+
require 'merb'
|
18
|
+
require File.dirname(__FILE__)+'/dist/conf/merb_init.rb'
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Run schema morphing"
|
22
|
+
task :schema => [:merb_init] do
|
23
|
+
require File.dirname(__FILE__)+'/dist/schema/schema1.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
task :uninstall => [:clean] do
|
27
|
+
sh %{sudo gem uninstall #{NAME}}
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run unit tests'
|
31
|
+
Rake::TestTask.new('test_unit') do |t|
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/unit/*_test.rb'
|
34
|
+
t.verbose = true
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Run functional tests'
|
38
|
+
Rake::TestTask.new('test_functional') do |t|
|
39
|
+
t.libs << 'test'
|
40
|
+
t.pattern = 'test/functional/*_test.rb'
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Run all tests'
|
45
|
+
Rake::TestTask.new('test') do |t|
|
46
|
+
t.libs << 'test'
|
47
|
+
t.pattern = 'test/**/*_test.rb'
|
48
|
+
t.verbose = true
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Run all tests, specs and finish with rcov'
|
52
|
+
task :aok do
|
53
|
+
sh %{rake rcov}
|
54
|
+
sh %{rake spec}
|
55
|
+
end
|
56
|
+
|
57
|
+
##############################################################################
|
58
|
+
# Statistics
|
59
|
+
##############################################################################
|
60
|
+
|
61
|
+
STATS_DIRECTORIES = [
|
62
|
+
%w(Code lib/),
|
63
|
+
%w(Unit\ tests test/unit),
|
64
|
+
%w(Functional\ tests test/functional)
|
65
|
+
].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
66
|
+
|
67
|
+
desc "Report code statistics (KLOCs, etc) from the application"
|
68
|
+
task :stats do
|
69
|
+
#require 'extra/stats'
|
70
|
+
verbose = true
|
71
|
+
CodeStatistics.new(*STATS_DIRECTORIES).to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
##############################################################################
|
75
|
+
# SVN
|
76
|
+
##############################################################################
|
77
|
+
|
78
|
+
desc "Add new files to subversion"
|
79
|
+
task :svn_add do
|
80
|
+
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
|
81
|
+
end
|