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,147 @@
|
|
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 Controller
|
6
|
+
class << self
|
7
|
+
# #ramaze - 9.5.2007
|
8
|
+
#
|
9
|
+
# manveru: if no possible controller is found, it's a NoController error
|
10
|
+
# manveru: that would be a 404 then
|
11
|
+
# Kashia: aye
|
12
|
+
# manveru: if some controller are found but no actions on them, it's NoAction Error for the first controller found, again, 404
|
13
|
+
# manveru: everything further down is considered 500
|
14
|
+
|
15
|
+
def resolve(path)
|
16
|
+
#Inform.debug("resolve_controller('#{path}')")
|
17
|
+
mapping = Global.mapping
|
18
|
+
controllers = Global.controllers
|
19
|
+
|
20
|
+
raise_no_controller(path) if controllers.empty? or mapping.empty?
|
21
|
+
|
22
|
+
patterns = Cache.patterns[path] ||= pattern_for(path)
|
23
|
+
first_controller = nil
|
24
|
+
|
25
|
+
patterns.each do |controller, method, params|
|
26
|
+
if controller = mapping[controller]
|
27
|
+
first_controller ||= controller
|
28
|
+
|
29
|
+
action = controller.resolve_action(method, *params)
|
30
|
+
template = action.template
|
31
|
+
|
32
|
+
valid_action = (action.method or (params.empty? && action.template))
|
33
|
+
|
34
|
+
return controller, action if valid_action
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
raise_no_action(first_controller, path) if first_controller
|
39
|
+
raise_no_controller(path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def resolve_action(path, *parameter)
|
43
|
+
path, parameter = path.to_s, parameter.map(&:to_s)
|
44
|
+
if alternate_template = trait["#{path}_template"]
|
45
|
+
t_controller, t_path = *alternate_template
|
46
|
+
template = t_controller.resolve_template(t_path)
|
47
|
+
end
|
48
|
+
|
49
|
+
method, params = resolve_method(path, *parameter)
|
50
|
+
|
51
|
+
if method or parameter.empty?
|
52
|
+
template ||= resolve_template(path)
|
53
|
+
end
|
54
|
+
|
55
|
+
hash = {:method => method, :params => params, :template => template}
|
56
|
+
Action.fill(hash)
|
57
|
+
end
|
58
|
+
|
59
|
+
def resolve_template(action)
|
60
|
+
action = action.to_s
|
61
|
+
action_converted = action.split('__').inject{|s,v| s/v}
|
62
|
+
actions = [action, action_converted].compact
|
63
|
+
|
64
|
+
paths = template_paths.map{|pa| actions.map{|a| pa/a } }.flatten.uniq
|
65
|
+
glob = "{#{paths.join(',')}}.{#{extension_order.join(',')}}"
|
66
|
+
|
67
|
+
Dir[glob].first
|
68
|
+
end
|
69
|
+
|
70
|
+
def template_paths
|
71
|
+
first_path =
|
72
|
+
if template_root = @template_root
|
73
|
+
template_root
|
74
|
+
else
|
75
|
+
Global.template_root / Global.mapping.invert[self]
|
76
|
+
end
|
77
|
+
[ first_path, public_root, Global.public_root ].compact
|
78
|
+
end
|
79
|
+
|
80
|
+
def resolve_method(name, *params)
|
81
|
+
if method = action_methods.delete(name)
|
82
|
+
arity = instance_method(method).arity
|
83
|
+
if params.size == arity or arity < 0
|
84
|
+
return method, params
|
85
|
+
end
|
86
|
+
end
|
87
|
+
return nil, []
|
88
|
+
end
|
89
|
+
|
90
|
+
def action_methods
|
91
|
+
exclude = Controller.trait[:exclude_action_modules]
|
92
|
+
|
93
|
+
ancs = (ancestors - exclude).select{|a| a.is_a?(Module)}
|
94
|
+
meths = ancs.map{|a| a.instance_methods(false).map(&:to_s)}.flatten.uniq
|
95
|
+
# fix for facets/more/paramix
|
96
|
+
meths - ancs.map(&:to_s)
|
97
|
+
end
|
98
|
+
|
99
|
+
def pattern_for(path)
|
100
|
+
atoms = path.split('/').grep(/\S/)
|
101
|
+
atoms.unshift('')
|
102
|
+
patterns, joiners = [], ['/']
|
103
|
+
|
104
|
+
atoms.size.times do |enum|
|
105
|
+
enum += 1
|
106
|
+
joiners << '__' if enum == 3
|
107
|
+
|
108
|
+
joiners.each do |joinus|
|
109
|
+
pattern = atoms.dup
|
110
|
+
|
111
|
+
controller = pattern[0, enum].join(joinus)
|
112
|
+
controller.gsub!(/^__/, '/')
|
113
|
+
controller = "/" if controller == ""
|
114
|
+
|
115
|
+
pattern = pattern[enum..-1]
|
116
|
+
args, temp = [], []
|
117
|
+
|
118
|
+
patterns << [controller, 'index', atoms[enum..-1]]
|
119
|
+
|
120
|
+
until pattern.empty?
|
121
|
+
args << pattern.shift
|
122
|
+
patterns << [controller, args.join( '__' ), pattern.dup]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
patterns.reverse!
|
128
|
+
end
|
129
|
+
|
130
|
+
def extension_order
|
131
|
+
t_extensions = Controller.trait[:template_extensions]
|
132
|
+
engine = trait[:engine]
|
133
|
+
c_extensions = t_extensions.reject{|k,v| v != engine}.keys
|
134
|
+
all_extensions = t_extensions.keys
|
135
|
+
(c_extensions + all_extensions).uniq
|
136
|
+
end
|
137
|
+
|
138
|
+
def raise_no_controller(path)
|
139
|
+
raise Ramaze::Error::NoController, "No Controller found for `#{path}'"
|
140
|
+
end
|
141
|
+
|
142
|
+
def raise_no_action(controller, path)
|
143
|
+
raise Ramaze::Error::NoAction, "No Action found for `#{path}' on #{controller}"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
data/lib/ramaze/dispatcher.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'timeout'
|
5
5
|
|
6
|
+
require 'ramaze/error'
|
6
7
|
require 'ramaze/adapter'
|
7
8
|
require 'ramaze/tool/mime'
|
8
9
|
|
@@ -19,25 +20,37 @@ module Ramaze
|
|
19
20
|
]
|
20
21
|
|
21
22
|
trait :handle_error => {
|
22
|
-
Exception
|
23
|
-
|
24
|
-
Ramaze::Error::
|
23
|
+
Exception =>
|
24
|
+
[ STATUS_CODE["Internal Server Error"], '/error' ],
|
25
|
+
Ramaze::Error::NoAction =>
|
26
|
+
[ STATUS_CODE["Not Found"], '/error' ],
|
27
|
+
Ramaze::Error::NoController =>
|
28
|
+
[ STATUS_CODE["Not Found"], '/error' ],
|
25
29
|
}
|
26
30
|
|
31
|
+
Cache.add :shield
|
32
|
+
|
33
|
+
trait :shielded => [ STATUS_CODE["Not Found"] ]
|
34
|
+
|
27
35
|
class << self
|
28
36
|
include Trinity
|
29
37
|
|
30
38
|
def handle rack_request, rack_response
|
31
39
|
setup_environment(rack_request, rack_response)
|
32
|
-
dispatch
|
33
|
-
rescue Object => error
|
34
|
-
Dispatcher::Error.process(error)
|
35
|
-
end
|
36
40
|
|
37
|
-
def dispatch
|
38
41
|
path = request.path_info.squeeze('/')
|
39
42
|
Inform.info("Request from #{request.remote_addr}: #{path}")
|
40
43
|
|
44
|
+
if Global.shield
|
45
|
+
shielded_dispatch(path)
|
46
|
+
else
|
47
|
+
dispatch(path)
|
48
|
+
end
|
49
|
+
rescue Object => error
|
50
|
+
Dispatcher::Error.process(error)
|
51
|
+
end
|
52
|
+
|
53
|
+
def dispatch(path)
|
41
54
|
catch(:respond) do
|
42
55
|
redirection = catch(:redirect) do
|
43
56
|
found = filter(path)
|
@@ -53,7 +66,26 @@ module Ramaze
|
|
53
66
|
def dispatch_to path
|
54
67
|
raise "Redirect to #{path} from #{path}" if request.path_info == path
|
55
68
|
request.path_info = path
|
56
|
-
|
69
|
+
|
70
|
+
if Global.shield
|
71
|
+
shielded_dispatch(path)
|
72
|
+
else
|
73
|
+
dispatch(path)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def shielded_dispatch(path)
|
78
|
+
shield_cache = Cache.shield
|
79
|
+
handled = shield_cache[path]
|
80
|
+
return handled if handled
|
81
|
+
|
82
|
+
dispatched = dispatch(path)
|
83
|
+
|
84
|
+
unless trait[:shielded].include?(dispatched.status)
|
85
|
+
dispatched
|
86
|
+
else
|
87
|
+
shield_cache[path] = dispatched
|
88
|
+
end
|
57
89
|
end
|
58
90
|
|
59
91
|
def filter path
|
data/lib/ramaze/global.rb
CHANGED
@@ -4,166 +4,81 @@
|
|
4
4
|
require 'ostruct'
|
5
5
|
require 'set'
|
6
6
|
|
7
|
+
require 'ramaze/global/dsl'
|
8
|
+
|
7
9
|
module Ramaze
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
:
|
32
|
-
|
33
|
-
|
34
|
-
:
|
35
|
-
|
36
|
-
|
37
|
-
:
|
38
|
-
|
39
|
-
|
40
|
-
:
|
41
|
-
:logger => Ramaze::Informer.new($stdout),
|
42
|
-
:mapping => {},
|
43
|
-
:port => 7000,
|
44
|
-
:run_loose => false,
|
45
|
-
:template_root => 'template',
|
46
|
-
:tidy => lambda{ Ramaze::Tool::Tidy.trait },
|
47
|
-
:test_connections => true,
|
48
|
-
:shutdown_trap => 'SIGINT',
|
49
|
-
|
50
|
-
:startup => [
|
51
|
-
lambda{
|
52
|
-
Ramaze::Inform = Global.logger unless defined?(Inform)
|
53
|
-
Inform.info("Starting up Ramaze (Version #{VERSION})")
|
54
|
-
}
|
55
|
-
],
|
56
|
-
:ramaze_startup => [
|
57
|
-
:setup_controllers, :init_autoreload, :init_adapter
|
58
|
-
],
|
59
|
-
|
60
|
-
:shutdown => [],
|
61
|
-
:ramaze_shutdown => [
|
62
|
-
:kill_threads,
|
63
|
-
lambda{
|
64
|
-
Inform.shutdown
|
65
|
-
puts("Shutdown Ramaze (it's save to kill me now if i hang)")
|
66
|
-
},
|
67
|
-
:exit
|
68
|
-
],
|
69
|
-
}
|
70
|
-
|
71
|
-
# takes an hash of options and optionally an block that is evaled in this
|
72
|
-
# instance of GlobalStruct.
|
73
|
-
|
74
|
-
def setup hash = {}, &block
|
75
|
-
Global.instance_eval(&block) if block_given?
|
76
|
-
table.merge!( hash.keys_to_sym )
|
77
|
-
end
|
78
|
-
|
79
|
-
# just update the hash, not deleting values already set.
|
80
|
-
# again, takes a block, but your assignments may be
|
81
|
-
# overwritten if they existed before.
|
82
|
-
|
83
|
-
def update hash = {}, &block
|
84
|
-
old_table = table.dup
|
85
|
-
Global.instance_eval(&block) if block_given?
|
86
|
-
table.merge!( hash.keys_to_sym.merge( old_table ) )
|
87
|
-
end
|
88
|
-
|
89
|
-
# synonym to Global.key = value
|
90
|
-
|
91
|
-
def []=(key, value)
|
92
|
-
table[key.to_sym] = value
|
93
|
-
end
|
94
|
-
|
95
|
-
# synonym for Global.key
|
96
|
-
|
97
|
-
def [](key)
|
98
|
-
table[key.to_sym]
|
99
|
-
end
|
100
|
-
|
101
|
-
# get all the values for the given keys in the right order.
|
102
|
-
|
103
|
-
def values_at(*keys)
|
104
|
-
table.values_at(*keys.map(&:to_sym))
|
105
|
-
end
|
106
|
-
|
107
|
-
# all keys already set
|
108
|
-
|
109
|
-
def keys
|
110
|
-
table.keys
|
111
|
-
end
|
112
|
-
|
113
|
-
# iterate over the GlobalStruct, no guarantee on the order.
|
114
|
-
|
115
|
-
def each
|
116
|
-
table.each do |e|
|
117
|
-
yield(e)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def inspect
|
122
|
-
table.inspect
|
123
|
-
end
|
124
|
-
|
125
|
-
def pretty_inspect
|
126
|
-
table.pretty_inspect
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
def new_ostruct_member(name)
|
131
|
-
name = name.to_sym
|
132
|
-
unless self.respond_to?(name)
|
133
|
-
class << self; self; end.class_eval do
|
134
|
-
define_method(name) { @table[name] }
|
135
|
-
define_method(:"#{name}=") { |x| @table[name] = x }
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
10
|
+
GlobalDSL.option_dsl do
|
11
|
+
o "Set the adapter Ramaze will run on.",
|
12
|
+
:adapter => :webrick, :cli => [:webrick, :mongrel]
|
13
|
+
|
14
|
+
o "All running threads of Adapter will be collected here.",
|
15
|
+
:adapters => ThreadGroup.new
|
16
|
+
|
17
|
+
o "Set the size of Backtrace shown.",
|
18
|
+
:backtrace_size => 10, :cli => 10
|
19
|
+
|
20
|
+
o "Turn benchmarking every request on.",
|
21
|
+
:benchmarking => false, :cli => false
|
22
|
+
|
23
|
+
o "Use this for general caching and as base for Cache.new.",
|
24
|
+
:cache => :memory, :cli => [:memory, :memcached, :yaml]
|
25
|
+
|
26
|
+
o "Turn on naive caching of all requests.",
|
27
|
+
:cache_all => false, :cli => false
|
28
|
+
|
29
|
+
o "Turn on cookies for all requests.",
|
30
|
+
:cookies => true, :cli => true
|
31
|
+
|
32
|
+
o "All subclasses of Controller are collected here.",
|
33
|
+
:controllers => Set.new
|
34
|
+
|
35
|
+
o "Start Ramaze within an IRB session",
|
36
|
+
:console => false, :cli => false
|
37
|
+
|
38
|
+
o "Turn on customized error pages.",
|
39
|
+
:error_page => true, :cli => true
|
40
|
+
|
41
|
+
o "Specify what IP Ramaze will respond to - 0.0.0.0 for all",
|
42
|
+
:host => "0.0.0.0", :cli => '0.0.0.0'
|
139
43
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
44
|
+
o "All paths to controllers are mapped here.",
|
45
|
+
:mapping => {}
|
46
|
+
|
47
|
+
o "The place ramaze was started from, useful mostly for debugging",
|
48
|
+
:origin => :main
|
49
|
+
|
50
|
+
o "Specify port",
|
51
|
+
:port => 7000, :cli => 7000
|
52
|
+
|
53
|
+
o "Specify the shadowing public directory (default in proto)",
|
54
|
+
:public_root => ( BASEDIR / 'proto' / 'public' )
|
55
|
+
|
56
|
+
o "Record all Request objects by assigning a filtering Proc to me.",
|
57
|
+
:record => false
|
58
|
+
|
59
|
+
o "Don't wait until all adapter-threads are finished or killed.",
|
60
|
+
:run_loose => false, :cli => false
|
61
|
+
|
62
|
+
o "Turn on BF/DoS protection for error-responses",
|
63
|
+
:shield => false, :cli => false
|
64
|
+
|
65
|
+
o "What signal to trap to call Ramaze::shutdown",
|
66
|
+
:shutdown_trap => "SIGINT"
|
67
|
+
|
68
|
+
o "Interval in seconds of the background SourceReload",
|
69
|
+
:sourcereload => 3, :cli => 3
|
70
|
+
|
71
|
+
o "How many adapters Ramaze should spawn.",
|
72
|
+
:spawn => 1, :cli => 1
|
73
|
+
|
74
|
+
o "Test before start if adapters will be able to connect",
|
75
|
+
:test_connections => true, :cli => true
|
76
|
+
|
77
|
+
o "Specify template root for dynamic files relative to main.rb",
|
78
|
+
:template_root => 'template'
|
165
79
|
end
|
166
80
|
|
167
|
-
|
168
|
-
|
81
|
+
require 'ramaze/global/globalstruct'
|
82
|
+
|
83
|
+
Global = GlobalStruct.setup(OPTIONS)
|
169
84
|
end
|