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.
Files changed (193) hide show
  1. data/Rakefile +52 -19
  2. data/bin/ramaze +19 -6
  3. data/doc/CHANGELOG +33 -0
  4. data/doc/COPYING +1 -1
  5. data/doc/FAQ +92 -0
  6. data/doc/GPL +340 -0
  7. data/doc/INSTALL +34 -0
  8. data/doc/ProjectInfo +53 -0
  9. data/doc/README +187 -110
  10. data/doc/readme_chunks/appendix.txt +13 -0
  11. data/doc/readme_chunks/examples.txt +38 -0
  12. data/doc/readme_chunks/features.txt +82 -0
  13. data/doc/readme_chunks/getting_help.txt +5 -0
  14. data/doc/readme_chunks/getting_started.txt +18 -0
  15. data/doc/readme_chunks/installing.txt +41 -0
  16. data/doc/readme_chunks/introduction.txt +18 -0
  17. data/doc/readme_chunks/principles.txt +41 -0
  18. data/doc/readme_chunks/thanks.txt +59 -0
  19. data/doc/tutorial/todolist.txt +546 -0
  20. data/examples/blog/main.rb +1 -1
  21. data/examples/blog/src/controller.rb +13 -11
  22. data/examples/blog/src/element.rb +11 -6
  23. data/examples/blog/src/model.rb +8 -23
  24. data/examples/blog/template/edit.xhtml +3 -1
  25. data/examples/blog/template/index.xhtml +4 -4
  26. data/examples/caching.rb +4 -4
  27. data/examples/element.rb +10 -7
  28. data/examples/hello.rb +3 -4
  29. data/examples/simple.rb +5 -3
  30. data/examples/templates/template/external.amrita +19 -0
  31. data/examples/templates/template/{external.rmze → external.zmr} +2 -2
  32. data/examples/templates/template_amrita2.rb +48 -0
  33. data/examples/templates/template_erubis.rb +5 -2
  34. data/examples/templates/{template_ramaze.rb → template_ezamar.rb} +13 -7
  35. data/examples/templates/template_haml.rb +4 -1
  36. data/examples/templates/template_liquid.rb +2 -1
  37. data/examples/templates/template_markaby.rb +2 -1
  38. data/examples/todolist/conf/benchmark.yaml +35 -0
  39. data/examples/todolist/conf/debug.yaml +34 -0
  40. data/examples/todolist/conf/live.yaml +33 -0
  41. data/examples/todolist/conf/silent.yaml +31 -0
  42. data/examples/todolist/conf/stage.yaml +33 -0
  43. data/examples/todolist/main.rb +18 -0
  44. data/examples/todolist/public/404.jpg +0 -0
  45. data/examples/todolist/public/css/coderay.css +105 -0
  46. data/examples/todolist/public/css/ramaze_error.css +42 -0
  47. data/{lib/proto → examples/todolist}/public/error.xhtml +0 -0
  48. data/examples/todolist/public/favicon.ico +0 -0
  49. data/examples/todolist/public/js/jquery.js +1923 -0
  50. data/examples/todolist/public/ramaze.png +0 -0
  51. data/examples/todolist/src/controller/main.rb +56 -0
  52. data/examples/todolist/src/element/page.rb +26 -0
  53. data/examples/todolist/src/model.rb +14 -0
  54. data/examples/todolist/template/index.xhtml +17 -0
  55. data/examples/todolist/template/new.xhtml +7 -0
  56. data/examples/todolist/todolist.db +9 -0
  57. data/examples/whywiki/main.rb +3 -8
  58. data/examples/whywiki/template/show.xhtml +4 -0
  59. data/lib/proto/public/error.zmr +77 -0
  60. data/lib/proto/src/controller/main.rb +2 -1
  61. data/lib/proto/src/element/page.rb +2 -1
  62. data/lib/proto/src/model.rb +3 -2
  63. data/lib/ramaze.rb +7 -9
  64. data/lib/ramaze/adapter.rb +51 -0
  65. data/lib/ramaze/adapter/cgi.rb +23 -0
  66. data/lib/ramaze/adapter/fcgi.rb +22 -0
  67. data/lib/ramaze/adapter/mongrel.rb +7 -86
  68. data/lib/ramaze/adapter/webrick.rb +14 -133
  69. data/lib/ramaze/cache/memcached.rb +6 -0
  70. data/lib/ramaze/cache/yaml_store.rb +3 -1
  71. data/lib/ramaze/controller.rb +292 -2
  72. data/lib/ramaze/dispatcher.rb +85 -213
  73. data/lib/ramaze/error.rb +10 -0
  74. data/lib/ramaze/global.rb +8 -0
  75. data/lib/ramaze/helper/aspect.rb +30 -7
  76. data/lib/ramaze/helper/auth.rb +16 -9
  77. data/lib/ramaze/helper/cache.rb +40 -35
  78. data/lib/ramaze/helper/feed.rb +1 -1
  79. data/lib/ramaze/helper/flash.rb +34 -0
  80. data/lib/ramaze/helper/link.rb +8 -2
  81. data/lib/ramaze/helper/openid.rb +63 -0
  82. data/lib/ramaze/helper/redirect.rb +12 -11
  83. data/lib/ramaze/helper/stack.rb +5 -7
  84. data/lib/ramaze/inform.rb +12 -1
  85. data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
  86. data/lib/ramaze/snippets/kernel/{self_method.rb → method.rb} +3 -18
  87. data/lib/ramaze/snippets/kernel/{rescue_require.rb → pretty_inspect.rb} +7 -6
  88. data/lib/ramaze/snippets/method/name.rb +22 -0
  89. data/lib/ramaze/snippets/{kernel → ramaze}/autoreload.rb +0 -0
  90. data/lib/ramaze/snippets/ramaze/caller_info.rb +14 -0
  91. data/lib/ramaze/snippets/{kernel → ramaze}/caller_lines.rb +3 -10
  92. data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +49 -23
  93. data/lib/ramaze/snippets/string/DIVIDE.rb +0 -1
  94. data/lib/ramaze/store/default.rb +58 -2
  95. data/lib/ramaze/store/yaml.rb +161 -0
  96. data/lib/ramaze/template.rb +27 -86
  97. data/lib/ramaze/template/amrita2.rb +14 -19
  98. data/lib/ramaze/template/erubis.rb +15 -38
  99. data/lib/ramaze/template/ezamar.rb +100 -0
  100. data/lib/ramaze/template/ezamar/element.rb +166 -0
  101. data/lib/ramaze/template/ezamar/engine.rb +124 -0
  102. data/lib/ramaze/template/ezamar/morpher.rb +155 -0
  103. data/lib/ramaze/template/haml.rb +16 -43
  104. data/lib/ramaze/template/liquid.rb +11 -51
  105. data/lib/ramaze/template/markaby.rb +44 -42
  106. data/lib/ramaze/tool/mime.rb +18 -0
  107. data/lib/ramaze/tool/mime_types.yaml +615 -0
  108. data/lib/ramaze/trinity/request.rb +20 -196
  109. data/lib/ramaze/trinity/response.rb +4 -33
  110. data/lib/ramaze/trinity/session.rb +150 -72
  111. data/lib/ramaze/version.rb +1 -1
  112. data/spec/adapter_spec.rb +20 -0
  113. data/spec/public/favicon.ico +0 -0
  114. data/spec/public/ramaze.png +0 -0
  115. data/spec/public/test_download.css +141 -0
  116. data/spec/{tc_request.rb → request_tc_helper.rb} +45 -21
  117. data/spec/spec_all.rb +77 -34
  118. data/spec/spec_helper.rb +8 -157
  119. data/spec/spec_helper_context.rb +72 -0
  120. data/spec/spec_helper_requester.rb +52 -0
  121. data/spec/spec_helper_simple_http.rb +433 -0
  122. data/spec/tc_adapter_mongrel.rb +3 -15
  123. data/spec/tc_adapter_webrick.rb +4 -14
  124. data/spec/tc_cache.rb +3 -5
  125. data/spec/tc_controller.rb +22 -12
  126. data/spec/tc_dependencies.rb +13 -0
  127. data/spec/tc_element.rb +8 -7
  128. data/spec/tc_error.rb +13 -7
  129. data/spec/tc_global.rb +16 -18
  130. data/spec/tc_helper_aspect.rb +2 -4
  131. data/spec/tc_helper_auth.rb +15 -14
  132. data/spec/tc_helper_cache.rb +5 -7
  133. data/spec/tc_helper_feed.rb +0 -2
  134. data/spec/tc_helper_flash.rb +103 -0
  135. data/spec/tc_helper_form.rb +4 -6
  136. data/spec/tc_helper_link.rb +1 -3
  137. data/spec/tc_helper_redirect.rb +23 -8
  138. data/spec/tc_helper_stack.rb +31 -15
  139. data/spec/tc_morpher.rb +1 -3
  140. data/spec/tc_params.rb +48 -7
  141. data/spec/tc_request_mongrel.rb +9 -0
  142. data/spec/tc_request_webrick.rb +5 -0
  143. data/spec/tc_session.rb +41 -25
  144. data/spec/tc_store.rb +55 -6
  145. data/spec/tc_store_yaml.rb +71 -0
  146. data/spec/tc_template_amrita2.rb +3 -3
  147. data/spec/tc_template_erubis.rb +2 -3
  148. data/spec/{tc_template_ramaze.rb → tc_template_ezamar.rb} +15 -5
  149. data/spec/tc_template_haml.rb +4 -3
  150. data/spec/tc_template_liquid.rb +3 -4
  151. data/spec/tc_template_markaby.rb +4 -6
  152. data/spec/tc_tidy.rb +1 -3
  153. data/spec/template/amrita2/{data.html → data.amrita} +0 -0
  154. data/spec/template/amrita2/{index.html → index.amrita} +0 -0
  155. data/spec/template/amrita2/{sum.html → sum.amrita} +0 -0
  156. data/spec/template/ezamar/another/long/action.zmr +1 -0
  157. data/spec/template/ezamar/combined.zmr +1 -0
  158. data/spec/template/{ramaze/file_only.rmze → ezamar/file_only.zmr} +0 -0
  159. data/spec/template/{ramaze/index.rmze → ezamar/index.zmr} +0 -0
  160. data/spec/template/{ramaze/nested.rmze → ezamar/nested.zmr} +0 -0
  161. data/spec/template/ezamar/some__long__action.zmr +1 -0
  162. data/spec/template/{ramaze/sum.rmze → ezamar/sum.zmr} +0 -0
  163. metadata +181 -123
  164. data/doc/allison/LICENSE +0 -184
  165. data/doc/allison/README +0 -37
  166. data/doc/allison/allison.css +0 -300
  167. data/doc/allison/allison.gif +0 -0
  168. data/doc/allison/allison.js +0 -307
  169. data/doc/allison/allison.rb +0 -287
  170. data/doc/allison/cache/BODY +0 -588
  171. data/doc/allison/cache/CLASS_INDEX +0 -4
  172. data/doc/allison/cache/CLASS_PAGE +0 -1
  173. data/doc/allison/cache/FILE_INDEX +0 -4
  174. data/doc/allison/cache/FILE_PAGE +0 -1
  175. data/doc/allison/cache/FONTS +0 -1
  176. data/doc/allison/cache/FR_INDEX_BODY +0 -1
  177. data/doc/allison/cache/IMGPATH +0 -1
  178. data/doc/allison/cache/INDEX +0 -1
  179. data/doc/allison/cache/JAVASCRIPT +0 -307
  180. data/doc/allison/cache/METHOD_INDEX +0 -4
  181. data/doc/allison/cache/METHOD_LIST +0 -1
  182. data/doc/allison/cache/SRC_PAGE +0 -1
  183. data/doc/allison/cache/STYLE +0 -322
  184. data/doc/allison/cache/URL +0 -1
  185. data/doc/changes.txt +0 -2021
  186. data/doc/changes.xml +0 -2024
  187. data/lib/ramaze/snippets/kernel/silently.rb +0 -13
  188. data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +0 -11
  189. data/lib/ramaze/template/haml/actionview_stub.rb +0 -20
  190. data/lib/ramaze/template/ramaze.rb +0 -177
  191. data/lib/ramaze/template/ramaze/element.rb +0 -166
  192. data/lib/ramaze/template/ramaze/morpher.rb +0 -156
  193. data/spec/tc_test.rb +0 -17
