Pistos-ramaze 2008.09 → 2008.12
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/benchmark/run.rb +1 -1
- data/examples/app/blog/spec/blog.rb +2 -2
- data/examples/app/rapaste/spec/rapaste.rb +1 -1
- data/examples/app/rapaste/start.rb +2 -2
- data/examples/app/rapaste/view/view.xhtml +3 -0
- data/examples/app/todolist/spec/todolist.rb +1 -1
- data/examples/app/whywiki/spec/whywiki.rb +1 -1
- data/examples/app/wikore/spec/wikore.rb +1 -1
- data/examples/app/wikore/src/model.rb +1 -1
- data/examples/app/wiktacular/spec/wiktacular.rb +1 -1
- data/examples/app/wiktacular/src/model.rb +1 -1
- data/examples/basic/partial.rb +28 -0
- data/examples/helpers/httpdigest.rb +68 -10
- data/examples/misc/ramaise.rb +2 -2
- data/examples/templates/template_amrita2.rb +1 -1
- data/examples/templates/template_erubis.rb +1 -1
- data/examples/templates/template_ezamar.rb +1 -1
- data/examples/templates/template_haml.rb +2 -2
- data/examples/templates/template_liquid.rb +1 -1
- data/examples/templates/template_markaby.rb +2 -2
- data/examples/templates/template_nagoro.rb +1 -1
- data/examples/templates/template_redcloth.rb +1 -1
- data/examples/templates/template_remarkably.rb +2 -2
- data/examples/templates/template_tenjin.rb +1 -1
- data/examples/templates/template_xslt.rb +1 -1
- data/lib/proto/controller/init.rb +2 -1
- data/lib/proto/model/init.rb +3 -3
- data/lib/proto/public/dispatch.fcgi +2 -2
- data/lib/proto/spec/main.rb +3 -3
- data/lib/proto/start.rb +4 -0
- data/lib/ramaze/action/render.rb +6 -5
- data/lib/ramaze/action.rb +7 -1
- data/lib/ramaze/cache/file.rb +71 -0
- data/lib/ramaze/cache.rb +1 -0
- data/lib/ramaze/contrib/email.rb +2 -0
- data/lib/ramaze/contrib/facebook.rb +2 -2
- data/lib/ramaze/contrib/file_cache.rb +2 -64
- data/lib/ramaze/contrib/sequel/image.rb +1 -1
- data/lib/ramaze/contrib.rb +1 -1
- data/lib/ramaze/controller/resolve.rb +8 -3
- data/lib/ramaze/controller.rb +9 -1
- data/lib/ramaze/current/request.rb +85 -68
- data/lib/ramaze/current/session/hash.rb +7 -11
- data/lib/ramaze/current/session.rb +3 -5
- data/lib/ramaze/dispatcher/action.rb +2 -0
- data/lib/ramaze/dispatcher/file.rb +6 -1
- data/lib/ramaze/helper/aspect.rb +2 -2
- data/lib/ramaze/helper/form.rb +5 -2
- data/lib/ramaze/helper/formatting.rb +4 -0
- data/lib/ramaze/helper/gravatar.rb +18 -1
- data/lib/ramaze/helper/httpdigest.rb +57 -28
- data/lib/ramaze/helper/maruku.rb +2 -0
- data/lib/ramaze/helper/paginate.rb +2 -3
- data/lib/ramaze/helper/partial.rb +1 -1
- data/lib/ramaze/helper/redirect.rb +22 -4
- data/lib/ramaze/helper/user.rb +4 -4
- data/lib/ramaze/helper.rb +12 -4
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/option/holder.rb +3 -3
- data/lib/ramaze/option.rb +1 -1
- data/lib/ramaze/reloader/watch_inotify.rb +85 -0
- data/lib/ramaze/reloader/watch_stat.rb +58 -0
- data/lib/ramaze/reloader.rb +25 -41
- data/lib/ramaze/snippets/divide.rb +2 -0
- data/lib/ramaze/snippets/numeric/time.rb +1 -1
- data/lib/ramaze/snippets/object/__dir__.rb +3 -3
- data/lib/ramaze/snippets/object/acquire.rb +3 -6
- data/lib/ramaze/snippets/ramaze/acquire.rb +31 -0
- data/lib/ramaze/snippets/ramaze/deprecated.rb +2 -1
- data/lib/ramaze/spec/helper/mock_http.rb +6 -5
- data/lib/ramaze/template/ezamar/render_partial.rb +8 -0
- data/lib/ramaze/tool/mime.rb +1 -1
- data/lib/ramaze/tool/project_creator.rb +2 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze.rb +6 -0
- data/rake_tasks/coverage.rake +4 -5
- data/rake_tasks/spec.rake +6 -6
- data/ramaze.gemspec +769 -756
- data/spec/contrib/profiling.rb +2 -2
- data/spec/ramaze/action/file_cache.rb +1 -1
- data/spec/ramaze/action/layout.rb +1 -1
- data/spec/ramaze/controller/actionless_templates.rb +1 -1
- data/spec/ramaze/controller/resolve.rb +1 -1
- data/spec/ramaze/controller/template_resolving.rb +1 -1
- data/spec/ramaze/dispatcher/directory.rb +3 -3
- data/spec/ramaze/helper/aspect.rb +1 -1
- data/spec/ramaze/helper/partial.rb +1 -1
- data/spec/ramaze/localize.rb +1 -1
- data/spec/ramaze/rewrite.rb +1 -1
- data/spec/ramaze/template/amrita2.rb +1 -1
- data/spec/ramaze/template/erubis.rb +1 -1
- data/spec/ramaze/template/ezamar.rb +1 -1
- data/spec/ramaze/template/haml.rb +2 -2
- data/spec/ramaze/template/nagoro.rb +1 -1
- data/spec/ramaze/template/redcloth.rb +1 -1
- data/spec/ramaze/template/sass.rb +1 -1
- data/spec/ramaze/template/tenjin.rb +1 -1
- data/spec/ramaze/template.rb +3 -3
- data/spec/snippets/object/__dir__.rb +6 -0
- data/spec/snippets/{object → ramaze}/acquire.rb +24 -18
- metadata +15 -12
- data/lib/ramaze/contrib/auto_params/get_args.rb +0 -58
- data/lib/ramaze/contrib/auto_params.rb +0 -135
- data/spec/contrib/auto_params.rb +0 -121
- data/spec/snippets/divide.rb +0 -19
data/benchmark/run.rb
CHANGED
|
@@ -176,7 +176,7 @@ class RamazeBenchmark
|
|
|
176
176
|
|
|
177
177
|
# benchmarks
|
|
178
178
|
__DIR__ = File.expand_path(File.dirname(__FILE__))
|
|
179
|
-
Dir[__DIR__
|
|
179
|
+
Dir[__DIR__('suite/*.rb')].each do |filename|
|
|
180
180
|
@adapters.each do |adapter|
|
|
181
181
|
@paths.each do |path|
|
|
182
182
|
benchmark(filename, adapter, path) if @target.match(filename)
|
|
@@ -3,7 +3,7 @@ require 'ramaze/spec/helper'
|
|
|
3
3
|
|
|
4
4
|
spec_require 'hpricot', 'sequel'
|
|
5
5
|
|
|
6
|
-
$LOAD_PATH.unshift base = __DIR__
|
|
6
|
+
$LOAD_PATH.unshift base = __DIR__('..')
|
|
7
7
|
require 'start'
|
|
8
8
|
|
|
9
9
|
describe 'Blog' do
|
|
@@ -83,5 +83,5 @@ describe 'Blog' do
|
|
|
83
83
|
(check_page/'div.entry').size.should == 1
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
FileUtils.rm_f(__DIR__
|
|
86
|
+
FileUtils.rm_f(__DIR__('../blog.db'))
|
|
87
87
|
end
|
|
@@ -7,7 +7,7 @@ require 'uv'
|
|
|
7
7
|
|
|
8
8
|
Ramaze::Log.debug "Initializing UltraViolet..."
|
|
9
9
|
|
|
10
|
-
Uv.copy_files "xhtml", __DIR__
|
|
10
|
+
Uv.copy_files "xhtml", __DIR__("public")
|
|
11
11
|
Uv.init_syntaxes
|
|
12
12
|
|
|
13
13
|
UV_PRIORITY_NAMES = %w[ ruby plain_text html css javascript yaml diff ]
|
|
@@ -16,7 +16,7 @@ STYLE = 'iplastic'
|
|
|
16
16
|
|
|
17
17
|
Ramaze::Log.debug "done."
|
|
18
18
|
|
|
19
|
-
DB_FILE = "
|
|
19
|
+
DB_FILE = __DIR__("rapaste.sqlite") # for specs
|
|
20
20
|
DB = Sequel.connect("sqlite://#{DB_FILE}")
|
|
21
21
|
|
|
22
22
|
require 'model/paste'
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#{@pager}
|
|
2
2
|
<script type="text/javascript" src="/js/jquery.js"></script>
|
|
3
3
|
<script type="text/javascript">
|
|
4
|
+
$(function() {
|
|
5
|
+
$('#paste_body').dblclick(function(){ $('.line-numbers').toggle() });
|
|
6
|
+
});
|
|
4
7
|
function change_style(name){
|
|
5
8
|
$('link')[1].href = '/css/' + name + '.css';
|
|
6
9
|
$('pre')[0].className = name;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'ramaze'
|
|
3
|
+
|
|
4
|
+
# This is a small extension to the hello world example, showing how to use the
|
|
5
|
+
# <render> tag of Ezamar.
|
|
6
|
+
#
|
|
7
|
+
# Browse to /more and /even_more
|
|
8
|
+
|
|
9
|
+
pipeline = Ramaze::Template::Ezamar::TRANSFORM_PIPELINE
|
|
10
|
+
pipeline.put_after(::Ezamar::Element, ::Ezamar::RenderPartial)
|
|
11
|
+
pipeline.uniq!
|
|
12
|
+
|
|
13
|
+
class MainController < Ramaze::Controller
|
|
14
|
+
def index
|
|
15
|
+
"Hello, World!"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def more
|
|
19
|
+
@tail = request[:tail] || 'the standard'
|
|
20
|
+
'More of <render src="/index" /> #@tail'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def even_more
|
|
24
|
+
'<render src="/more" tail="This is even more" />'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Ramaze.start
|
|
@@ -4,12 +4,61 @@ require 'ramaze'
|
|
|
4
4
|
REALM = 'ramaze authentication required'
|
|
5
5
|
|
|
6
6
|
class MainController < Ramaze::Controller
|
|
7
|
+
|
|
8
|
+
helper :httpdigest
|
|
9
|
+
|
|
7
10
|
def index
|
|
8
11
|
%|
|
|
12
|
+
<p><a href="#{Rs(:eyes_only)}">eyes only</a></p>
|
|
9
13
|
<p><a href="#{R(SecretController,'/')}">secret area</a></p>
|
|
10
|
-
<p><a href="#{R(GuestController,'/')}">guest area</a>
|
|
14
|
+
<p><a href="#{R(GuestController,'/')}">guest area</a> username is <em>guest</em> password is <em>access</em></p>
|
|
11
15
|
|
|
|
12
16
|
end
|
|
17
|
+
|
|
18
|
+
def eyes_only
|
|
19
|
+
httpdigest('eyes only',REALM) do |username|
|
|
20
|
+
password = username.reverse
|
|
21
|
+
MD5.hexdigest([username,REALM,password].join(':'))
|
|
22
|
+
end
|
|
23
|
+
"Shhhh don't tell anyone"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class LoginController < Ramaze::Controller
|
|
29
|
+
map '/login'
|
|
30
|
+
|
|
31
|
+
helper :httpdigest
|
|
32
|
+
|
|
33
|
+
def index
|
|
34
|
+
@username ||= session[:username]
|
|
35
|
+
@username ||= httpdigest('login area',REALM)
|
|
36
|
+
"Hi there #@username!"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def login
|
|
40
|
+
%|<form action="#{Rs(:post)}" method="post"><input type="text" name="username"/><input type="password" name="password"/><input type="submit"/></form>|
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def post
|
|
44
|
+
username = request.params["username"]
|
|
45
|
+
password = request.params["password"]
|
|
46
|
+
if password == "entry"
|
|
47
|
+
session[:username] = username
|
|
48
|
+
destination = session[ :redirect_after_login ]
|
|
49
|
+
session.delete( :redirect_after_login )
|
|
50
|
+
redirect destination
|
|
51
|
+
end
|
|
52
|
+
redirect Rs(:login)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
protected
|
|
56
|
+
|
|
57
|
+
def httpdigest_failure
|
|
58
|
+
session[ :redirect_after_login ] = Rs(Ramaze::Action.current.method)
|
|
59
|
+
redirect Rs(:login)
|
|
60
|
+
end
|
|
61
|
+
|
|
13
62
|
end
|
|
14
63
|
|
|
15
64
|
class SecretController < Ramaze::Controller
|
|
@@ -17,17 +66,22 @@ class SecretController < Ramaze::Controller
|
|
|
17
66
|
helper :aspect
|
|
18
67
|
helper :httpdigest
|
|
19
68
|
|
|
69
|
+
USERS = { 'admin' => 'secret', 'root' => 'password' }
|
|
70
|
+
|
|
20
71
|
before_all do
|
|
21
|
-
@username = httpdigest('secret area',REALM)
|
|
22
|
-
{ 'admin' => MD5.hexdigest("admin:#{REALM}:secret"),
|
|
23
|
-
'root' => MD5.hexdigest("root:#{REALM}:access"),
|
|
24
|
-
}[ username ]
|
|
25
|
-
end
|
|
72
|
+
@username = httpdigest('secret area',REALM)
|
|
26
73
|
end
|
|
27
74
|
|
|
28
75
|
def index
|
|
29
76
|
"Hello <em>#@username</em>, welcome to SECRET world"
|
|
30
77
|
end
|
|
78
|
+
|
|
79
|
+
protected
|
|
80
|
+
|
|
81
|
+
def httpdigest_lookup_plaintext_password username
|
|
82
|
+
USERS[ username ]
|
|
83
|
+
end
|
|
84
|
+
|
|
31
85
|
end
|
|
32
86
|
|
|
33
87
|
class GuestController < Ramaze::Controller
|
|
@@ -36,15 +90,19 @@ class GuestController < Ramaze::Controller
|
|
|
36
90
|
helper :httpdigest
|
|
37
91
|
|
|
38
92
|
before_all do
|
|
39
|
-
@username = httpdigest('guest area',REALM)
|
|
40
|
-
username_used = username
|
|
41
|
-
MD5.hexdigest([username,REALM,username].join(':'))
|
|
42
|
-
end
|
|
93
|
+
@username = httpdigest('guest area',REALM)
|
|
43
94
|
end
|
|
44
95
|
|
|
45
96
|
def index
|
|
46
97
|
"Hello <em>#@username</em>, welcome to GUEST world."
|
|
47
98
|
end
|
|
99
|
+
|
|
100
|
+
protected
|
|
101
|
+
|
|
102
|
+
def httpdigest_lookup_password username
|
|
103
|
+
return "b71f15b2f6dd4834224fbe02169ed94c" if username == "guest"
|
|
104
|
+
end
|
|
105
|
+
|
|
48
106
|
end
|
|
49
107
|
|
|
50
108
|
Ramaze.start
|
data/examples/misc/ramaise.rb
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
%w(rubygems ramaze bluecloth rubypants haml).each{|lib| require lib }
|
|
16
16
|
|
|
17
17
|
class BlogPost
|
|
18
|
-
DIR = __DIR__
|
|
18
|
+
DIR = __DIR__(:entries)
|
|
19
19
|
|
|
20
20
|
def initialize filename
|
|
21
21
|
raise 'Invalid BlogPost filename' unless File.exists?(filename)
|
|
@@ -129,4 +129,4 @@ class MainController < Ramaze::Controller
|
|
|
129
129
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
Ramaze.start :sessions => false #, :adapter => :mongrel, :port => 3000
|
|
132
|
+
Ramaze.start :sessions => false #, :adapter => :mongrel, :port => 3000
|
|
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
|
2
2
|
require 'ramaze'
|
|
3
3
|
|
|
4
4
|
class MainController < Ramaze::Controller
|
|
5
|
-
view_root __DIR__
|
|
5
|
+
view_root __DIR__(:template)
|
|
6
6
|
engine :Haml
|
|
7
7
|
|
|
8
8
|
def index
|
|
@@ -29,7 +29,7 @@ class MainController < Ramaze::Controller
|
|
|
29
29
|
= A("#@place/one/two/three")
|
|
30
30
|
%br/
|
|
31
31
|
= A("#@place/one?foo=bar")
|
|
32
|
-
%div
|
|
32
|
+
%div
|
|
33
33
|
The arguments you have passed to this action are:
|
|
34
34
|
- if @args.empty?
|
|
35
35
|
none
|
|
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
|
2
2
|
require 'ramaze'
|
|
3
3
|
|
|
4
4
|
class MainController < Ramaze::Controller
|
|
5
|
-
view_root __DIR__
|
|
5
|
+
view_root __DIR__('template')
|
|
6
6
|
engine :Markaby
|
|
7
7
|
|
|
8
8
|
helper :markaby
|
|
@@ -33,7 +33,7 @@ class MainController < Ramaze::Controller
|
|
|
33
33
|
br
|
|
34
34
|
end
|
|
35
35
|
div do
|
|
36
|
-
text "The arguments you have passed to this action are:"
|
|
36
|
+
text "The arguments you have passed to this action are:"
|
|
37
37
|
if @args.empty?
|
|
38
38
|
text "none"
|
|
39
39
|
else
|
|
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
|
2
2
|
require 'ramaze'
|
|
3
3
|
|
|
4
4
|
class MainController < Ramaze::Controller
|
|
5
|
-
view_root __DIR__
|
|
5
|
+
view_root __DIR__(:template)
|
|
6
6
|
engine :Remarkably
|
|
7
7
|
|
|
8
8
|
include Remarkably::Common
|
|
@@ -31,7 +31,7 @@ class MainController < Ramaze::Controller
|
|
|
31
31
|
br
|
|
32
32
|
end
|
|
33
33
|
div do
|
|
34
|
-
text "The arguments you have passed to this action are:"
|
|
34
|
+
text "The arguments you have passed to this action are:"
|
|
35
35
|
if args.empty?
|
|
36
36
|
"none"
|
|
37
37
|
else
|
data/lib/proto/model/init.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Here goes your database connection and options
|
|
1
|
+
# Here goes your database connection and options:
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
|
|
3
|
+
# Here go your requires for models:
|
|
4
|
+
# require 'model/user'
|
|
@@ -4,8 +4,8 @@ require 'rubygems'
|
|
|
4
4
|
require 'ramaze'
|
|
5
5
|
|
|
6
6
|
# FCGI doesn't like you writing to stdout
|
|
7
|
-
Ramaze::Log.loggers = [ Ramaze::Logger::Informer.new(
|
|
7
|
+
Ramaze::Log.loggers = [ Ramaze::Logger::Informer.new( __DIR__("../ramaze.fcgi.log") ) ]
|
|
8
8
|
Ramaze::Global.adapter = :fcgi
|
|
9
9
|
|
|
10
|
-
$0 =
|
|
10
|
+
$0 = __DIR__("../start.rb")
|
|
11
11
|
require $0
|
data/lib/proto/spec/main.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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'
|
|
8
|
-
ramaze :view_root => __DIR__
|
|
9
|
-
:public_root => __DIR__
|
|
8
|
+
ramaze :view_root => __DIR__('../view'),
|
|
9
|
+
:public_root => __DIR__('../public')
|
|
10
10
|
|
|
11
11
|
it 'should show start page' do
|
|
12
12
|
got = get('/')
|
data/lib/proto/start.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'ramaze'
|
|
3
3
|
|
|
4
|
+
# Add directory start.rb is in to the load path, so you can run the app from
|
|
5
|
+
# any other working path
|
|
6
|
+
$LOAD_PATH.unshift(__DIR__)
|
|
7
|
+
|
|
4
8
|
# Initialize controllers and models
|
|
5
9
|
require 'controller/init'
|
|
6
10
|
require 'model/init'
|
data/lib/ramaze/action/render.rb
CHANGED
|
@@ -49,8 +49,8 @@ module Ramaze
|
|
|
49
49
|
# true.
|
|
50
50
|
|
|
51
51
|
def cached_render
|
|
52
|
-
if Global.file_cache
|
|
53
|
-
cached_render_file
|
|
52
|
+
if cache_root = Global.file_cache
|
|
53
|
+
cached_render_file(cache_root)
|
|
54
54
|
else
|
|
55
55
|
cached_render_memory
|
|
56
56
|
end
|
|
@@ -59,12 +59,13 @@ module Ramaze
|
|
|
59
59
|
# Uses files in the Global.public_root to provide a static ressource on
|
|
60
60
|
# next request and returns the rendered action
|
|
61
61
|
|
|
62
|
-
def cached_render_file
|
|
62
|
+
def cached_render_file(cache_root)
|
|
63
63
|
rendered = uncached_render
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
cr = cache_root.respond_to?(:to_str) ? cache_root.to_str : Global.public_root
|
|
66
|
+
global_epath = File.join(cr, self.controller.mapping, extended_path)
|
|
66
67
|
FileUtils.mkdir_p(File.dirname(global_epath))
|
|
67
|
-
File.open(global_epath, 'w+')
|
|
68
|
+
File.open(global_epath, 'w+'){|fp| fp.print(rendered) }
|
|
68
69
|
|
|
69
70
|
rendered
|
|
70
71
|
end
|
data/lib/ramaze/action.rb
CHANGED
|
@@ -110,17 +110,21 @@ module Ramaze
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
# Try to figure out a sane name for current action.
|
|
113
|
+
|
|
113
114
|
def name
|
|
114
115
|
File.basename((self[:method] || self[:template]).to_s).split('.').first
|
|
115
116
|
end
|
|
116
117
|
|
|
117
118
|
# combined path to current action, from path and params
|
|
119
|
+
|
|
118
120
|
def extended_path
|
|
119
121
|
(path == "index" && !params.empty? ? params : Array[path, *params]).join('/')
|
|
120
122
|
end
|
|
121
123
|
|
|
124
|
+
# same as Ramaze::Action#extended_path, with mapping of the current controller prepended.
|
|
125
|
+
|
|
122
126
|
def full_path
|
|
123
|
-
self.controller.mapping
|
|
127
|
+
File.join(self.controller.mapping, extended_path)
|
|
124
128
|
end
|
|
125
129
|
|
|
126
130
|
# Hook for AspectHelper
|
|
@@ -133,6 +137,8 @@ module Ramaze
|
|
|
133
137
|
def after_process
|
|
134
138
|
end
|
|
135
139
|
|
|
140
|
+
# Returns true if current request is valid REST request.
|
|
141
|
+
|
|
136
142
|
def valid_rest?
|
|
137
143
|
return true unless rest = controller.trait[:REST]
|
|
138
144
|
meth = Request.current.request_method
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module Ramaze
|
|
2
|
+
# Persist cache contents to the filesystem.
|
|
3
|
+
# By default this will create a `/cache` directory in your APPDIR
|
|
4
|
+
#
|
|
5
|
+
# Usage for sessions only:
|
|
6
|
+
#
|
|
7
|
+
# Ramaze::Global::cache_alternative[:sessions] = Ramaze::FileCache
|
|
8
|
+
#
|
|
9
|
+
# Usage for everything:
|
|
10
|
+
#
|
|
11
|
+
# Ramaze::Global::cache = Ramaze::FileCache
|
|
12
|
+
|
|
13
|
+
class FileCache
|
|
14
|
+
attr_accessor :root, :subdir
|
|
15
|
+
attr_reader :host, :pid
|
|
16
|
+
|
|
17
|
+
def initialize(root = Ramaze::Global.root, subdir = 'cache')
|
|
18
|
+
@root, @subdir = root, subdir
|
|
19
|
+
@host = Socket.gethostname
|
|
20
|
+
@pid = $$
|
|
21
|
+
|
|
22
|
+
FileUtils.mkdir_p(dir)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def dir(*further)
|
|
26
|
+
File.join(root, subdir, *further)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def [](key)
|
|
30
|
+
Marshal.load(File.read(dir(key.to_s, 'data')))
|
|
31
|
+
rescue
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def []=(key, value)
|
|
36
|
+
key = key.to_s
|
|
37
|
+
tmp_name = dir(key, "data.#{host}.#{pid}")
|
|
38
|
+
key_name = dir(key, 'data')
|
|
39
|
+
dir_name = dir(key)
|
|
40
|
+
|
|
41
|
+
data = Marshal.dump(value)
|
|
42
|
+
|
|
43
|
+
FileUtils.rm_rf(dir_name)
|
|
44
|
+
FileUtils.mkdir_p(dir_name)
|
|
45
|
+
|
|
46
|
+
File.open(tmp_name, 'w'){|fd| fd.write(data) }
|
|
47
|
+
|
|
48
|
+
FileUtils.mv(tmp_name, key_name)
|
|
49
|
+
|
|
50
|
+
return value
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def values_at(*keys)
|
|
54
|
+
keys.map{|key| self[key] }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def delete(*keys)
|
|
58
|
+
keys.map do |key|
|
|
59
|
+
FileUtils.rm_rf(dir(key.to_s))
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def clear
|
|
64
|
+
Dir[dir('*')].each{|entry| FileUtils.rm_rf(entry) }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def to_sym
|
|
68
|
+
name.split('::').last.to_sym
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
data/lib/ramaze/cache.rb
CHANGED
|
@@ -6,6 +6,7 @@ require 'ramaze/cache/memory'
|
|
|
6
6
|
module Ramaze
|
|
7
7
|
autoload :YAMLStoreCache, "ramaze/cache/yaml_store.rb"
|
|
8
8
|
autoload :MemcachedCache, "ramaze/cache/memcached.rb"
|
|
9
|
+
autoload :FileCache, "ramaze/cache/file.rb"
|
|
9
10
|
|
|
10
11
|
# This is the wrapper of all caches, providing mechanism
|
|
11
12
|
# for switching caching from one adapter to another.
|
data/lib/ramaze/contrib/email.rb
CHANGED
|
@@ -67,6 +67,8 @@ Message-Id: #{id}
|
|
|
67
67
|
send_smtp( email, recipient, subject )
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
# the raw mail sending method used by Ramaze::EmailHelper
|
|
71
|
+
|
|
70
72
|
def send_smtp( email, recipient, subject )
|
|
71
73
|
options = trait.values_at(:smtp_server, :smtp_port, :smtp_helo_domain,
|
|
72
74
|
:smtp_username, :smtp_password, :smtp_auth_type)
|