ramaze 2008.06 → 2008.11
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.markdown +6 -6
- data/Rakefile +33 -3
- data/bin/ramaze +18 -0
- data/doc/CHANGELOG +960 -0
- data/doc/LEGAL +5 -1
- data/doc/meta/announcement.txt +20 -36
- data/doc/tutorial/todolist.html +421 -313
- data/doc/tutorial/todolist.mkd +33 -16
- data/examples/app/blog/spec/blog.rb +3 -3
- data/examples/app/rapaste/controller/paste.rb +8 -1
- data/examples/app/rapaste/model/paste.rb +3 -0
- data/examples/app/rapaste/spec/rapaste.rb +3 -1
- data/examples/app/rapaste/start.rb +3 -2
- data/examples/app/sourceview/public/sourceview.js +2 -2
- data/examples/app/todolist/spec/todolist.rb +6 -6
- data/examples/app/todolist/template/index.xhtml +1 -1
- data/examples/app/whywiki/spec/whywiki.rb +2 -2
- data/examples/app/wikore/spec/wikore.rb +2 -2
- data/examples/app/wikore/src/model.rb +4 -3
- data/examples/app/wiktacular/spec/wiktacular.rb +7 -7
- data/examples/basic/simple.rb +2 -2
- data/examples/helpers/paginate.rb +71 -0
- data/examples/misc/simple_auth.rb +20 -8
- data/lib/proto/controller/init.rb +10 -0
- data/lib/proto/controller/main.rb +1 -3
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/dispatch.fcgi +1 -1
- data/lib/proto/spec/main.rb +2 -1
- data/lib/proto/start.rb +3 -3
- data/lib/proto/start.ru +1 -1
- data/lib/proto/view/error.xhtml +4 -4
- data/lib/ramaze.rb +8 -3
- data/lib/ramaze/action.rb +6 -6
- data/lib/ramaze/adapter.rb +1 -6
- data/lib/ramaze/adapter/base.rb +30 -27
- data/lib/ramaze/adapter/cgi.rb +1 -0
- data/lib/ramaze/cache.rb +1 -3
- data/lib/ramaze/cache/memcached.rb +3 -5
- data/lib/ramaze/contrib/auto_params.rb +2 -2
- data/lib/ramaze/contrib/auto_params/get_args.rb +2 -1
- data/lib/ramaze/contrib/gems.rb +17 -18
- data/lib/ramaze/contrib/gzip_filter.rb +22 -9
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +1 -1
- data/lib/ramaze/contrib/rest.rb +16 -13
- data/lib/ramaze/contrib/sequel/create_join.rb +25 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +198 -0
- data/lib/ramaze/contrib/sequel/relation.rb +82 -0
- data/lib/ramaze/controller.rb +33 -34
- data/lib/ramaze/controller/resolve.rb +29 -9
- data/lib/ramaze/current.rb +60 -20
- data/lib/ramaze/current/request.rb +8 -7
- data/lib/ramaze/current/response.rb +15 -3
- data/lib/ramaze/current/session/flash.rb +8 -0
- data/lib/ramaze/dispatcher.rb +17 -9
- data/lib/ramaze/dispatcher/action.rb +4 -5
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +4 -4
- data/lib/ramaze/dispatcher/file.rb +4 -4
- data/lib/ramaze/gestalt.rb +15 -20
- data/lib/ramaze/helper/cgi.rb +7 -15
- data/lib/ramaze/helper/formatting.rb +41 -1
- data/lib/ramaze/helper/httpdigest.rb +20 -7
- data/lib/ramaze/helper/link.rb +4 -6
- data/lib/ramaze/helper/paginate.rb +233 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/helper/rest.rb +1 -1
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +44 -0
- data/lib/ramaze/helper/user.rb +4 -9
- data/lib/ramaze/log.rb +2 -2
- data/lib/ramaze/log/analogger.rb +21 -23
- data/lib/ramaze/log/growl.rb +21 -23
- data/lib/ramaze/log/hub.rb +1 -1
- data/lib/ramaze/log/informer.rb +97 -99
- data/lib/ramaze/log/knotify.rb +14 -16
- data/lib/ramaze/log/logger.rb +11 -13
- data/lib/ramaze/log/logging.rb +61 -63
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/log/syslog.rb +41 -31
- data/lib/ramaze/log/xosd.rb +70 -72
- data/lib/ramaze/option.rb +9 -6
- data/lib/ramaze/option/holder.rb +5 -27
- data/lib/ramaze/reloader.rb +186 -0
- data/lib/ramaze/setup.rb +1 -1
- data/lib/ramaze/snippets.rb +13 -0
- data/lib/ramaze/snippets/array/put_within.rb +31 -24
- data/lib/ramaze/snippets/binding/locals.rb +23 -11
- data/lib/ramaze/snippets/dictionary.rb +2 -2
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/constant.rb +36 -21
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +12 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +24 -17
- data/lib/ramaze/snippets/numeric/time.rb +63 -0
- data/lib/ramaze/snippets/object/__dir__.rb +29 -0
- data/lib/ramaze/snippets/object/acquire.rb +40 -0
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +16 -5
- data/lib/ramaze/snippets/object/pretty.rb +14 -4
- data/lib/ramaze/snippets/object/scope.rb +14 -7
- data/lib/ramaze/snippets/ordered_set.rb +25 -14
- data/lib/ramaze/snippets/proc/locals.rb +17 -9
- data/lib/ramaze/snippets/ramaze/deprecated.rb +13 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/state.rb +86 -0
- data/lib/ramaze/snippets/ramaze/struct.rb +45 -0
- data/lib/ramaze/snippets/string/camel_case.rb +13 -8
- data/lib/ramaze/snippets/string/color.rb +24 -20
- data/lib/ramaze/snippets/string/each.rb +14 -3
- data/lib/ramaze/snippets/string/end_with.rb +20 -0
- data/lib/ramaze/snippets/string/esc.rb +26 -21
- data/lib/ramaze/snippets/string/ord.rb +12 -6
- data/lib/ramaze/snippets/string/snake_case.rb +13 -7
- data/lib/ramaze/snippets/string/start_with.rb +16 -5
- data/lib/ramaze/snippets/string/unindent.rb +23 -15
- data/lib/ramaze/snippets/thread/into.rb +3 -3
- data/lib/ramaze/spec/helper/bacon.rb +5 -5
- data/lib/ramaze/spec/helper/mock_http.rb +1 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +2 -2
- data/lib/ramaze/spec/helper/snippets.rb +8 -0
- data/lib/ramaze/template.rb +4 -1
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/template/maruku.rb +34 -0
- data/lib/ramaze/template/tagz.rb +2 -2
- data/lib/ramaze/template/xslt.rb +2 -2
- data/lib/ramaze/tool/create.rb +27 -53
- data/lib/ramaze/tool/localize.rb +8 -4
- data/lib/ramaze/tool/mime.rb +11 -1
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/trinity.rb +4 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/gem.rake +10 -1
- data/rake_tasks/maintenance.rake +40 -2
- data/rake_tasks/metric.rake +24 -0
- data/rake_tasks/release.rake +17 -4
- data/rake_tasks/spec.rake +1 -2
- data/ramaze.gemspec +549 -495
- data/spec/contrib/auto_params.rb +3 -3
- data/spec/contrib/profiling.rb +2 -2
- data/spec/examples/simple_auth.rb +2 -2
- data/spec/examples/templates/template_haml.rb +0 -2
- data/spec/ramaze/action/file_cache.rb +22 -0
- data/spec/ramaze/adapter.rb +2 -2
- data/spec/ramaze/controller/actionless_templates.rb +1 -1
- data/spec/ramaze/controller/subclass.rb +15 -0
- data/spec/ramaze/controller/template_resolving.rb +1 -1
- data/spec/ramaze/controller/view/bar.xhtml +1 -0
- data/spec/ramaze/controller/view/base/another.xhtml +1 -0
- data/spec/ramaze/current/session.rb +1 -1
- data/spec/ramaze/dispatcher/file.rb +2 -2
- data/spec/ramaze/helper/aspect.rb +26 -17
- data/spec/ramaze/helper/formatting.rb +13 -0
- data/spec/ramaze/log/informer.rb +10 -10
- data/spec/ramaze/log/syslog.rb +67 -4
- data/spec/ramaze/rewrite.rb +1 -1
- data/spec/ramaze/route.rb +1 -1
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/tagz.rb +1 -1
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/{kernel → object}/__dir__.rb +0 -0
- data/spec/snippets/{kernel → object}/acquire.rb +0 -0
- metadata +90 -81
- data/cache.yaml +0 -7
- data/examples/app/rammit/spec/rammit.rb +0 -31
- data/examples/app/rammit/src/controller/main.rb +0 -3
- data/examples/app/rammit/src/controller/page.rb +0 -16
- data/examples/app/rammit/src/model.rb +0 -33
- data/examples/app/rammit/start.rb +0 -8
- data/examples/app/rammit/template/index.xhtml +0 -14
- data/examples/app/rammit/template/page/view.xhtml +0 -4
- data/lib/ramaze/snippets/kernel/__dir__.rb +0 -23
- data/lib/ramaze/snippets/kernel/acquire.rb +0 -34
- data/lib/ramaze/snippets/object/thread_accessor.rb +0 -5
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +0 -58
- data/lib/ramaze/snippets/struct/fill.rb +0 -23
- data/lib/ramaze/snippets/struct/values_at.rb +0 -39
- data/lib/ramaze/snippets/symbol/to_proc.rb +0 -24
- data/lib/ramaze/sourcereload.rb +0 -176
- data/spec/snippets/struct/fill.rb +0 -26
- data/spec/snippets/struct/values_at.rb +0 -52
- data/spec/snippets/symbol/to_proc.rb +0 -13
data/examples/basic/simple.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'ramaze'
|
3
|
+
|
4
|
+
USERS = DATA.read.split("\n")
|
5
|
+
|
6
|
+
class MainController < Ramaze::Controller
|
7
|
+
helper :paginate
|
8
|
+
|
9
|
+
trait :paginate => {
|
10
|
+
:limit => 6,
|
11
|
+
:var => 'user_page',
|
12
|
+
}
|
13
|
+
|
14
|
+
def index
|
15
|
+
@pager = paginate(USERS)
|
16
|
+
%q~
|
17
|
+
<html>
|
18
|
+
|
19
|
+
<head><title>Users</title></head>
|
20
|
+
<body>
|
21
|
+
#{@pager.navigation if @pager.needed?}
|
22
|
+
<pre>
|
23
|
+
<?r @pager.each do |user| ?>
|
24
|
+
#{user}
|
25
|
+
<?r end ?>
|
26
|
+
</pre>
|
27
|
+
#{@pager.navigation if @pager.needed?}
|
28
|
+
</body>
|
29
|
+
</html>
|
30
|
+
~
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Ramaze.start
|
35
|
+
|
36
|
+
__END__
|
37
|
+
Michael Fellinger 1868 [ 77.13% ]
|
38
|
+
Aman Gupta 211 [ 8.71% ]
|
39
|
+
Jonathan Buch 89 [ 3.67% ]
|
40
|
+
Gabriele Renzi 49 [ 2.02% ]
|
41
|
+
Ara T. Howard 44 [ 1.82% ]
|
42
|
+
Clive Crous 37 [ 1.53% ]
|
43
|
+
Keita Yamaguchi 27 [ 1.11% ]
|
44
|
+
Ryan Grove 17 [ 0.70% ]
|
45
|
+
Pistos 16 [ 0.66% ]
|
46
|
+
Wang, Jinjing 11 [ 0.45% ]
|
47
|
+
Colin Shea 9 [ 0.37% ]
|
48
|
+
Sam Carr 6 [ 0.25% ]
|
49
|
+
Stephan Maka 5 [ 0.21% ]
|
50
|
+
samcarr 4 [ 0.17% ]
|
51
|
+
raggi 3 [ 0.12% ]
|
52
|
+
Clinton R. Nixon 3 [ 0.12% ]
|
53
|
+
Chris Duncan 3 [ 0.12% ]
|
54
|
+
Richard Outten 2 [ 0.08% ]
|
55
|
+
Andy Smith 2 [ 0.08% ]
|
56
|
+
skaar 1 [ 0.04% ]
|
57
|
+
Yasushi Abe 1 [ 0.04% ]
|
58
|
+
Thomas Leitner 1 [ 0.04% ]
|
59
|
+
Rob Lievaart 1 [ 0.04% ]
|
60
|
+
Riku Raisaenen 1 [ 0.04% ]
|
61
|
+
Matt Rubens 1 [ 0.04% ]
|
62
|
+
Martin Hilbig 1 [ 0.04% ]
|
63
|
+
Leo Borisenko 1 [ 0.04% ]
|
64
|
+
Lars Olsson 1 [ 0.04% ]
|
65
|
+
Jeremy Evans 1 [ 0.04% ]
|
66
|
+
Jean-Francois Chevrette 1 [ 0.04% ]
|
67
|
+
James Tucker 1 [ 0.04% ]
|
68
|
+
Fabian Buch 1 [ 0.04% ]
|
69
|
+
Christian Neukirchen 1 [ 0.04% ]
|
70
|
+
Carlo Zottmann 1 [ 0.04% ]
|
71
|
+
Andrew Farmer 1 [ 0.04% ]
|
@@ -2,22 +2,34 @@ require 'rubygems'
|
|
2
2
|
require 'ramaze'
|
3
3
|
|
4
4
|
class MainController < Ramaze::Controller
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}.map{|k,v| ["#{k}:#{v}"].pack('m').strip}
|
5
|
+
trait :logins => {
|
6
|
+
'jill' => 'password1',
|
7
|
+
'jack' => 'password2',
|
8
|
+
}.map{|k,v| ["#{k}:#{v}"].pack('m').strip }
|
9
9
|
|
10
10
|
helper :aspect
|
11
11
|
|
12
12
|
before_all do
|
13
|
-
|
14
|
-
respond 'Unauthorized', 401 unless auth = request.env['HTTP_AUTHORIZATION'] and
|
15
|
-
LOGINS.include? auth.split.last
|
13
|
+
check_auth
|
16
14
|
end
|
17
15
|
|
18
16
|
def index
|
19
17
|
'Secret Info'
|
20
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def check_auth
|
23
|
+
response['WWW-Authenticate'] = 'Basic realm="Login Required"'
|
24
|
+
|
25
|
+
if auth = request.env['HTTP_AUTHORIZATION']
|
26
|
+
if class_trait[:logins].include?(auth.split.last)
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
respond 'Unauthorized', 401
|
32
|
+
end
|
21
33
|
end
|
22
34
|
|
23
|
-
Ramaze.start :adapter => :mongrel
|
35
|
+
Ramaze.start :adapter => :mongrel
|
@@ -5,9 +5,7 @@
|
|
5
5
|
# map '/otherurl'
|
6
6
|
# this will force the controller to be mounted on: /otherurl
|
7
7
|
|
8
|
-
class MainController <
|
9
|
-
layout '/page'
|
10
|
-
|
8
|
+
class MainController < Controller
|
11
9
|
# the index action is called automatically when no other action is specified
|
12
10
|
def index
|
13
11
|
@title = "Welcome to Ramaze!"
|
@@ -4,7 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'ramaze'
|
5
5
|
|
6
6
|
# FCGI doesn't like you writing to stdout
|
7
|
-
Ramaze::Log.loggers = [ Ramaze::Informer.new( File.join(__DIR__, '..', 'ramaze.fcgi.log') ) ]
|
7
|
+
Ramaze::Log.loggers = [ Ramaze::Logger::Informer.new( File.join(__DIR__, '..', 'ramaze.fcgi.log') ) ]
|
8
8
|
Ramaze::Global.adapter = :fcgi
|
9
9
|
|
10
10
|
$0 = File.join(__DIR__, '..', 'start.rb')
|
data/lib/proto/spec/main.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'ramaze'
|
2
2
|
require 'ramaze/spec/helper'
|
3
3
|
|
4
|
-
require __DIR__/'
|
4
|
+
require __DIR__/'../start'
|
5
5
|
|
6
6
|
describe MainController do
|
7
7
|
behaves_like 'http', 'xpath'
|
@@ -11,6 +11,7 @@ describe MainController do
|
|
11
11
|
it 'should show start page' do
|
12
12
|
got = get('/')
|
13
13
|
got.status.should == 200
|
14
|
+
puts got.body
|
14
15
|
got.at('//title').text.strip.should ==
|
15
16
|
MainController.new.index
|
16
17
|
end
|
data/lib/proto/start.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'ramaze'
|
3
3
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
4
|
+
# Initialize controllers and models
|
5
|
+
require 'controller/init'
|
6
|
+
require 'model/init'
|
7
7
|
|
8
8
|
Ramaze.start :adapter => :webrick, :port => 7000
|
data/lib/proto/start.ru
CHANGED
data/lib/proto/view/error.xhtml
CHANGED
@@ -40,16 +40,16 @@ Click on any of them to view the surrounding source code.</p>
|
|
40
40
|
</table>
|
41
41
|
|
42
42
|
<?r
|
43
|
-
{ 'Session' =>
|
44
|
-
'Request' =>
|
45
|
-
'Response' =>
|
43
|
+
{ 'Session' => Ramaze::STATE[:session],
|
44
|
+
'Request' => Ramaze::STATE[:request],
|
45
|
+
'Response' => Ramaze::STATE[:response],
|
46
46
|
'Global' => Global,
|
47
47
|
}.each do |title, content|
|
48
48
|
hash = [title, content].object_id.abs
|
49
49
|
?>
|
50
50
|
<div class="additional">
|
51
51
|
<h3 id="#{hash}">#{title}</h3>
|
52
|
-
<pre style="display:none" id="is_#{hash}">#{
|
52
|
+
<pre style="display:none" id="is_#{hash}">#{Rack::Utils.escape_html(content.pretty_inspect)}</pre>
|
53
53
|
</div>
|
54
54
|
<?r end ?>
|
55
55
|
|
data/lib/ramaze.rb
CHANGED
@@ -33,16 +33,22 @@ module Ramaze
|
|
33
33
|
BASEDIR = File.dirname(File.expand_path(__FILE__))
|
34
34
|
$LOAD_PATH.unshift BASEDIR
|
35
35
|
$LOAD_PATH.uniq!
|
36
|
+
|
37
|
+
# Shortcut to the HTTP_STATUS_CODES of Rack::Utils
|
38
|
+
# inverted for easier access
|
39
|
+
|
40
|
+
STATUS_CODE = Rack::Utils::HTTP_STATUS_CODES.invert
|
36
41
|
end
|
37
42
|
|
38
43
|
Thread.abort_on_exception = true
|
39
44
|
|
40
45
|
# Bootstrap
|
41
46
|
require 'ramaze/version'
|
42
|
-
require 'ramaze/
|
47
|
+
require 'ramaze/reloader'
|
43
48
|
require 'ramaze/snippets'
|
44
49
|
require 'ramaze/log'
|
45
50
|
require 'ramaze/trinity'
|
51
|
+
require 'ramaze/dispatcher'
|
46
52
|
require 'ramaze/current'
|
47
53
|
require 'ramaze/adapter'
|
48
54
|
require 'ramaze/option'
|
@@ -53,7 +59,6 @@ require 'ramaze/tool'
|
|
53
59
|
require 'ramaze/controller'
|
54
60
|
|
55
61
|
# Complete
|
56
|
-
require 'ramaze/dispatcher'
|
57
62
|
require 'ramaze/template/ezamar'
|
58
63
|
require 'ramaze/contrib'
|
59
64
|
require 'ramaze/route'
|
@@ -63,7 +68,7 @@ module Ramaze
|
|
63
68
|
# Each of these classes will be called ::startup upon Ramaze.startup
|
64
69
|
|
65
70
|
trait :essentials => [
|
66
|
-
Global, Cache, Contrib, Controller, Session,
|
71
|
+
Global, Cache, Contrib, Controller, Session, Adapter
|
67
72
|
]
|
68
73
|
|
69
74
|
trait :started => false
|
data/lib/ramaze/action.rb
CHANGED
@@ -10,7 +10,7 @@ module Ramaze
|
|
10
10
|
# The Action holds information that is essential to render the action for a
|
11
11
|
# request.
|
12
12
|
|
13
|
-
class Action < Struct.new('Action', *members)
|
13
|
+
class Action < Ramaze::Struct.new('Action', *members)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -41,7 +41,7 @@ module Ramaze
|
|
41
41
|
|
42
42
|
# Return the stacked actions for the current request
|
43
43
|
def stack
|
44
|
-
|
44
|
+
STATE[:action_stack] ||= []
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -59,10 +59,10 @@ module Ramaze
|
|
59
59
|
self[:method] = (meth.empty? ? nil : meth)
|
60
60
|
end
|
61
61
|
|
62
|
-
# runs all parameters assigned through flatten and
|
62
|
+
# runs all parameters assigned through flatten and unescape
|
63
63
|
|
64
64
|
def params=(*par)
|
65
|
-
self[:params] = par.flatten.compact.map{|pa|
|
65
|
+
self[:params] = par.flatten.compact.map{|pa| Rack::Utils.unescape(pa.to_s) }
|
66
66
|
end
|
67
67
|
|
68
68
|
# Use this as key for caches.
|
@@ -116,7 +116,7 @@ module Ramaze
|
|
116
116
|
|
117
117
|
# combined path to current action, from path and params
|
118
118
|
def extended_path
|
119
|
-
Array[path, *params].join('/')
|
119
|
+
(path == "index" && !params.empty? ? params : Array[path, *params]).join('/')
|
120
120
|
end
|
121
121
|
|
122
122
|
def full_path
|
@@ -145,7 +145,7 @@ module Ramaze
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
# Shortcut to create new instances of Action
|
148
|
+
# Shortcut to create new instances of Action
|
149
149
|
|
150
150
|
def self.Action(hash = {})
|
151
151
|
Action.create(hash)
|
data/lib/ramaze/adapter.rb
CHANGED
@@ -11,11 +11,6 @@ Socket.do_not_reverse_lookup = true
|
|
11
11
|
|
12
12
|
module Ramaze
|
13
13
|
|
14
|
-
# Shortcut to the HTTP_STATUS_CODES of Rack::Utils
|
15
|
-
# inverted for easier access
|
16
|
-
|
17
|
-
STATUS_CODE = Rack::Utils::HTTP_STATUS_CODES.invert
|
18
|
-
|
19
14
|
# This module holds all classes and methods related to the adapters like
|
20
15
|
# webrick or mongrel.
|
21
16
|
# It's responsible for starting and stopping them.
|
@@ -57,7 +52,7 @@ module Ramaze
|
|
57
52
|
|
58
53
|
if Global.test_connections
|
59
54
|
test_connection(host, port)
|
60
|
-
Log.info("Ramaze is ready to run on: #{host}:#{port}")
|
55
|
+
Log.info("Ramaze is ready to run on: #{host}:#{port} using #{Global.adapter}")
|
61
56
|
end
|
62
57
|
|
63
58
|
adapter.start(host, port)
|
data/lib/ramaze/adapter/base.rb
CHANGED
@@ -5,16 +5,34 @@ module Ramaze
|
|
5
5
|
module Adapter
|
6
6
|
|
7
7
|
# (Rack) middleware injected around Adapter::Base::call
|
8
|
-
MIDDLEWARE = OrderedSet
|
9
|
-
|
8
|
+
MIDDLEWARE = OrderedSet[
|
9
|
+
Rack::ShowExceptions,
|
10
10
|
Rack::ShowStatus,
|
11
|
-
Rack::
|
12
|
-
|
11
|
+
# Rack::Deflater,
|
12
|
+
Ramaze::Reloader,
|
13
|
+
Ramaze::Current,
|
14
|
+
Ramaze::Dispatcher
|
15
|
+
] unless defined? MIDDLEWARE
|
16
|
+
|
17
|
+
def self.middleware(mws = MIDDLEWARE)
|
18
|
+
if @middleware and trait[:previous] == mws
|
19
|
+
@middleware
|
20
|
+
else
|
21
|
+
trait :previous => mws.dup
|
22
|
+
inner_app = mws.last
|
23
|
+
cascade = mws[0...-1].reverse
|
24
|
+
|
25
|
+
@middleware = cascade.inject(inner_app){|app, mw| mw.new(app) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
@middleware = nil
|
30
|
+
@middleware = middleware
|
13
31
|
|
14
32
|
# Helper to assign a new block to before_call
|
15
33
|
# Usage:
|
16
34
|
# Ramaze::Adapter.before do |env|
|
17
|
-
# if env['PATH_INFO'] =~ /
|
35
|
+
# if env['PATH_INFO'] =~ /superfast/
|
18
36
|
# [200, {'Content-Type' => 'text/plain'}, ['super fast!']]
|
19
37
|
# end
|
20
38
|
# end
|
@@ -28,12 +46,13 @@ module Ramaze
|
|
28
46
|
|
29
47
|
class Base
|
30
48
|
class << self
|
49
|
+
|
31
50
|
attr_reader :thread
|
32
51
|
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
52
|
+
# Call ::startup with the given host and port.
|
53
|
+
# Sets Global.server to itself.
|
54
|
+
# Adds a trap that is triggered by the value of Global.shutdown_trap,
|
55
|
+
# which is SIGINT by default.
|
37
56
|
|
38
57
|
def start(host = nil, port = nil)
|
39
58
|
@thread = startup(host, port)
|
@@ -45,11 +64,6 @@ module Ramaze
|
|
45
64
|
}
|
46
65
|
end
|
47
66
|
|
48
|
-
def start_server(host, port)
|
49
|
-
Ramaze::deprecated("Adapter::Base::start_server", "Adapter::Base::startup")
|
50
|
-
startup(host, port)
|
51
|
-
end
|
52
|
-
|
53
67
|
# Does nothing by default
|
54
68
|
|
55
69
|
def shutdown
|
@@ -103,22 +117,11 @@ module Ramaze
|
|
103
117
|
# Then goes on and calls Dispatcher::handle with request and response.
|
104
118
|
|
105
119
|
def respond(env)
|
106
|
-
|
107
|
-
|
108
|
-
else
|
109
|
-
middleware_respond(env)
|
120
|
+
Ramaze::STATE.wrap do
|
121
|
+
Adapter::middleware.call(env)
|
110
122
|
end
|
111
123
|
end
|
112
124
|
|
113
|
-
def middleware_respond(env)
|
114
|
-
Thread.current.priority = 1
|
115
|
-
|
116
|
-
if Global.middleware
|
117
|
-
MIDDLEWARE.inject{|app, middleware| middleware.new(app) }.call(env)
|
118
|
-
else
|
119
|
-
Current.call(env)
|
120
|
-
end
|
121
|
-
end
|
122
125
|
end
|
123
126
|
end
|
124
127
|
end
|
data/lib/ramaze/adapter/cgi.rb
CHANGED
data/lib/ramaze/cache.rb
CHANGED
@@ -48,9 +48,7 @@ module Ramaze
|
|
48
48
|
def add_on(key, cache_class)
|
49
49
|
CACHES[key] = new(cache_class)
|
50
50
|
CACHES[key].instance_variable_set("@cache_name", key)
|
51
|
-
self
|
52
|
-
define_method(key){ CACHES[key] }
|
53
|
-
end
|
51
|
+
eval("def self.%s; CACHES[%p]; end" % [key, key])
|
54
52
|
end
|
55
53
|
|
56
54
|
end
|