@@ -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>
@@ -0,0 +1,7 @@
1
+ <Page title="New Task">
2
+ <a href="/">Back to TodoList</a>
3
+ <form method="POST" action="create">
4
+ Task: <input type="text" name="title" /><br />
5
+ <input type="submit" />
6
+ </form>
7
+ </Page>
@@ -0,0 +1,9 @@
1
+ ---
2
+ Wash dishes:
3
+ :done: false
4
+ foobar:
5
+ :done: false
6
+ Laundry:
7
+ :done: false
8
+ implement:
9
+ :done: false
@@ -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 < Template::Ramaze
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
- link( R(self, :show, CGI.escape($1)), :title => $1)
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
@@ -1,6 +1,10 @@
1
1
  <html>
2
2
  <head>
3
3
  <title>MicroWiki #{@page}</title>
4
+ <style>
5
+ a.exists{ color: #00f; }
6
+ a.nonexists{ color: #f00; }
7
+ </style>
4
8
  </head>
5
9
  #{ link(R(self), :title => "&lt; Home") unless @page == "Home" }
6
10
  <body>
@@ -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>
@@ -1,6 +1,7 @@
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
- class MainController < Template::Ramaze
3
+
4
+ class MainController < Controller
4
5
  def index
5
6
  "Hello, World"
6
7
  end
@@ -1,6 +1,7 @@
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
- class Page < Element
3
+
4
+ class Page < Ezamar::Element
4
5
  def render
5
6
  %{
6
7
  <html>
@@ -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
- Db = YAML::Store.new('yaml.db')
4
+ require 'ramaze/store/default'
5
+
6
+ Db = Ramaze::Store::Default.new('yaml.db')
@@ -17,16 +17,17 @@ require 'pp'
17
17
 
18
18
  require 'ramaze/snippets'
19
19
  require 'ramaze/cache'
20
- require 'ramaze/controller'
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/template'
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 *tasks
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 *tasks
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
+