ramaze 0.0.7 → 0.0.8
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/Rakefile +52 -19
- data/bin/ramaze +19 -6
- data/doc/CHANGELOG +33 -0
- data/doc/COPYING +1 -1
- data/doc/FAQ +92 -0
- data/doc/GPL +340 -0
- data/doc/INSTALL +34 -0
- data/doc/ProjectInfo +53 -0
- data/doc/README +187 -110
- data/doc/readme_chunks/appendix.txt +13 -0
- data/doc/readme_chunks/examples.txt +38 -0
- data/doc/readme_chunks/features.txt +82 -0
- data/doc/readme_chunks/getting_help.txt +5 -0
- data/doc/readme_chunks/getting_started.txt +18 -0
- data/doc/readme_chunks/installing.txt +41 -0
- data/doc/readme_chunks/introduction.txt +18 -0
- data/doc/readme_chunks/principles.txt +41 -0
- data/doc/readme_chunks/thanks.txt +59 -0
- data/doc/tutorial/todolist.txt +546 -0
- data/examples/blog/main.rb +1 -1
- data/examples/blog/src/controller.rb +13 -11
- data/examples/blog/src/element.rb +11 -6
- data/examples/blog/src/model.rb +8 -23
- data/examples/blog/template/edit.xhtml +3 -1
- data/examples/blog/template/index.xhtml +4 -4
- data/examples/caching.rb +4 -4
- data/examples/element.rb +10 -7
- data/examples/hello.rb +3 -4
- data/examples/simple.rb +5 -3
- data/examples/templates/template/external.amrita +19 -0
- data/examples/templates/template/{external.rmze → external.zmr} +2 -2
- data/examples/templates/template_amrita2.rb +48 -0
- data/examples/templates/template_erubis.rb +5 -2
- data/examples/templates/{template_ramaze.rb → template_ezamar.rb} +13 -7
- data/examples/templates/template_haml.rb +4 -1
- data/examples/templates/template_liquid.rb +2 -1
- data/examples/templates/template_markaby.rb +2 -1
- data/examples/todolist/conf/benchmark.yaml +35 -0
- data/examples/todolist/conf/debug.yaml +34 -0
- data/examples/todolist/conf/live.yaml +33 -0
- data/examples/todolist/conf/silent.yaml +31 -0
- data/examples/todolist/conf/stage.yaml +33 -0
- data/examples/todolist/main.rb +18 -0
- data/examples/todolist/public/404.jpg +0 -0
- data/examples/todolist/public/css/coderay.css +105 -0
- data/examples/todolist/public/css/ramaze_error.css +42 -0
- data/{lib/proto → examples/todolist}/public/error.xhtml +0 -0
- data/examples/todolist/public/favicon.ico +0 -0
- data/examples/todolist/public/js/jquery.js +1923 -0
- data/examples/todolist/public/ramaze.png +0 -0
- data/examples/todolist/src/controller/main.rb +56 -0
- data/examples/todolist/src/element/page.rb +26 -0
- data/examples/todolist/src/model.rb +14 -0
- data/examples/todolist/template/index.xhtml +17 -0
- data/examples/todolist/template/new.xhtml +7 -0
- data/examples/todolist/todolist.db +9 -0
- data/examples/whywiki/main.rb +3 -8
- data/examples/whywiki/template/show.xhtml +4 -0
- data/lib/proto/public/error.zmr +77 -0
- data/lib/proto/src/controller/main.rb +2 -1
- data/lib/proto/src/element/page.rb +2 -1
- data/lib/proto/src/model.rb +3 -2
- data/lib/ramaze.rb +7 -9
- data/lib/ramaze/adapter.rb +51 -0
- data/lib/ramaze/adapter/cgi.rb +23 -0
- data/lib/ramaze/adapter/fcgi.rb +22 -0
- data/lib/ramaze/adapter/mongrel.rb +7 -86
- data/lib/ramaze/adapter/webrick.rb +14 -133
- data/lib/ramaze/cache/memcached.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +3 -1
- data/lib/ramaze/controller.rb +292 -2
- data/lib/ramaze/dispatcher.rb +85 -213
- data/lib/ramaze/error.rb +10 -0
- data/lib/ramaze/global.rb +8 -0
- data/lib/ramaze/helper/aspect.rb +30 -7
- data/lib/ramaze/helper/auth.rb +16 -9
- data/lib/ramaze/helper/cache.rb +40 -35
- data/lib/ramaze/helper/feed.rb +1 -1
- data/lib/ramaze/helper/flash.rb +34 -0
- data/lib/ramaze/helper/link.rb +8 -2
- data/lib/ramaze/helper/openid.rb +63 -0
- data/lib/ramaze/helper/redirect.rb +12 -11
- data/lib/ramaze/helper/stack.rb +5 -7
- data/lib/ramaze/inform.rb +12 -1
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
- data/lib/ramaze/snippets/kernel/{self_method.rb → method.rb} +3 -18
- data/lib/ramaze/snippets/kernel/{rescue_require.rb → pretty_inspect.rb} +7 -6
- data/lib/ramaze/snippets/method/name.rb +22 -0
- data/lib/ramaze/snippets/{kernel → ramaze}/autoreload.rb +0 -0
- data/lib/ramaze/snippets/ramaze/caller_info.rb +14 -0
- data/lib/ramaze/snippets/{kernel → ramaze}/caller_lines.rb +3 -10
- data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +49 -23
- data/lib/ramaze/snippets/string/DIVIDE.rb +0 -1
- data/lib/ramaze/store/default.rb +58 -2
- data/lib/ramaze/store/yaml.rb +161 -0
- data/lib/ramaze/template.rb +27 -86
- data/lib/ramaze/template/amrita2.rb +14 -19
- data/lib/ramaze/template/erubis.rb +15 -38
- data/lib/ramaze/template/ezamar.rb +100 -0
- data/lib/ramaze/template/ezamar/element.rb +166 -0
- data/lib/ramaze/template/ezamar/engine.rb +124 -0
- data/lib/ramaze/template/ezamar/morpher.rb +155 -0
- data/lib/ramaze/template/haml.rb +16 -43
- data/lib/ramaze/template/liquid.rb +11 -51
- data/lib/ramaze/template/markaby.rb +44 -42
- data/lib/ramaze/tool/mime.rb +18 -0
- data/lib/ramaze/tool/mime_types.yaml +615 -0
- data/lib/ramaze/trinity/request.rb +20 -196
- data/lib/ramaze/trinity/response.rb +4 -33
- data/lib/ramaze/trinity/session.rb +150 -72
- data/lib/ramaze/version.rb +1 -1
- data/spec/adapter_spec.rb +20 -0
- data/spec/public/favicon.ico +0 -0
- data/spec/public/ramaze.png +0 -0
- data/spec/public/test_download.css +141 -0
- data/spec/{tc_request.rb → request_tc_helper.rb} +45 -21
- data/spec/spec_all.rb +77 -34
- data/spec/spec_helper.rb +8 -157
- data/spec/spec_helper_context.rb +72 -0
- data/spec/spec_helper_requester.rb +52 -0
- data/spec/spec_helper_simple_http.rb +433 -0
- data/spec/tc_adapter_mongrel.rb +3 -15
- data/spec/tc_adapter_webrick.rb +4 -14
- data/spec/tc_cache.rb +3 -5
- data/spec/tc_controller.rb +22 -12
- data/spec/tc_dependencies.rb +13 -0
- data/spec/tc_element.rb +8 -7
- data/spec/tc_error.rb +13 -7
- data/spec/tc_global.rb +16 -18
- data/spec/tc_helper_aspect.rb +2 -4
- data/spec/tc_helper_auth.rb +15 -14
- data/spec/tc_helper_cache.rb +5 -7
- data/spec/tc_helper_feed.rb +0 -2
- data/spec/tc_helper_flash.rb +103 -0
- data/spec/tc_helper_form.rb +4 -6
- data/spec/tc_helper_link.rb +1 -3
- data/spec/tc_helper_redirect.rb +23 -8
- data/spec/tc_helper_stack.rb +31 -15
- data/spec/tc_morpher.rb +1 -3
- data/spec/tc_params.rb +48 -7
- data/spec/tc_request_mongrel.rb +9 -0
- data/spec/tc_request_webrick.rb +5 -0
- data/spec/tc_session.rb +41 -25
- data/spec/tc_store.rb +55 -6
- data/spec/tc_store_yaml.rb +71 -0
- data/spec/tc_template_amrita2.rb +3 -3
- data/spec/tc_template_erubis.rb +2 -3
- data/spec/{tc_template_ramaze.rb → tc_template_ezamar.rb} +15 -5
- data/spec/tc_template_haml.rb +4 -3
- data/spec/tc_template_liquid.rb +3 -4
- data/spec/tc_template_markaby.rb +4 -6
- data/spec/tc_tidy.rb +1 -3
- data/spec/template/amrita2/{data.html → data.amrita} +0 -0
- data/spec/template/amrita2/{index.html → index.amrita} +0 -0
- data/spec/template/amrita2/{sum.html → sum.amrita} +0 -0
- data/spec/template/ezamar/another/long/action.zmr +1 -0
- data/spec/template/ezamar/combined.zmr +1 -0
- data/spec/template/{ramaze/file_only.rmze → ezamar/file_only.zmr} +0 -0
- data/spec/template/{ramaze/index.rmze → ezamar/index.zmr} +0 -0
- data/spec/template/{ramaze/nested.rmze → ezamar/nested.zmr} +0 -0
- data/spec/template/ezamar/some__long__action.zmr +1 -0
- data/spec/template/{ramaze/sum.rmze → ezamar/sum.zmr} +0 -0
- metadata +181 -123
- data/doc/allison/LICENSE +0 -184
- data/doc/allison/README +0 -37
- data/doc/allison/allison.css +0 -300
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +0 -307
- data/doc/allison/allison.rb +0 -287
- data/doc/allison/cache/BODY +0 -588
- data/doc/allison/cache/CLASS_INDEX +0 -4
- data/doc/allison/cache/CLASS_PAGE +0 -1
- data/doc/allison/cache/FILE_INDEX +0 -4
- data/doc/allison/cache/FILE_PAGE +0 -1
- data/doc/allison/cache/FONTS +0 -1
- data/doc/allison/cache/FR_INDEX_BODY +0 -1
- data/doc/allison/cache/IMGPATH +0 -1
- data/doc/allison/cache/INDEX +0 -1
- data/doc/allison/cache/JAVASCRIPT +0 -307
- data/doc/allison/cache/METHOD_INDEX +0 -4
- data/doc/allison/cache/METHOD_LIST +0 -1
- data/doc/allison/cache/SRC_PAGE +0 -1
- data/doc/allison/cache/STYLE +0 -322
- data/doc/allison/cache/URL +0 -1
- data/doc/changes.txt +0 -2021
- data/doc/changes.xml +0 -2024
- data/lib/ramaze/snippets/kernel/silently.rb +0 -13
- data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +0 -11
- data/lib/ramaze/template/haml/actionview_stub.rb +0 -20
- data/lib/ramaze/template/ramaze.rb +0 -177
- data/lib/ramaze/template/ramaze/element.rb +0 -166
- data/lib/ramaze/template/ramaze/morpher.rb +0 -156
- data/spec/tc_test.rb +0 -17
|
Binary file
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
class MainController < Controller
|
|
5
|
+
|
|
6
|
+
trait :engine => Template::Ezamar
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
@tasks = []
|
|
10
|
+
TodoList.original.each do |title, parameters|
|
|
11
|
+
if parameters[:done]
|
|
12
|
+
status = 'done'
|
|
13
|
+
toggle = link( R( self, :open, CGI.escape(title) ), :title => 'Open Task' )
|
|
14
|
+
else
|
|
15
|
+
status = 'not done'
|
|
16
|
+
toggle = link( R( self, :close, CGI.escape(title) ), :title => 'Close Task' )
|
|
17
|
+
end
|
|
18
|
+
delete = link( R( self, :delete, CGI.escape(title) ), :title => 'Delete' )
|
|
19
|
+
@tasks << [title, status, toggle, delete]
|
|
20
|
+
end
|
|
21
|
+
@tasks.sort!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create
|
|
25
|
+
title = request['title']
|
|
26
|
+
TodoList[title] = {:done => false}
|
|
27
|
+
redirect R(self)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def open title
|
|
31
|
+
task_status title, false
|
|
32
|
+
redirect R(self)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def close title
|
|
36
|
+
task_status title, true
|
|
37
|
+
redirect R(self)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def delete title
|
|
41
|
+
TodoList.delete title
|
|
42
|
+
redirect R(self)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def error
|
|
46
|
+
@foo = 'bar'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def task_status title, status
|
|
52
|
+
task = TodoList[title]
|
|
53
|
+
task[:done] = status
|
|
54
|
+
TodoList[title] = task
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
class Page < Ezamar::Element
|
|
5
|
+
def render
|
|
6
|
+
%(
|
|
7
|
+
<html>
|
|
8
|
+
<head>
|
|
9
|
+
<title>TodoList</title>
|
|
10
|
+
<style>
|
|
11
|
+
table { width: 100%; }
|
|
12
|
+
tr { background: #efe; width: 100%; }
|
|
13
|
+
tr:hover { background: #dfd; }
|
|
14
|
+
td.title { font-weight: bold; width: 60%; }
|
|
15
|
+
td.status { margin: 1em; }
|
|
16
|
+
a { color: #3a3; }
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<h1>#{@hash['title']}</h1>
|
|
21
|
+
#{content}
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require 'ramaze/store/default'
|
|
5
|
+
|
|
6
|
+
TodoList = Ramaze::Store::Default.new('todolist.db')
|
|
7
|
+
|
|
8
|
+
{
|
|
9
|
+
'Laundry' => {:done => false},
|
|
10
|
+
'Wash dishes' => {:done => false},
|
|
11
|
+
|
|
12
|
+
}.each do |task, parameters|
|
|
13
|
+
TodoList[task] = parameters
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<Page title="TodoList">
|
|
2
|
+
<a href="/new">New Task</a>
|
|
3
|
+
<?r if @tasks.empty? ?>
|
|
4
|
+
No Tasks
|
|
5
|
+
<?r else ?>
|
|
6
|
+
<table>
|
|
7
|
+
<?r @tasks.each do |title, status, toggle, delete| ?>
|
|
8
|
+
<tr>
|
|
9
|
+
<td class="title"> #{title} </td>
|
|
10
|
+
<td class="status"> #{status} </td>
|
|
11
|
+
<td class="toggle"> #{toggle} </td>
|
|
12
|
+
<td class="delete"> #{delete} </td>
|
|
13
|
+
</tr>
|
|
14
|
+
<?r end ?>
|
|
15
|
+
</table>
|
|
16
|
+
<?r end ?>
|
|
17
|
+
</Page>
|
data/examples/whywiki/main.rb
CHANGED
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
# written as an example of how to implement the minimal _why wiki
|
|
5
5
|
|
|
6
|
-
begin
|
|
7
|
-
require 'rubygems'
|
|
8
|
-
rescue LoadError
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
require 'ramaze'
|
|
12
7
|
require 'bluecloth'
|
|
13
8
|
|
|
@@ -15,7 +10,7 @@ include Ramaze
|
|
|
15
10
|
|
|
16
11
|
Db = YAMLStoreCache.new('wiki.yaml')
|
|
17
12
|
|
|
18
|
-
class WikiController <
|
|
13
|
+
class WikiController < Controller
|
|
19
14
|
def index
|
|
20
15
|
redirect(R(:show, 'Home'))
|
|
21
16
|
end
|
|
@@ -25,7 +20,8 @@ class WikiController < Template::Ramaze
|
|
|
25
20
|
@text = Db[page].to_s
|
|
26
21
|
|
|
27
22
|
@text.gsub!(/\[\[(.*?)\]\]/) do |m|
|
|
28
|
-
|
|
23
|
+
exists = Db[$1] ? 'exists' : 'nonexists'
|
|
24
|
+
link( R(self, :show, CGI.escape($1)), :title => $1, :class => exists)
|
|
29
25
|
end
|
|
30
26
|
|
|
31
27
|
@text = BlueCloth.new(@text).to_html
|
|
@@ -50,7 +46,6 @@ end
|
|
|
50
46
|
|
|
51
47
|
Global.adapter = :mongrel
|
|
52
48
|
#Global.tidy = true
|
|
53
|
-
#Global.mode = :benchmark
|
|
54
49
|
Global.mapping = {'/' => WikiController}
|
|
55
50
|
|
|
56
51
|
start
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>#{@title}</title>
|
|
4
|
+
<?r if @coderay ?>
|
|
5
|
+
<style>
|
|
6
|
+
#{CodeRay::Encoders[:html]::CSS.new.stylesheet}
|
|
7
|
+
</style>
|
|
8
|
+
<?r end ?>
|
|
9
|
+
<link rel="stylesheet" href="/css/ramaze_error.css" />
|
|
10
|
+
<script type="text/javascript" src="/js/jquery.js"></script>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<img id="logo" alt="Ramaze" src="/ramaze.png" />
|
|
14
|
+
|
|
15
|
+
<h1>#{@title}</h1>
|
|
16
|
+
|
|
17
|
+
<table class="main">
|
|
18
|
+
<tr class="head">
|
|
19
|
+
<td>File</td><td>Line</td><td>Method</td>
|
|
20
|
+
</tr>
|
|
21
|
+
<?r @backtrace.each do |lines, hash, file, lineno, meth| ?>
|
|
22
|
+
<tr id="line_#{hash}" style="background:rgb(#{@colors.shift},200,200);">
|
|
23
|
+
<td>#{file}</td><td>#{lineno}</td><td><pre>#{meth}</pre></td>
|
|
24
|
+
</tr>
|
|
25
|
+
<tr id="source_#{hash}" style="display:none;">
|
|
26
|
+
<td colspan="3">
|
|
27
|
+
<div class="source">
|
|
28
|
+
<table style="width:100%;">
|
|
29
|
+
<tr>
|
|
30
|
+
<td colspan="2">vim #{file} +#{lineno}</td>
|
|
31
|
+
</tr>
|
|
32
|
+
<?r
|
|
33
|
+
if @coderay
|
|
34
|
+
code = lines.map{|no, code, cur| code}.join("\n")
|
|
35
|
+
options = {
|
|
36
|
+
:wrap => :div,
|
|
37
|
+
:line_numbers => :inline,
|
|
38
|
+
:line_number_start => (lineno.to_i - Global.inform_backtrace_size)
|
|
39
|
+
}
|
|
40
|
+
?>
|
|
41
|
+
#{CodeRay.scan(code, :ruby).html(options)}
|
|
42
|
+
<?r else ?>
|
|
43
|
+
<?r lines.each do |llineno, lcode, lcurrent| ?>
|
|
44
|
+
<tr class="source" #{'style="background:#faa;"' if lcurrent}>
|
|
45
|
+
<td>#{llineno}</td>
|
|
46
|
+
<td><pre>#{lcode.rstrip}</pre></td>
|
|
47
|
+
</tr>
|
|
48
|
+
<?r end ?>
|
|
49
|
+
<?r end ?>
|
|
50
|
+
</table>
|
|
51
|
+
</div>
|
|
52
|
+
<script type="text/javascript">
|
|
53
|
+
$("tr#line_#{hash}").click(function(){$("tr#source_#{hash}").toggle()});
|
|
54
|
+
</script>
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<?r end ?>
|
|
58
|
+
</table>
|
|
59
|
+
<?r
|
|
60
|
+
{
|
|
61
|
+
'Session' => Thread.current[:session],
|
|
62
|
+
'Request' => Thread.current[:request],
|
|
63
|
+
'Response' => Thread.current[:response],
|
|
64
|
+
'Global' => Global,
|
|
65
|
+
}.each do |title, content|
|
|
66
|
+
hash = [title, content].object_id.abs
|
|
67
|
+
?>
|
|
68
|
+
<div class="additional">
|
|
69
|
+
<h3 id="show_#{hash}">#{title}</h3>
|
|
70
|
+
<pre style="display:none" id="is_#{hash}">#{CGI.escapeHTML(content.pretty_inspect)}</pre>
|
|
71
|
+
<script type="text/javascript">
|
|
72
|
+
$("h3#show_#{hash}").click(function(){$("pre#is_#{hash}").toggle()});
|
|
73
|
+
</script>
|
|
74
|
+
</div>
|
|
75
|
+
<?r end ?>
|
|
76
|
+
</body>
|
|
77
|
+
</html>
|
data/lib/proto/src/model.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
require 'yaml/store'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
require 'ramaze/store/default'
|
|
5
|
+
|
|
6
|
+
Db = Ramaze::Store::Default.new('yaml.db')
|
data/lib/ramaze.rb
CHANGED
|
@@ -17,16 +17,17 @@ require 'pp'
|
|
|
17
17
|
|
|
18
18
|
require 'ramaze/snippets'
|
|
19
19
|
require 'ramaze/cache'
|
|
20
|
-
require 'ramaze/
|
|
21
|
-
require 'ramaze/dispatcher'
|
|
20
|
+
require 'ramaze/trinity'
|
|
22
21
|
require 'ramaze/error'
|
|
22
|
+
require 'ramaze/dispatcher'
|
|
23
23
|
require 'ramaze/gestalt'
|
|
24
24
|
require 'ramaze/global'
|
|
25
25
|
require 'ramaze/inform'
|
|
26
26
|
require 'ramaze/http_status'
|
|
27
|
-
require 'ramaze/snippets'
|
|
28
27
|
require 'ramaze/helper'
|
|
29
|
-
require 'ramaze/
|
|
28
|
+
require 'ramaze/controller'
|
|
29
|
+
require 'ramaze/template/ezamar'
|
|
30
|
+
require 'ramaze/adapter'
|
|
30
31
|
require 'ramaze/version'
|
|
31
32
|
|
|
32
33
|
module Ramaze
|
|
@@ -74,7 +75,6 @@ module Ramaze
|
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
alias run start
|
|
77
|
-
alias new start
|
|
78
78
|
|
|
79
79
|
# same as start(:force => true)
|
|
80
80
|
|
|
@@ -91,7 +91,7 @@ module Ramaze
|
|
|
91
91
|
|
|
92
92
|
def startup
|
|
93
93
|
tasks = Global.startup + Global.ramaze_startup
|
|
94
|
-
execute
|
|
94
|
+
execute(*tasks)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
# Execute the tasks specified in Global.shutdown
|
|
@@ -101,7 +101,7 @@ module Ramaze
|
|
|
101
101
|
|
|
102
102
|
def shutdown
|
|
103
103
|
tasks = Global.shutdown + Global.ramaze_shutdown
|
|
104
|
-
execute
|
|
104
|
+
execute(*tasks)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
# executes a list of tasks, depending on the task-object, if it responds to
|
|
@@ -183,7 +183,6 @@ module Ramaze
|
|
|
183
183
|
else
|
|
184
184
|
mapping["/#{name.split('::').last.snake_case}"] = c
|
|
185
185
|
end
|
|
186
|
-
c.__send__(:send, :include, Ramaze::Controller)
|
|
187
186
|
end
|
|
188
187
|
|
|
189
188
|
Global.mapping.merge!(mapping) if Global.mapping.empty?
|
|
@@ -195,7 +194,6 @@ module Ramaze
|
|
|
195
194
|
|
|
196
195
|
Global.controllers.map! do |controller|
|
|
197
196
|
controller = constant(controller)
|
|
198
|
-
controller.send(:include, Ramaze::Controller)
|
|
199
197
|
end
|
|
200
198
|
end
|
|
201
199
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require 'rack'
|
|
5
|
+
require 'benchmark'
|
|
6
|
+
|
|
7
|
+
# for OSX compatibility
|
|
8
|
+
Socket.do_not_reverse_lookup = true
|
|
9
|
+
|
|
10
|
+
module Ramaze::Adapter
|
|
11
|
+
class Base
|
|
12
|
+
class << self
|
|
13
|
+
def stop
|
|
14
|
+
Informer.debug "Stopping #{self.class}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def call(env)
|
|
18
|
+
new.call(env)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def call(env)
|
|
23
|
+
if Ramaze::Global.inform_tags.include?(:benchmark)
|
|
24
|
+
time = Benchmark.measure{ respond env }
|
|
25
|
+
info "request took #{time.real}s"
|
|
26
|
+
else
|
|
27
|
+
respond env
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@response = Thread.current[:response]
|
|
31
|
+
|
|
32
|
+
[@response.status, @response.header, self]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def respond env
|
|
36
|
+
Ramaze::Dispatcher.handle(::Rack::Request.new(env), ::Rack::Response.new)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def each
|
|
40
|
+
body = @response.body
|
|
41
|
+
|
|
42
|
+
if body.respond_to?(:read)
|
|
43
|
+
until body.eof?
|
|
44
|
+
yield body.read(1024)
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
yield body
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require 'ramaze/adapter'
|
|
5
|
+
|
|
6
|
+
module Ramaze::Adapter
|
|
7
|
+
class Cgi < Base
|
|
8
|
+
class << self
|
|
9
|
+
def start host, ports
|
|
10
|
+
global = Ramaze::Global
|
|
11
|
+
global.inform_to = :stderr if global.inform_to == $stdout
|
|
12
|
+
run_server
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run_server
|
|
16
|
+
Thread.new do
|
|
17
|
+
Thread.current[:task] = :cgi
|
|
18
|
+
Rack::Handler::CGI.run(self)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require 'ramaze/adapter'
|
|
5
|
+
|
|
6
|
+
module Ramaze::Adapter
|
|
7
|
+
class Fcgi < Base
|
|
8
|
+
class << self
|
|
9
|
+
def start host, ports
|
|
10
|
+
run_server
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def run_server
|
|
14
|
+
Thread.new do
|
|
15
|
+
Thread.current[:task] = :cgi
|
|
16
|
+
Rack::Handler::FastCGI.run(self)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|