ramaze 0.3.5 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -20
- data/bin/ramaze +0 -4
- data/doc/AUTHORS +5 -0
- data/doc/meta/announcement.txt +2 -1
- data/doc/tutorial/todolist.html +20 -21
- data/doc/tutorial/todolist.mkd +10 -9
- data/examples/blog/{src/controller.rb → controller/main.rb} +2 -0
- data/examples/blog/{src/model.rb → model/entry.rb} +0 -0
- data/examples/blog/spec/blog.rb +3 -3
- data/examples/blog/start.rb +2 -3
- data/examples/blog/view/edit.xhtml +17 -0
- data/examples/blog/view/index.xhtml +17 -0
- data/examples/blog/view/layout.xhtml +11 -0
- data/examples/blog/view/new.xhtml +16 -0
- data/examples/facebook.rb +15 -8
- data/examples/identity.rb +1 -1
- data/examples/memleak_detector.rb +1 -1
- data/examples/rammit/src/model.rb +1 -1
- data/examples/rapaste/controller/paste.rb +7 -7
- data/examples/rapaste/model/paste.rb +1 -3
- data/examples/rapaste/public/css/display.css +2 -1
- data/examples/rapaste/start.rb +2 -3
- data/examples/sourceview/sourceview.rb +1 -1
- data/examples/templates/template/external.tenjin +28 -0
- data/examples/templates/template_amrita2.rb +0 -3
- data/examples/templates/template_tenjin.rb +57 -0
- data/examples/todolist/spec/todolist.rb +13 -2
- data/examples/todolist/src/controller/main.rb +1 -1
- data/examples/todolist/template/index.xhtml +1 -1
- data/examples/wiktacular/spec/wiktacular.rb +18 -0
- data/examples/wiktacular/src/controller.rb +2 -2
- data/examples/wiktacular/src/model.rb +8 -2
- data/lib/proto/public/css/ramaze_error.css +4 -0
- data/lib/proto/public/dispatch.fcgi +11 -0
- data/lib/proto/spec/main.rb +1 -1
- data/lib/proto/start.ru +8 -0
- data/lib/proto/view/error.xhtml +2 -0
- data/lib/ramaze.rb +28 -5
- data/lib/ramaze/action.rb +9 -2
- data/lib/ramaze/action/render.rb +40 -24
- data/lib/ramaze/adapter.rb +10 -17
- data/lib/ramaze/adapter/base.rb +8 -12
- data/lib/ramaze/adapter/cgi.rb +14 -13
- data/lib/ramaze/adapter/ebb.rb +34 -0
- data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
- data/lib/ramaze/adapter/fcgi.rb +14 -14
- data/lib/ramaze/adapter/lsws.rb +15 -11
- data/lib/ramaze/adapter/mongrel.rb +2 -1
- data/lib/ramaze/adapter/scgi.rb +24 -0
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
- data/lib/ramaze/adapter/thin.rb +4 -5
- data/lib/ramaze/adapter/webrick.rb +5 -5
- data/lib/ramaze/cache.rb +1 -1
- data/lib/ramaze/cache/memcached.rb +1 -1
- data/lib/ramaze/contrib.rb +70 -10
- data/lib/ramaze/contrib/auto_params.rb +1 -1
- data/lib/ramaze/contrib/email.rb +15 -15
- data/lib/ramaze/contrib/facebook.rb +2 -2
- data/lib/ramaze/contrib/facebook/facebook.rb +7 -4
- data/lib/ramaze/contrib/file_cache.rb +65 -0
- data/lib/ramaze/contrib/gettext.rb +56 -55
- data/lib/ramaze/contrib/profiling.rb +36 -0
- data/lib/ramaze/contrib/sequel_cache.rb +92 -0
- data/lib/ramaze/controller.rb +80 -47
- data/lib/ramaze/controller/error.rb +10 -5
- data/lib/ramaze/controller/resolve.rb +36 -48
- data/lib/ramaze/current.rb +70 -0
- data/lib/ramaze/{trinity → current}/request.rb +62 -15
- data/lib/ramaze/current/response.rb +19 -0
- data/lib/ramaze/{trinity → current}/session.rb +32 -110
- data/lib/ramaze/current/session/flash.rb +67 -0
- data/lib/ramaze/current/session/hash.rb +65 -0
- data/lib/ramaze/dispatcher.rb +1 -28
- data/lib/ramaze/dispatcher/action.rb +6 -3
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +26 -5
- data/lib/ramaze/dispatcher/file.rb +13 -2
- data/lib/ramaze/gestalt.rb +3 -1
- data/lib/ramaze/global.rb +6 -3
- data/lib/ramaze/global/globalstruct.rb +3 -1
- data/lib/ramaze/helper.rb +66 -20
- data/lib/ramaze/helper/aspect.rb +25 -17
- data/lib/ramaze/helper/auth.rb +4 -3
- data/lib/ramaze/helper/cache.rb +5 -4
- data/lib/ramaze/helper/cgi.rb +11 -9
- data/lib/ramaze/helper/flash.rb +28 -3
- data/lib/ramaze/helper/formatting.rb +1 -3
- data/lib/ramaze/helper/identity.rb +2 -3
- data/lib/ramaze/helper/inform.rb +7 -6
- data/lib/ramaze/helper/link.rb +15 -17
- data/lib/ramaze/helper/markaby.rb +2 -4
- data/lib/ramaze/helper/maruku.rb +1 -1
- data/lib/ramaze/helper/nitroform.rb +4 -4
- data/lib/ramaze/helper/pager.rb +4 -6
- data/lib/ramaze/helper/partial.rb +24 -21
- data/lib/ramaze/helper/redirect.rb +8 -5
- data/lib/ramaze/helper/{file.rb → sendfile.rb} +1 -3
- data/lib/ramaze/helper/sequel.rb +1 -3
- data/lib/ramaze/helper/stack.rb +1 -3
- data/lib/ramaze/helper/tagz.rb +19 -0
- data/lib/ramaze/helper/user.rb +63 -0
- data/lib/ramaze/inform.rb +2 -24
- data/lib/ramaze/log.rb +28 -0
- data/lib/ramaze/{inform → log}/analogger.rb +3 -3
- data/lib/ramaze/{inform → log}/growl.rb +2 -2
- data/lib/ramaze/{inform → log}/hub.rb +4 -6
- data/lib/ramaze/{inform → log}/informer.rb +4 -4
- data/lib/ramaze/{inform → log}/knotify.rb +2 -2
- data/lib/ramaze/log/logger.rb +22 -0
- data/lib/ramaze/{inform/informing.rb → log/logging.rb} +16 -16
- data/lib/ramaze/{inform → log}/syslog.rb +0 -0
- data/lib/ramaze/{inform → log}/xosd.rb +2 -2
- data/lib/ramaze/route.rb +64 -36
- data/lib/ramaze/snippets/array/put_within.rb +13 -0
- data/lib/ramaze/snippets/binding/locals.rb +13 -0
- data/lib/ramaze/snippets/kernel/__dir__.rb +10 -8
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
- data/lib/ramaze/snippets/kernel/constant.rb +1 -1
- data/lib/ramaze/snippets/object/pretty.rb +6 -0
- data/lib/ramaze/snippets/object/scope.rb +11 -0
- data/lib/ramaze/snippets/object/thread_accessor.rb +5 -0
- data/lib/ramaze/snippets/ordered_set.rb +1 -1
- data/lib/ramaze/snippets/proc/locals.rb +11 -0
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +44 -0
- data/lib/ramaze/snippets/string/esc.rb +29 -0
- data/lib/ramaze/snippets/string/start_with.rb +7 -0
- data/lib/ramaze/snippets/string/unindent.rb +6 -1
- data/lib/ramaze/snippets/struct/values_at.rb +1 -5
- data/lib/ramaze/sourcereload.rb +16 -14
- data/lib/ramaze/spec.rb +1 -0
- data/lib/ramaze/spec/helper.rb +11 -3
- data/lib/ramaze/spec/helper/browser.rb +25 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +11 -11
- data/lib/ramaze/template.rb +5 -4
- data/lib/ramaze/template/amrita2.rb +2 -3
- data/lib/ramaze/template/ezamar/element.rb +2 -3
- data/lib/ramaze/template/ezamar/morpher.rb +1 -2
- data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
- data/lib/ramaze/template/haml.rb +5 -2
- data/lib/ramaze/template/markaby.rb +2 -0
- data/lib/ramaze/template/tagz.rb +79 -0
- data/lib/ramaze/template/tenjin.rb +34 -0
- data/lib/ramaze/tool/create.rb +0 -3
- data/lib/ramaze/tool/localize.rb +107 -105
- data/lib/ramaze/tool/mime.rb +0 -2
- data/lib/ramaze/trinity.rb +1 -26
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +47 -41
- data/rake_tasks/conf.rake +18 -0
- data/rake_tasks/darcs.rake +5 -0
- data/rake_tasks/maintenance.rake +37 -24
- data/rake_tasks/spec.rake +1 -1
- data/spec/contrib/auto_params.rb +3 -1
- data/spec/contrib/profiling.rb +26 -0
- data/spec/examples/templates/template_redcloth.rb +1 -1
- data/spec/examples/templates/template_tenjin.rb +28 -0
- data/spec/helper.rb +0 -1
- data/spec/ramaze/action/layout.rb +28 -0
- data/spec/ramaze/controller/actionless_templates.rb +32 -0
- data/spec/ramaze/controller/template/other_wrapper.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +37 -0
- data/spec/ramaze/{trinity → current}/request.rb +12 -2
- data/spec/ramaze/current/session.rb +97 -0
- data/spec/ramaze/dispatcher/directory.rb +2 -1
- data/spec/ramaze/dispatcher/file.rb +8 -3
- data/spec/ramaze/dispatcher/public/file name.txt +1 -0
- data/spec/ramaze/gestalt.rb +11 -0
- data/spec/ramaze/helper/aspect.rb +28 -22
- data/spec/ramaze/helper/cgi.rb +2 -2
- data/spec/ramaze/helper/flash.rb +33 -15
- data/spec/ramaze/helper/formatting.rb +2 -2
- data/spec/ramaze/helper/link.rb +46 -18
- data/spec/ramaze/helper/pager.rb +8 -5
- data/spec/ramaze/helper/partial.rb +8 -1
- data/spec/ramaze/helper/template/recursive_local_ivars.xhtml +7 -0
- data/spec/ramaze/helper/user.rb +46 -0
- data/spec/ramaze/{inform → log}/informer.rb +0 -0
- data/spec/ramaze/{inform → log}/syslog.rb +1 -1
- data/spec/ramaze/request.rb +14 -10
- data/spec/ramaze/route.rb +23 -0
- data/spec/ramaze/template.rb +48 -1
- data/spec/ramaze/template/haml.rb +6 -16
- data/spec/ramaze/template/haml/locals.haml +2 -1
- data/spec/ramaze/template/tagz.rb +62 -0
- data/spec/ramaze/template/tagz/external.tagz +8 -0
- data/spec/ramaze/template/tagz/sum.tagz +1 -0
- data/spec/ramaze/template/tenjin.rb +49 -0
- data/spec/ramaze/template/tenjin/external.tenjin +1 -0
- data/spec/snippets/string/unindent.rb +15 -0
- metadata +509 -475
- data/doc/README.html +0 -729
- data/doc/changes.txt +0 -5757
- data/doc/changes.xml +0 -5759
- data/examples/blog/src/view.rb +0 -16
- data/examples/blog/template/edit.xhtml +0 -19
- data/examples/blog/template/index.xhtml +0 -19
- data/examples/blog/template/new.xhtml +0 -18
- data/examples/wiktacular/mkd/newpagename/current.mkd +0 -1
- data/examples/wiktacular/mkd/newpagename/current.mkd.bak +0 -1
- data/lib/ramaze/contrib/email.rb-darcs-backup0 +0 -81
- data/lib/ramaze/template/bijou.rb +0 -39
- data/lib/ramaze/trinity/response.rb +0 -32
- data/spec/ramaze/template/bijou.rb +0 -25
- data/spec/ramaze/trinity/session.rb +0 -29
data/lib/ramaze/action.rb
CHANGED
@@ -15,8 +15,11 @@ module Ramaze
|
|
15
15
|
end
|
16
16
|
|
17
17
|
require 'ramaze/action/render'
|
18
|
+
require 'ramaze/helper/link'
|
18
19
|
|
19
20
|
class Action
|
21
|
+
include Helper::Link
|
22
|
+
|
20
23
|
class << self
|
21
24
|
|
22
25
|
# Instantiate with given Hash, takes both string/symbol keys.
|
@@ -30,10 +33,14 @@ module Ramaze
|
|
30
33
|
i
|
31
34
|
end
|
32
35
|
|
33
|
-
#
|
36
|
+
# alias for stack.last, returns the instance of Action you are currently in.
|
34
37
|
|
35
38
|
def current
|
36
|
-
|
39
|
+
stack.last
|
40
|
+
end
|
41
|
+
|
42
|
+
def stack
|
43
|
+
Thread.current[:action_stack] ||= []
|
37
44
|
end
|
38
45
|
end
|
39
46
|
|
data/lib/ramaze/action/render.rb
CHANGED
@@ -4,6 +4,16 @@
|
|
4
4
|
module Ramaze
|
5
5
|
class Action
|
6
6
|
|
7
|
+
def stack
|
8
|
+
Action.stack << self
|
9
|
+
yield self
|
10
|
+
rescue Object => ex
|
11
|
+
Log.error "#{ex} in: #{self}"
|
12
|
+
raise ex
|
13
|
+
ensure
|
14
|
+
Action.stack.pop
|
15
|
+
end
|
16
|
+
|
7
17
|
# Render this instance of Action, this will (eventually) pass itself to
|
8
18
|
# Action#engine.transform
|
9
19
|
# Usage, given that Foo is a Controller and has the method/template
|
@@ -12,13 +22,14 @@ module Ramaze
|
|
12
22
|
# #> 'bar'
|
13
23
|
|
14
24
|
def render
|
15
|
-
|
16
|
-
Thread.current[:action] = self
|
25
|
+
Log.dev("Action: #{self}")
|
17
26
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
stack do
|
28
|
+
if should_cache?
|
29
|
+
cached_render
|
30
|
+
else
|
31
|
+
uncached_render
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
@@ -62,10 +73,10 @@ module Ramaze
|
|
62
73
|
end
|
63
74
|
|
64
75
|
if cache.size > 0 and (cache_opts[:ttl].nil? or cache[:time] + cache_opts[:ttl] > Time.now)
|
65
|
-
|
76
|
+
Log.debug("Using Cached version")
|
66
77
|
Response.current['Content-Type'] = cache[:type]
|
67
78
|
else
|
68
|
-
|
79
|
+
Log.debug("Compiling Action")
|
69
80
|
cache.replace({ :time => Time.now, :content => uncached_render, :type => Response.current['Content-Type'] })
|
70
81
|
end
|
71
82
|
|
@@ -77,9 +88,9 @@ module Ramaze
|
|
77
88
|
# Layout will be found and rendered in this step after self was rendered.
|
78
89
|
|
79
90
|
def uncached_render
|
80
|
-
|
81
|
-
|
82
|
-
|
91
|
+
before_process
|
92
|
+
|
93
|
+
content = engine.transform(self)
|
83
94
|
|
84
95
|
if path and tlayout = layout
|
85
96
|
[instance, tlayout.instance].each do |i|
|
@@ -87,34 +98,39 @@ module Ramaze
|
|
87
98
|
end
|
88
99
|
|
89
100
|
content = tlayout.render
|
90
|
-
|
91
|
-
# restore Action.current after render above
|
92
|
-
Thread.current[:action] = self
|
93
101
|
end
|
94
102
|
|
95
103
|
content
|
104
|
+
|
105
|
+
ensure
|
106
|
+
after_process unless $!
|
96
107
|
end
|
97
108
|
|
98
109
|
# Determine whether or not we have a layout to process and sets it up
|
99
|
-
# correctly to be rendered in the same context as current action.
|
100
|
-
#
|
101
|
-
# infinite recursion and also if no layout on this controller
|
110
|
+
# correctly to be rendered in the same context as current action. Will
|
111
|
+
# return false if the layout is the same as current action to avoid
|
112
|
+
# infinite recursion and also if no layout on this controller or its
|
113
|
+
# ancestors was found.
|
102
114
|
|
103
115
|
def layout
|
104
|
-
return false unless layouts = controller.
|
116
|
+
return false unless layouts = controller.ancestral_trait[:layout]
|
105
117
|
|
106
|
-
possible = [layouts[
|
118
|
+
possible = [layouts[path], layouts[:all]].compact
|
107
119
|
denied = layouts[:deny].to_a
|
108
120
|
|
109
121
|
if layout = possible.first
|
110
|
-
|
111
|
-
|
112
|
-
if denied.include?(path) or layout_action.path == path
|
113
|
-
return false
|
122
|
+
if layout.to_s !~ /\A\// # late bind layout action to current controller
|
123
|
+
layout = R(controller, layout)
|
114
124
|
end
|
125
|
+
layout_action = Controller.resolve(layout)
|
126
|
+
|
127
|
+
return false if denied.any?{|deny| deny === path} or layout_action.path == path
|
115
128
|
|
116
|
-
|
129
|
+
if layout_action.controller != controller
|
117
130
|
instance.instance_variables.each do |x|
|
131
|
+
if layout_action.instance.instance_variable_defined?(x)
|
132
|
+
Log.warn "overwriting instance variable #{x} from layout controller with instance variable from action controller."
|
133
|
+
end
|
118
134
|
layout_action.instance.instance_variable_set(x, instance.instance_variable_get(x))
|
119
135
|
end
|
120
136
|
else
|
data/lib/ramaze/adapter.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'socket'
|
5
|
-
require 'timeout'
|
6
|
-
require 'benchmark'
|
7
|
-
|
8
|
-
require 'rack'
|
9
|
-
require 'rack/utils'
|
10
|
-
|
11
4
|
require 'ramaze/trinity'
|
12
5
|
require 'ramaze/tool/record'
|
13
6
|
require 'ramaze/adapter/base'
|
@@ -47,7 +40,7 @@ module Ramaze
|
|
47
40
|
rescue SystemExit
|
48
41
|
Ramaze.shutdown
|
49
42
|
rescue Object => ex
|
50
|
-
|
43
|
+
Log.error(ex)
|
51
44
|
Ramaze.shutdown
|
52
45
|
end
|
53
46
|
|
@@ -61,17 +54,19 @@ module Ramaze
|
|
61
54
|
if adapter = Global.adapter
|
62
55
|
host, ports = Global.host, Global.ports
|
63
56
|
|
64
|
-
|
65
|
-
|
57
|
+
if Global.test_connections
|
58
|
+
Log.info("Adapter: #{adapter}, testing connection to #{host}:#{ports}")
|
59
|
+
test_connections(host, ports)
|
60
|
+
Log.info("and we're running: #{host}:#{ports}")
|
61
|
+
end
|
66
62
|
|
67
|
-
Inform.info("and we're running: #{host}:#{ports}")
|
68
63
|
adapter.start(host, ports)
|
69
64
|
else # run dummy
|
70
65
|
Global.adapters.add Thread.new{ sleep }
|
71
|
-
|
66
|
+
Log.warn("Seems like Global.adapter is turned off", "Continue without adapter.")
|
72
67
|
end
|
73
68
|
rescue LoadError => ex
|
74
|
-
|
69
|
+
Log.warn(ex, "Continue without adapter.")
|
75
70
|
end
|
76
71
|
|
77
72
|
# Calls ::shutdown on all running adapters and waits up to 1 second for
|
@@ -94,11 +89,9 @@ module Ramaze
|
|
94
89
|
# Shuts down if no connection is possible.
|
95
90
|
|
96
91
|
def test_connections host, ports
|
97
|
-
return unless Global.test_connections
|
98
|
-
|
99
92
|
ports.each do |port|
|
100
93
|
unless test_connection(host, port)
|
101
|
-
|
94
|
+
Log.error("Cannot open connection on #{host}:#{port}")
|
102
95
|
Ramaze.shutdown
|
103
96
|
end
|
104
97
|
end
|
@@ -114,7 +107,7 @@ module Ramaze
|
|
114
107
|
true
|
115
108
|
end
|
116
109
|
rescue => ex
|
117
|
-
|
110
|
+
Log.error(ex)
|
118
111
|
false
|
119
112
|
end
|
120
113
|
end
|
data/lib/ramaze/adapter/base.rb
CHANGED
@@ -24,7 +24,7 @@ module Ramaze
|
|
24
24
|
# Does nothing
|
25
25
|
|
26
26
|
def stop
|
27
|
-
|
27
|
+
Log.debug("Stopping #{self.class}")
|
28
28
|
end
|
29
29
|
|
30
30
|
# This is called by Rack with the usual env, subsequently calls
|
@@ -34,14 +34,14 @@ module Ramaze
|
|
34
34
|
# calls .finish on the current response after ::respond has finished.
|
35
35
|
|
36
36
|
def call(env)
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
returned = nil
|
38
|
+
if Global.benchmarking
|
39
|
+
time = Benchmark.measure{ returned = respond(env) }
|
40
|
+
Log.debug('request took %.5fs [~%.0f r/s]' % [time.real, 1.0/time.real])
|
40
41
|
else
|
41
|
-
respond env
|
42
|
+
returned = respond env
|
42
43
|
end
|
43
|
-
|
44
|
-
Thread.current[:response].finish
|
44
|
+
returned
|
45
45
|
end
|
46
46
|
|
47
47
|
# Initializes Request with env and an empty Response. Records the
|
@@ -49,11 +49,7 @@ module Ramaze
|
|
49
49
|
# Then goes on and calls Dispatcher::handle with request and response.
|
50
50
|
|
51
51
|
def respond env
|
52
|
-
|
53
|
-
if filter = Global.record
|
54
|
-
Record << request if filter[request]
|
55
|
-
end
|
56
|
-
Dispatcher.handle(request, response)
|
52
|
+
Current.call env
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
data/lib/ramaze/adapter/cgi.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
|
4
|
+
module Ramaze
|
5
|
+
Global.test_connections = false
|
5
6
|
|
6
|
-
module
|
7
|
+
module Adapter
|
8
|
+
# Our CGI adapter acts as wrapper for the Rack::Handler::CGI.
|
9
|
+
class Cgi < Base
|
10
|
+
class << self
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Thread.new do
|
17
|
-
Thread.current[:task] = :cgi
|
18
|
-
Rack::Handler::CGI.run(self)
|
12
|
+
# start CGI in a new thread, host and port parameter are only taken
|
13
|
+
# to make it compatible with other adapters but have no influence and
|
14
|
+
# can be omitted
|
15
|
+
def start host = nil, ports = nil
|
16
|
+
Thread.new do
|
17
|
+
Thread.current[:task] = :cgi
|
18
|
+
Rack::Handler::CGI.run(self)
|
19
|
+
end
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'ebb'
|
2
|
+
|
3
|
+
module Ramaze
|
4
|
+
Global.test_connections = true
|
5
|
+
|
6
|
+
module Adapter
|
7
|
+
class Ebb < Base
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# start server on given host and port.
|
11
|
+
def run_server host, port
|
12
|
+
server = ::Ebb::Server.new(self, :port => port)
|
13
|
+
|
14
|
+
thread = Thread.new{ server.start }
|
15
|
+
thread[:adapter] = server
|
16
|
+
thread
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Response
|
23
|
+
def finish(&block)
|
24
|
+
@block = block
|
25
|
+
|
26
|
+
if [201, 204, 304].include?(status.to_i)
|
27
|
+
header.delete "Content-Type"
|
28
|
+
[status.to_i, header.to_hash, '']
|
29
|
+
else
|
30
|
+
[status.to_i, header.to_hash, [body].flatten.join]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
Ramaze::
|
4
|
+
Ramaze::Log.debug "Using Evented Mongrel"
|
5
5
|
|
6
6
|
require 'swiftcore/evented_mongrel'
|
7
7
|
require 'ramaze/adapter/mongrel'
|
data/lib/ramaze/adapter/fcgi.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
|
4
|
+
module Ramaze
|
5
|
+
Global.test_connections = false
|
5
6
|
|
6
|
-
module
|
7
|
+
module Adapter
|
8
|
+
# Our Fcgi adapter acts as wrapper for the Rack::Handler::FastCGI.
|
9
|
+
class Fcgi < Base
|
10
|
+
class << self
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Thread.new do
|
17
|
-
Thread.current[:task] = :cgi
|
18
|
-
Rack::Handler::FastCGI.run(self)
|
12
|
+
# start FastCGI in a new thread, host and port parameter are only taken
|
13
|
+
# to make it compatible with other adapters but have no influence and
|
14
|
+
# can be omitted
|
15
|
+
def run_server host = nil, ports = nil
|
16
|
+
Thread.new do
|
17
|
+
Thread.current[:task] = :cgi
|
18
|
+
Rack::Handler::FastCGI.run(self)
|
19
|
+
end
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
24
|
-
|
data/lib/ramaze/adapter/lsws.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
2
3
|
|
3
|
-
module Ramaze
|
4
|
+
module Ramaze
|
5
|
+
Global.test_connections = false
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
class
|
7
|
+
module Adapter
|
8
|
+
# Our Lsws adapter acts as wrapper for the Rack::Handler::LSWS.
|
9
|
+
class Lsws < Base
|
10
|
+
class << self
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# start Lsws in a new thread, host and port parameter are only taken
|
13
|
+
# to make it compatible with other adapters but have no influence and
|
14
|
+
# can be omitted
|
15
|
+
def run_server host = nil, ports = nil
|
16
|
+
Thread.new do
|
17
|
+
Rack::Handler::LSWS.run(self)
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -2,10 +2,11 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
require 'mongrel'
|
5
|
-
require 'ramaze/adapter'
|
6
5
|
require 'rack/handler/mongrel'
|
7
6
|
|
8
7
|
module Ramaze
|
8
|
+
Global.test_connections = true
|
9
|
+
|
9
10
|
module Adapter
|
10
11
|
|
11
12
|
# Our Mongrel adapter acts as wrapper for the Rack::Handler::Mongrel.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright (c) 2008 Jeremy Evans code@jeremyevans.net
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'rack/handler/scgi'
|
5
|
+
|
6
|
+
module Ramaze
|
7
|
+
Global.test_connections = true
|
8
|
+
|
9
|
+
module Adapter
|
10
|
+
# Our Scgi adapter acts as wrapper for the Rack::Handler::SCGI.
|
11
|
+
class Scgi < Base
|
12
|
+
class << self
|
13
|
+
|
14
|
+
# start SCGI in a new thread
|
15
|
+
def run_server host, port
|
16
|
+
Thread.new do
|
17
|
+
Thread.current[:task] = :cgi
|
18
|
+
Rack::Handler::SCGI.run(self, :Host=>host, :Port=>port)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|