ramaze 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -12
- data/bin/ramaze +95 -171
- data/doc/CHANGELOG +387 -4
- data/doc/README +81 -13
- data/doc/meta/announcement.txt +51 -8
- data/doc/meta/configuration.txt +17 -34
- data/doc/meta/internals.txt +34 -4
- data/doc/migrate/1110_to_1111.txt +131 -0
- data/doc/readme_chunks/features.txt +81 -12
- data/doc/readme_chunks/installing.txt +0 -1
- data/doc/tutorial/todolist.html +293 -65
- data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
- data/examples/blog/main.rb +1 -1
- data/examples/blog/src/model.rb +0 -1
- data/examples/hello.rb +2 -5
- data/examples/templates/template/external.haml +5 -5
- data/examples/templates/template/external.liquid +1 -1
- data/examples/templates/template/external.mab +8 -8
- data/examples/templates/template/external.rem +30 -0
- data/examples/templates/template/external.rhtml +6 -7
- data/examples/templates/template/external.zmr +13 -9
- data/examples/templates/template_amrita2.rb +8 -8
- data/examples/templates/template_erubis.rb +11 -11
- data/examples/templates/template_ezamar.rb +9 -11
- data/examples/templates/template_haml.rb +13 -13
- data/examples/templates/template_liquid.rb +10 -10
- data/examples/templates/template_markaby.rb +13 -10
- data/examples/templates/template_remarkably.rb +59 -0
- data/examples/todolist/main.rb +1 -7
- data/examples/todolist/src/controller/main.rb +26 -13
- data/examples/todolist/src/element/page.rb +5 -0
- data/examples/whywiki/main.rb +1 -1
- data/lib/proto/main.rb +0 -8
- data/lib/proto/public/css/ramaze_error.css +12 -4
- data/lib/proto/public/error.zmr +6 -25
- data/lib/ramaze.rb +35 -245
- data/lib/ramaze/action.rb +21 -0
- data/lib/ramaze/adapter.rb +94 -29
- data/lib/ramaze/adapter/base.rb +57 -0
- data/lib/ramaze/adapter/mongrel.rb +12 -19
- data/lib/ramaze/adapter/webrick.rb +21 -20
- data/lib/ramaze/cache.rb +47 -3
- data/lib/ramaze/cache/memcached.rb +22 -0
- data/lib/ramaze/cache/yaml_store.rb +19 -0
- data/lib/ramaze/controller.rb +47 -271
- data/lib/ramaze/controller/error.rb +43 -0
- data/lib/ramaze/controller/render.rb +90 -0
- data/lib/ramaze/controller/resolve.rb +147 -0
- data/lib/ramaze/dispatcher.rb +41 -9
- data/lib/ramaze/dispatcher/file.rb +1 -1
- data/lib/ramaze/global.rb +73 -158
- data/lib/ramaze/global/dsl.rb +29 -0
- data/lib/ramaze/global/globalstruct.rb +90 -0
- data/lib/ramaze/helper.rb +1 -1
- data/lib/ramaze/helper/aspect.rb +39 -179
- data/lib/ramaze/helper/cache.rb +8 -9
- data/lib/ramaze/helper/cgi.rb +23 -0
- data/lib/ramaze/helper/file.rb +3 -0
- data/lib/ramaze/helper/inform.rb +3 -0
- data/lib/ramaze/helper/link.rb +56 -63
- data/lib/ramaze/helper/nitroform.rb +4 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/inform.rb +6 -2
- data/lib/ramaze/inform/analogger.rb +5 -1
- data/lib/ramaze/inform/hub.rb +1 -1
- data/lib/ramaze/inform/informing.rb +7 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
- data/lib/ramaze/snippets/kernel/constant.rb +2 -0
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
- data/lib/ramaze/snippets/object/traits.rb +4 -0
- data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
- data/lib/ramaze/snippets/string/camel_case.rb +2 -0
- data/lib/ramaze/snippets/string/color.rb +2 -0
- data/lib/ramaze/snippets/string/each.rb +2 -0
- data/lib/ramaze/snippets/string/snake_case.rb +3 -0
- data/lib/ramaze/snippets/struct/fill.rb +8 -2
- data/lib/ramaze/snippets/struct/values_at.rb +16 -0
- data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
- data/lib/ramaze/sourcereload.rb +89 -0
- data/lib/ramaze/template.rb +21 -12
- data/lib/ramaze/template/amrita2.rb +6 -6
- data/lib/ramaze/template/erubis.rb +4 -9
- data/lib/ramaze/template/ezamar.rb +13 -57
- data/lib/ramaze/template/ezamar/element.rb +10 -12
- data/lib/ramaze/template/ezamar/engine.rb +40 -101
- data/lib/ramaze/template/ezamar/morpher.rb +3 -3
- data/lib/ramaze/template/haml.rb +3 -6
- data/lib/ramaze/template/liquid.rb +4 -9
- data/lib/ramaze/template/markaby.rb +16 -22
- data/lib/ramaze/template/remarkably.rb +28 -0
- data/lib/ramaze/tool/mime.rb +2 -0
- data/lib/ramaze/tool/record.rb +6 -0
- data/lib/ramaze/trinity/request.rb +44 -54
- data/lib/ramaze/trinity/response.rb +1 -1
- data/lib/ramaze/trinity/session.rb +15 -37
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/gem.rake +2 -2
- data/rake_tasks/maintaince.rake +42 -1
- data/rake_tasks/spec.rake +45 -0
- data/spec/examples/caching.rb +1 -1
- data/spec/examples/simple.rb +1 -1
- data/spec/examples/templates/template_amrita2.rb +1 -0
- data/spec/examples/templates/template_erubis.rb +2 -1
- data/spec/examples/templates/template_ezamar.rb +1 -1
- data/spec/examples/templates/template_haml.rb +2 -1
- data/spec/examples/templates/template_liquid.rb +2 -1
- data/spec/examples/templates/template_markaby.rb +2 -1
- data/spec/examples/templates/template_remarkably.rb +22 -0
- data/spec/examples/todolist.rb +125 -0
- data/spec/helper.rb +2 -23
- data/spec/helper/minimal.rb +20 -0
- data/spec/helper/mock_http.rb +24 -30
- data/spec/helper/simple_http.rb +2 -2
- data/spec/helper/wrap.rb +6 -9
- data/spec/ramaze/adapter.rb +1 -1
- data/spec/ramaze/adapter/record.rb +31 -0
- data/spec/ramaze/cache.rb +41 -54
- data/spec/ramaze/controller.rb +121 -137
- data/spec/ramaze/controller/template/list.xhtml +1 -0
- data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +27 -3
- data/spec/ramaze/element.rb +11 -7
- data/spec/ramaze/error.rb +1 -1
- data/spec/ramaze/gestalt.rb +2 -0
- data/spec/ramaze/helper/aspect.rb +30 -21
- data/spec/ramaze/helper/auth.rb +1 -1
- data/spec/ramaze/helper/cache.rb +2 -1
- data/spec/ramaze/helper/form.rb +14 -11
- data/spec/ramaze/helper/link.rb +18 -41
- data/spec/ramaze/localize.rb +29 -2
- data/spec/ramaze/morpher.rb +23 -12
- data/spec/ramaze/params.rb +46 -24
- data/spec/ramaze/request.rb +6 -2
- data/spec/ramaze/store/yaml.rb +5 -0
- data/spec/ramaze/template.rb +22 -27
- data/spec/ramaze/template/amrita2.rb +1 -2
- data/spec/ramaze/template/erubis.rb +1 -1
- data/spec/ramaze/template/ezamar.rb +1 -2
- data/spec/ramaze/template/haml.rb +2 -2
- data/spec/ramaze/template/haml/with_vars.haml +1 -1
- data/spec/ramaze/template/liquid.rb +1 -1
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/remarkably.rb +56 -0
- data/spec/ramaze/template/remarkably/external.rem +8 -0
- data/spec/ramaze/template/remarkably/sum.rem +1 -0
- metadata +38 -63
- data/doc/README.html +0 -637
- data/doc/allison/LICENSE +0 -184
- data/doc/allison/README +0 -37
- data/doc/allison/allison.css +0 -299
- 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 -321
- data/doc/allison/cache/URL +0 -1
- data/doc/changes.txt +0 -3375
- data/doc/changes.xml +0 -3378
- data/examples/todolist/conf/benchmark.yaml +0 -35
- data/examples/todolist/conf/debug.yaml +0 -34
- data/examples/todolist/conf/live.yaml +0 -33
- data/examples/todolist/conf/silent.yaml +0 -31
- data/examples/todolist/conf/stage.yaml +0 -33
- data/examples/todolist/public/css/coderay.css +0 -105
- data/examples/todolist/public/css/ramaze_error.css +0 -42
- data/lib/proto/conf/benchmark.yaml +0 -21
- data/lib/proto/conf/debug.yaml +0 -21
- data/lib/proto/conf/live.yaml +0 -21
- data/lib/proto/conf/silent.yaml +0 -21
- data/lib/proto/conf/stage.yaml +0 -21
- data/lib/proto/public/css/coderay.css +0 -105
- data/lib/ramaze/http_status.rb +0 -66
- data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
- data/lib/ramaze/snippets/kernel/method.rb +0 -26
- data/lib/ramaze/snippets/method/name.rb +0 -22
- data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
- data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
- data/spec/all.rb +0 -32
- data/spec/ramaze/conf/locale_de.yaml +0 -6
- data/spec/ramaze/conf/locale_en.yaml +0 -6
- data/spec/ramaze/dependencies.rb +0 -16
- data/spec/ramaze/global.rb +0 -44
@@ -0,0 +1,29 @@
|
|
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
|
+
module Ramaze
|
5
|
+
CLIOption = Struct.new('CLIOption', :name, :default, :doc, :cli)
|
6
|
+
OPTIONS = {}
|
7
|
+
CLI_OPTIONS = []
|
8
|
+
|
9
|
+
module GlobalDSL
|
10
|
+
class << self
|
11
|
+
def option_dsl(&block)
|
12
|
+
instance_eval(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def o(doc, options = {})
|
16
|
+
cli_given = options.has_key?(:cli)
|
17
|
+
cli = options.delete(:cli)
|
18
|
+
name, default = options.to_a.flatten
|
19
|
+
|
20
|
+
if cli_given
|
21
|
+
option = CLIOption.new(name, default, doc, cli)
|
22
|
+
CLI_OPTIONS << option
|
23
|
+
end
|
24
|
+
|
25
|
+
OPTIONS.merge!(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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
|
+
module Ramaze
|
5
|
+
class GlobalStruct < Struct.new('Global', *OPTIONS.keys)
|
6
|
+
ADAPTER_ALIAS = {
|
7
|
+
:webrick => :WEBrick,
|
8
|
+
:mongrel => :Mongrel,
|
9
|
+
:cgi => :CGI,
|
10
|
+
:fcgi => :Fcgi,
|
11
|
+
}
|
12
|
+
|
13
|
+
CACHE_ALIAS = {
|
14
|
+
:memcached => :MemcachedCache,
|
15
|
+
:memory => :MemoryCache,
|
16
|
+
:yaml => :YAMLStoreCache,
|
17
|
+
}
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def setup options = {}
|
21
|
+
self.fill(options)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def startup(options = {})
|
26
|
+
options.each do |key, value|
|
27
|
+
if (method(key) rescue false)
|
28
|
+
self[key] = value
|
29
|
+
else
|
30
|
+
create_member(key, value)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup(hash = {})
|
36
|
+
hash.each do |key, value|
|
37
|
+
self.send("#{key}=", value)
|
38
|
+
end
|
39
|
+
yield(self) if block_given?
|
40
|
+
end
|
41
|
+
|
42
|
+
# Object wraps
|
43
|
+
|
44
|
+
def adapter
|
45
|
+
if internal = self[:adapter]
|
46
|
+
class_name = ADAPTER_ALIAS[internal.to_sym]
|
47
|
+
require("ramaze/adapter/"/class_name.to_s.downcase)
|
48
|
+
adapter = Ramaze::Adapter.const_get(class_name)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def cache
|
53
|
+
cache_name = self[:cache].to_sym
|
54
|
+
class_name = CACHE_ALIAS[cache_name] || cache_name
|
55
|
+
cache = Ramaze.const_get(class_name)
|
56
|
+
end
|
57
|
+
|
58
|
+
def ports
|
59
|
+
(port..(port + (spawn - 1)))
|
60
|
+
end
|
61
|
+
|
62
|
+
def sourcereload=(interval)
|
63
|
+
self[:sourcereload] = interval
|
64
|
+
sri = Thread.main[:sourcereload]
|
65
|
+
sri.interval = interval if sri
|
66
|
+
end
|
67
|
+
|
68
|
+
# External helpers
|
69
|
+
|
70
|
+
def values_at(*keys)
|
71
|
+
keys.map{|key| __send__(key)}
|
72
|
+
end
|
73
|
+
|
74
|
+
private # Internal helpers
|
75
|
+
|
76
|
+
def create_member key, value = nil
|
77
|
+
Inform.warn "Create #{key}=#{value.inspect} on Global"
|
78
|
+
|
79
|
+
@table ||= {}
|
80
|
+
key = key.to_sym
|
81
|
+
|
82
|
+
(class << self; self; end).class_eval do
|
83
|
+
define_method(key){ @table[key] }
|
84
|
+
define_method("#{key}="){|val| @table[key] = val }
|
85
|
+
end
|
86
|
+
|
87
|
+
@table[key] = value
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/ramaze/helper.rb
CHANGED
data/lib/ramaze/helper/aspect.rb
CHANGED
@@ -13,202 +13,62 @@ module Ramaze
|
|
13
13
|
# want this feature it shouldn't have too large impact ;)
|
14
14
|
|
15
15
|
module AspectHelper
|
16
|
-
|
17
|
-
# define the trait[:aspects] for the class that includes us
|
18
|
-
# also prepare hijacking of the :render method
|
19
|
-
|
20
16
|
def self.included(klass)
|
21
|
-
|
22
|
-
unless defined?(Traits[klass][:aspects]) and Traits[klass][:aspects]
|
23
|
-
klass.trait :aspects => {:pre => {}, :post => {}, :wrap => {}}
|
24
|
-
unless defined?(klass.old_render)
|
25
|
-
klass.class_eval do
|
26
|
-
class << self
|
27
|
-
include AspectHelperMixin
|
28
|
-
alias_method :old_render, :render
|
29
|
-
alias_method :render, :new_render
|
30
|
-
|
31
|
-
public :render
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
17
|
+
klass.trait[:aspects] ||= { :before => {}, :after => {} }
|
36
18
|
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# This is the actual Module to be included into the Controller you call
|
40
|
-
# helper :aspect
|
41
|
-
# from.
|
42
|
-
#
|
43
|
-
# The reason for that is to avoid recursion of inclusion in AspectHelper
|
44
|
-
# which does the aliasing and predefinition of the traits for the aspects.
|
45
19
|
|
46
|
-
module AspectHelperMixin
|
47
20
|
private
|
48
21
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# however, due to the nature of this helper, only action that have been
|
55
|
-
# defined so far are wrapped by the :all.
|
56
|
-
# methods that are in the :except (which is not mandatory) are ignored.
|
57
|
-
#
|
58
|
-
# the notion :all_ is a nice reminder that it is a pre-wrapper, you don't
|
59
|
-
# have to use the underscore, it's just my way to do it.
|
60
|
-
#
|
61
|
-
# Also, be careful, since :all will wrap other wraps that have been defined
|
62
|
-
# so far as well.
|
63
|
-
# Usually i don't think it's a good thing that order defines
|
64
|
-
# behaviour, but in this case it gives you quite powerful control
|
65
|
-
# over the whole process. Just watch out:
|
66
|
-
# With great power comes great responsibility
|
67
|
-
#
|
68
|
-
# Example:
|
69
|
-
# class FooController < Controller
|
70
|
-
#
|
71
|
-
# def index
|
72
|
-
# 'foo'
|
73
|
-
# end
|
74
|
-
# pre :index, :_index
|
75
|
-
#
|
76
|
-
# def other
|
77
|
-
# 'foo'
|
78
|
-
# end
|
79
|
-
# pre :all, :all_, :except => :index
|
80
|
-
#
|
81
|
-
# def _index
|
82
|
-
# 'I will be put before your action'
|
83
|
-
# end
|
84
|
-
#
|
85
|
-
# def _all
|
86
|
-
# '<pre>'
|
87
|
-
# end
|
88
|
-
# end
|
89
|
-
|
90
|
-
def pre(*opts)
|
91
|
-
enwrap(:pre, *opts)
|
92
|
-
end
|
93
|
-
alias before pre
|
94
|
-
|
95
|
-
# define post-aspect which calls render(:your_post_aspect)
|
96
|
-
# and appends it on your default action
|
97
|
-
# please note, that if you give can define
|
98
|
-
# post :all, :all_, :except => [:action1, :action2]
|
99
|
-
# post :all, :all_, :except => :action
|
100
|
-
# however, due to the nature of this helper, only action that have been
|
101
|
-
# defined so far are wrapped by the :all.
|
102
|
-
# methods that are in the :except (which is not mandatory) are ignored.
|
103
|
-
#
|
104
|
-
# the notion :all_ is a nice reminder that it is a post-wrapper, you don't
|
105
|
-
# have to use the underscore, it's just my way to do it.
|
106
|
-
#
|
107
|
-
# Also, be careful, since :all will wrap other wraps that have been defined
|
108
|
-
# so far as well.
|
109
|
-
# Usually i don't think it's a good thing that order defines
|
110
|
-
# behaviour, but in this case it gives you quite powerful control
|
111
|
-
# over the whole process. Just watch out:
|
112
|
-
# With great power comes great responsibility
|
113
|
-
#
|
114
|
-
# Example:
|
115
|
-
# class FooController < Controller
|
116
|
-
#
|
117
|
-
# def index
|
118
|
-
# 'foo'
|
119
|
-
# end
|
120
|
-
# post :index, :index_
|
121
|
-
#
|
122
|
-
# def other
|
123
|
-
# 'foo'
|
124
|
-
# end
|
125
|
-
# pre :all, :all_, :except => :index
|
126
|
-
#
|
127
|
-
# def index_
|
128
|
-
# 'I will be put after your action'
|
129
|
-
# end
|
130
|
-
#
|
131
|
-
# def all_
|
132
|
-
# '</pre>'
|
133
|
-
# end
|
134
|
-
# end
|
135
|
-
|
136
|
-
def post(*opts)
|
137
|
-
enwrap(:post, *opts)
|
22
|
+
def before(*meths, &block)
|
23
|
+
aspects = trait[:aspects][:before]
|
24
|
+
meths.each do |meth|
|
25
|
+
aspects[meth.to_s] = block
|
26
|
+
end
|
138
27
|
end
|
139
|
-
alias
|
140
|
-
|
141
|
-
# a shortcut that combines pre and post
|
142
|
-
# same syntax as pre/post, just a linesaver
|
28
|
+
alias pre before
|
143
29
|
|
144
|
-
def
|
145
|
-
|
146
|
-
|
30
|
+
def before_all(&block)
|
31
|
+
meths = instance_methods(false)
|
32
|
+
before(*meths, &block)
|
147
33
|
end
|
34
|
+
alias pre_all before_all
|
148
35
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
def enwrap(kind, key, meths, hash = {})
|
155
|
-
wrapping =
|
156
|
-
if key == :all
|
157
|
-
instance_methods(false).map{|im| im.to_sym}
|
158
|
-
else
|
159
|
-
if ([] + key rescue nil)
|
160
|
-
key.map{|k| k.to_sym}
|
161
|
-
else
|
162
|
-
[key.to_sym]
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
if hash[:except]
|
167
|
-
wrapping -= [hash[:except]].flatten.map{|m| m.to_sym}
|
168
|
-
end
|
169
|
-
|
170
|
-
wrapping.each do |meth|
|
171
|
-
ancestral_trait[:aspects][kind][meth] = meths
|
36
|
+
def after(*meths, &block)
|
37
|
+
aspects = trait[:aspects][:after]
|
38
|
+
meths.each do |meth|
|
39
|
+
aspects[meth.to_s] = block
|
172
40
|
end
|
173
41
|
end
|
42
|
+
alias post after
|
174
43
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
action = action.to_sym
|
179
|
-
aspects = ancestral_trait[:aspects]
|
180
|
-
{
|
181
|
-
:pre => aspects[:pre][action],
|
182
|
-
:post => aspects[:post][action]
|
183
|
-
}
|
44
|
+
def after_all(&block)
|
45
|
+
meths = instance_methods(false)
|
46
|
+
after(*meths, &block)
|
184
47
|
end
|
48
|
+
alias post_all after_all
|
185
49
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
def new_render(action)
|
192
|
-
arity_for = lambda{|meth| method(meth).arity rescue -1 }
|
193
|
-
post, pre = resolve_aspect(action.method).values_at(:post, :pre)
|
194
|
-
|
195
|
-
if pre
|
196
|
-
arity = arity_for[pre].abs
|
197
|
-
pre_action = resolve_action(pre, *action.params[0,arity])
|
198
|
-
pre_content = old_render(pre_action)
|
199
|
-
end
|
50
|
+
def wrap(*meths, &block)
|
51
|
+
before(*meths, &block)
|
52
|
+
after(*meths, &block)
|
53
|
+
end
|
200
54
|
|
201
|
-
|
202
|
-
|
55
|
+
def wrap_all(&block)
|
56
|
+
meths = instance_methods(false)
|
57
|
+
wrap(*meths, &block)
|
58
|
+
end
|
203
59
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
end
|
60
|
+
def before_process(action)
|
61
|
+
block = ancestral_trait[:aspects][:before][action.method]
|
62
|
+
before = action.controller.instance_eval(&block) if block
|
63
|
+
before
|
64
|
+
end
|
210
65
|
|
211
|
-
|
66
|
+
def after_process(action)
|
67
|
+
block = ancestral_trait[:aspects][:after][action.method]
|
68
|
+
after = action.controller.instance_eval(&block) if block
|
69
|
+
after
|
212
70
|
end
|
71
|
+
|
72
|
+
module_function :before_process, :after_process
|
213
73
|
end
|
214
74
|
end
|
data/lib/ramaze/helper/cache.rb
CHANGED
@@ -2,15 +2,14 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
module Ramaze
|
5
|
-
module CacheHelper
|
6
|
-
|
7
|
-
# Cache for single key/value pairs
|
8
|
-
|
9
|
-
trait :value_cache => Global.cache.new
|
10
5
|
|
11
|
-
|
6
|
+
# This helper is providing easy access to a couple of Caches to use for
|
7
|
+
# smaller amounts of data.
|
12
8
|
|
13
|
-
|
9
|
+
module CacheHelper
|
10
|
+
def self.included(klass)
|
11
|
+
Cache.add(:value_cache) unless Cache::CACHES.has_key?(:value_cache)
|
12
|
+
end
|
14
13
|
|
15
14
|
private
|
16
15
|
|
@@ -18,7 +17,7 @@ module Ramaze
|
|
18
17
|
# for example heavy calculations or time-consuming queries.
|
19
18
|
|
20
19
|
def value_cache
|
21
|
-
|
20
|
+
Cache.value_cache
|
22
21
|
end
|
23
22
|
|
24
23
|
# holds the values returned on the first call to a cached action.
|
@@ -38,7 +37,7 @@ module Ramaze
|
|
38
37
|
# action_cache.delete_if{|key, value| key =~ /"index",/}
|
39
38
|
|
40
39
|
def action_cache
|
41
|
-
|
40
|
+
Cache.actions
|
42
41
|
end
|
43
42
|
|
44
43
|
# This refers to the class-trait of cached actions, you can
|
@@ -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
|
+
module Ramaze
|
5
|
+
|
6
|
+
# Shortcuts to some CGI methods
|
7
|
+
|
8
|
+
module CgiHelper
|
9
|
+
private
|
10
|
+
|
11
|
+
# shortcut for CGI.escape
|
12
|
+
|
13
|
+
def escape(*args)
|
14
|
+
CGI.escape(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
# shortcut for CGI.unescape
|
18
|
+
|
19
|
+
def unescape(*args)
|
20
|
+
CGI.escape(*args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/ramaze/helper/file.rb
CHANGED
@@ -5,6 +5,9 @@ module Ramaze
|
|
5
5
|
module FileHelper
|
6
6
|
private
|
7
7
|
|
8
|
+
# Sets Content-Type to the mimetype of the file and opens the file you pass
|
9
|
+
# it, then throws :respond to finish off the request.
|
10
|
+
|
8
11
|
def send_file(file, mime_type = Tool::MIME.type_for(file))
|
9
12
|
response.header["Content-Type"] = mime_type
|
10
13
|
response.body = File.open(file)
|