nitro 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +752 -543
- data/INSTALL +38 -38
- data/README +264 -225
- data/Rakefile +48 -49
- data/bin/nitro +3 -3
- data/bin/nitrogen +6 -6
- data/doc/AUTHORS +10 -10
- data/doc/CHANGELOG.1 +1939 -1939
- data/doc/CHANGELOG.2 +954 -954
- data/doc/LICENSE +3 -3
- data/doc/MIGRATION +28 -0
- data/doc/RELEASES +814 -643
- data/doc/config.txt +5 -5
- data/install.rb +7 -17
- data/lib/nitro.rb +38 -9
- data/lib/nitro/adapter/cgi.rb +311 -312
- data/lib/nitro/adapter/fastcgi.rb +18 -25
- data/lib/nitro/adapter/webrick.rb +128 -137
- data/lib/nitro/adapter/wee.rb +51 -0
- data/lib/nitro/caching.rb +20 -20
- data/lib/nitro/caching/actions.rb +43 -43
- data/lib/nitro/caching/fragments.rb +46 -46
- data/lib/nitro/caching/invalidation.rb +11 -11
- data/lib/nitro/caching/output.rb +65 -65
- data/lib/nitro/caching/stores.rb +67 -67
- data/lib/nitro/compiler.rb +262 -0
- data/lib/nitro/compiler/elements.rb +0 -0
- data/lib/nitro/compiler/errors.rb +65 -0
- data/lib/nitro/compiler/localization.rb +25 -0
- data/lib/nitro/compiler/markup.rb +19 -0
- data/lib/nitro/compiler/shaders.rb +206 -0
- data/lib/nitro/compiler/squeeze.rb +20 -0
- data/lib/nitro/compiler/xslt.rb +61 -0
- data/lib/nitro/context.rb +87 -88
- data/lib/nitro/controller.rb +151 -158
- data/lib/nitro/cookie.rb +34 -34
- data/lib/nitro/dispatcher.rb +195 -186
- data/lib/nitro/element.rb +132 -126
- data/lib/nitro/element/java_script.rb +6 -6
- data/lib/nitro/flash.rb +66 -66
- data/lib/nitro/mail.rb +192 -192
- data/lib/nitro/mixin/buffer.rb +66 -0
- data/lib/nitro/mixin/debug.rb +16 -16
- data/lib/nitro/mixin/form.rb +88 -0
- data/lib/nitro/mixin/helper.rb +2 -2
- data/lib/nitro/mixin/javascript.rb +108 -108
- data/lib/nitro/mixin/markup.rb +144 -0
- data/lib/nitro/mixin/pager.rb +202 -202
- data/lib/nitro/mixin/rss.rb +67 -0
- data/lib/nitro/mixin/table.rb +63 -0
- data/lib/nitro/mixin/xhtml.rb +75 -0
- data/lib/nitro/mixin/xml.rb +124 -0
- data/lib/nitro/render.rb +183 -359
- data/lib/nitro/request.rb +140 -140
- data/lib/nitro/response.rb +27 -27
- data/lib/nitro/routing.rb +21 -21
- data/lib/nitro/scaffold.rb +124 -118
- data/lib/nitro/server.rb +117 -80
- data/lib/nitro/server/runner.rb +341 -0
- data/lib/nitro/service.rb +12 -12
- data/lib/nitro/service/xmlrpc.rb +22 -22
- data/lib/nitro/session.rb +122 -120
- data/lib/nitro/session/drb.rb +9 -9
- data/lib/nitro/session/drbserver.rb +34 -34
- data/lib/nitro/template.rb +171 -155
- data/lib/nitro/testing/assertions.rb +90 -90
- data/lib/nitro/testing/context.rb +16 -16
- data/lib/nitro/testing/testcase.rb +34 -34
- data/proto/conf/lhttpd.conf +9 -9
- data/proto/public/error.xhtml +75 -75
- data/proto/public/index.xhtml +18 -18
- data/proto/public/js/behaviour.js +65 -65
- data/proto/public/js/controls.js +1 -1
- data/proto/public/js/prototype.js +3 -3
- data/proto/public/settings.xhtml +61 -61
- data/proto/run.rb +1 -5
- data/test/nitro/adapter/raw_post1.bin +0 -0
- data/test/nitro/adapter/tc_cgi.rb +57 -57
- data/test/nitro/adapter/tc_webrick.rb +4 -4
- data/test/nitro/mixin/tc_pager.rb +25 -25
- data/test/nitro/mixin/tc_rss.rb +24 -0
- data/test/nitro/mixin/tc_table.rb +31 -0
- data/test/nitro/mixin/tc_xhtml.rb +13 -0
- data/test/nitro/tc_caching.rb +10 -10
- data/test/nitro/tc_context.rb +8 -8
- data/test/nitro/tc_controller.rb +48 -48
- data/test/nitro/tc_cookie.rb +6 -6
- data/test/nitro/tc_dispatcher.rb +64 -64
- data/test/nitro/tc_element.rb +27 -27
- data/test/nitro/tc_flash.rb +31 -31
- data/test/nitro/tc_mail.rb +63 -63
- data/test/nitro/tc_server.rb +26 -26
- data/test/nitro/tc_session.rb +9 -9
- data/test/nitro/tc_template.rb +19 -19
- data/test/public/blog/list.xhtml +1 -1
- metadata +31 -37
- data/lib/nitro/buffering.rb +0 -45
- data/lib/nitro/builder/form.rb +0 -104
- data/lib/nitro/builder/rss.rb +0 -104
- data/lib/nitro/builder/table.rb +0 -80
- data/lib/nitro/builder/xhtml.rb +0 -132
- data/lib/nitro/builder/xml.rb +0 -131
- data/lib/nitro/conf.rb +0 -36
- data/lib/nitro/environment.rb +0 -21
- data/lib/nitro/errors.rb +0 -69
- data/lib/nitro/localization.rb +0 -153
- data/lib/nitro/markup.rb +0 -147
- data/lib/nitro/output.rb +0 -24
- data/lib/nitro/runner.rb +0 -348
- data/lib/nitro/shaders.rb +0 -206
- data/test/nitro/builder/tc_rss.rb +0 -23
- data/test/nitro/builder/tc_table.rb +0 -30
- data/test/nitro/builder/tc_xhtml.rb +0 -39
- data/test/nitro/builder/tc_xml.rb +0 -56
- data/test/nitro/tc_localization.rb +0 -49
data/lib/nitro/server.rb
CHANGED
@@ -1,89 +1,126 @@
|
|
1
1
|
require 'glue/autoreload'
|
2
|
-
|
2
|
+
|
3
|
+
require 'nitro/server/runner'
|
3
4
|
|
4
5
|
module Nitro
|
5
6
|
|
6
7
|
class Server
|
7
8
|
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
9
|
+
# The server listening address.
|
10
|
+
#--
|
11
|
+
# 0.0.0.0 may be a better default?
|
12
|
+
#++
|
13
|
+
|
14
|
+
setting :address, :default => '127.0.0.1', :doc => 'The server listening address'
|
15
|
+
|
16
|
+
# The server listening port.
|
17
|
+
|
18
|
+
setting :port, :default => 9999, :doc => 'The server listening port'
|
19
|
+
|
20
|
+
# The map.
|
21
|
+
|
22
|
+
setting :map, :default => { '/' => SimpleController }, :doc => 'The server map'
|
23
|
+
|
24
|
+
# The public files root directory.
|
25
|
+
|
26
|
+
setting :public_root, :default => 'public', :doc => 'The public files root directory'
|
27
|
+
|
28
|
+
# The access log, can be a path to a file or an IO object.
|
29
|
+
|
30
|
+
setting :access_log, :default => nil, :doc => 'The access log'
|
31
|
+
|
32
|
+
# The name of the application.
|
33
|
+
|
34
|
+
attr_accessor :name
|
35
|
+
|
36
|
+
# The sitemap. Defines how controller objects are published.
|
37
|
+
|
38
|
+
attr_accessor :map
|
39
|
+
|
40
|
+
# The public files root directory.
|
41
|
+
|
42
|
+
attr_accessor :public_root
|
43
|
+
|
44
|
+
# The server listening address.
|
45
|
+
|
46
|
+
attr_accessor :address
|
47
|
+
|
48
|
+
# The server listening port.
|
49
|
+
|
50
|
+
attr_accessor :port
|
51
|
+
|
52
|
+
# The dispatcher
|
53
|
+
|
54
|
+
attr_accessor :dispatcher
|
55
|
+
|
56
|
+
# Additional server options. Useful to pass options to
|
57
|
+
# Webrick for example.
|
58
|
+
|
59
|
+
attr_accessor :options
|
60
|
+
|
61
|
+
def initialize(name = 'Nitro', options = {})
|
62
|
+
@name = name
|
63
|
+
@map = self.class.map.dup
|
64
|
+
@address, @port = self.class.address, self.class.port
|
65
|
+
@public_root = self.class.public_root
|
66
|
+
@access_log = self.class.access_log
|
67
|
+
@options = options
|
68
|
+
end
|
69
|
+
|
70
|
+
# Return the dispatcher.
|
71
|
+
|
72
|
+
def dispatcher
|
73
|
+
unless @dispatcher
|
74
|
+
@dispatcher = Dispatcher.new(self.map)
|
75
|
+
end
|
76
|
+
@dispatcher
|
77
|
+
end
|
78
|
+
|
79
|
+
# Start the server.
|
80
|
+
|
81
|
+
def start(controller = nil)
|
82
|
+
@map['/'] = controller if controller
|
83
|
+
@dispatcher = Dispatcher.new(@map)
|
84
|
+
end
|
85
|
+
|
86
|
+
def root=(controller)
|
87
|
+
@map['/'] = controller
|
88
|
+
end
|
89
|
+
|
90
|
+
def root
|
91
|
+
Mounter.new(self)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Helper method.
|
95
|
+
|
96
|
+
def self.run(controller = nil)
|
97
|
+
runner = Runner.new
|
98
|
+
runner.setup_options
|
99
|
+
runner.setup_mode
|
100
|
+
runner.daemonize if runner.daemon
|
101
|
+
server = Server.new
|
102
|
+
server.start(controller)
|
103
|
+
runner.invoke(server)
|
104
|
+
end
|
105
|
+
|
106
|
+
# A Helper class used for CherryPy-style publishing.
|
107
|
+
|
108
|
+
class Mounter # :nodoc: all
|
109
|
+
def initialize(parent, base = '')
|
110
|
+
@parent, @base = parent, base
|
111
|
+
end
|
112
|
+
|
113
|
+
def method_missing(sym, *args)
|
114
|
+
sym = sym.to_s
|
115
|
+
if sym =~ /=$/
|
116
|
+
@parent.map["#@base/#{sym.gsub(/=/, '')}"] = args.first
|
117
|
+
else
|
118
|
+
Mounter.new(@parent, "#@base/#{sym}")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
87
124
|
end
|
88
125
|
|
89
126
|
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
require 'glue/misc'
|
4
|
+
require 'glue/configuration'
|
5
|
+
|
6
|
+
module Nitro
|
7
|
+
|
8
|
+
# The Runner is a helper class that encapsulates a web
|
9
|
+
# application and is responsible for launching the
|
10
|
+
# application in different modes.
|
11
|
+
#
|
12
|
+
# The runner provides default parsing of command line
|
13
|
+
# and environment parameters.
|
14
|
+
#
|
15
|
+
# The default execution modes are:
|
16
|
+
#
|
17
|
+
# :debug, :stage, :live
|
18
|
+
#
|
19
|
+
# You can implement your own, custom version of the Runner
|
20
|
+
# to run your custom web applications.
|
21
|
+
|
22
|
+
class Runner
|
23
|
+
|
24
|
+
# ...
|
25
|
+
|
26
|
+
setting :adapter, :default => :webrick, :doc => 'The web adapter'
|
27
|
+
|
28
|
+
# Execution mode = (:debug, :stage, :live)
|
29
|
+
#
|
30
|
+
# [:debug]
|
31
|
+
# useful when debugging, extra debug information
|
32
|
+
# is emmited, actions, templates and shaders are
|
33
|
+
# reloaded, etc. The execution speed of the application
|
34
|
+
# is impaired.
|
35
|
+
#
|
36
|
+
# [:stage]
|
37
|
+
# test the application with live parameters
|
38
|
+
# (typically on a staging server).
|
39
|
+
#
|
40
|
+
# [:live]
|
41
|
+
# use the parameters for the live (production)
|
42
|
+
# server. Optimized for speed.
|
43
|
+
#
|
44
|
+
# The default mode is :debug
|
45
|
+
|
46
|
+
attr_accessor :mode
|
47
|
+
|
48
|
+
# :start, :stop, :restart
|
49
|
+
|
50
|
+
attr_accessor :action
|
51
|
+
|
52
|
+
# The server used to run this web application.
|
53
|
+
# :webrick, :nitro, :lhttp, :apache, :mod_apache
|
54
|
+
#
|
55
|
+
# At the moment only :webrick and :lhttp are available.
|
56
|
+
|
57
|
+
attr_accessor :server
|
58
|
+
|
59
|
+
# Run as daemon.
|
60
|
+
|
61
|
+
attr_accessor :daemon
|
62
|
+
|
63
|
+
# Spidering mode. Acceptable values are :crawl, :render
|
64
|
+
# and false.
|
65
|
+
|
66
|
+
attr_accessor :spider
|
67
|
+
|
68
|
+
# Parse the command line arguments and the environment
|
69
|
+
# parameters to setup the application.
|
70
|
+
|
71
|
+
def setup_options
|
72
|
+
@mode ||= :debug
|
73
|
+
@action ||= :start
|
74
|
+
@server ||= :webrick
|
75
|
+
@daemon = false
|
76
|
+
@spider = false
|
77
|
+
|
78
|
+
# Setup from environment
|
79
|
+
|
80
|
+
@mode = ENV.fetch('NITRO_MODE', 'debug').to_sym
|
81
|
+
|
82
|
+
# Setup from command line arguments.
|
83
|
+
|
84
|
+
parser = OptionParser.new do |opts|
|
85
|
+
|
86
|
+
opts.banner = 'Usage: run.rb [options]'
|
87
|
+
opts.separator ''
|
88
|
+
opts.separator 'Specific options:'
|
89
|
+
|
90
|
+
opts.on('-s', '--start', 'Start application.') do
|
91
|
+
@action = :start
|
92
|
+
end
|
93
|
+
|
94
|
+
opts.on('-S', '--stop', 'Stop application.') do
|
95
|
+
@action = :stop
|
96
|
+
end
|
97
|
+
|
98
|
+
opts.on('-r', '--restart', 'Restart application.') do
|
99
|
+
@action = :restart
|
100
|
+
end
|
101
|
+
|
102
|
+
opts.on('-d', '--daemon', 'Run application as a daemon.') do
|
103
|
+
@daemon = true
|
104
|
+
end
|
105
|
+
|
106
|
+
opts.on('-D', '--debug', 'Run application in debug mode.') do
|
107
|
+
@mode = :debug
|
108
|
+
end
|
109
|
+
|
110
|
+
opts.on('-T', '--stage', 'Run application in stage mode.') do
|
111
|
+
@mode = :stage
|
112
|
+
end
|
113
|
+
|
114
|
+
opts.on('-L', '--live', 'Run application in live mode.') do
|
115
|
+
@mode = :live
|
116
|
+
end
|
117
|
+
|
118
|
+
opts.on('-w', '--webrick', 'Use a webrick server [default].') do
|
119
|
+
@server = :webrick
|
120
|
+
end
|
121
|
+
|
122
|
+
opts.on('-l', '--lhttpd', 'Use a lighttpd server.') do
|
123
|
+
@server = :lhttpd
|
124
|
+
Logger.set(Logger.new('log/app.log'))
|
125
|
+
end
|
126
|
+
|
127
|
+
opts.on('-a', '--apache', 'Use an apache server.') do
|
128
|
+
@server = :apache
|
129
|
+
Logger.set(Logger.new('log/app.log'))
|
130
|
+
end
|
131
|
+
|
132
|
+
opts.on('--apache-cgi', 'Run as CGI (Apache)') do
|
133
|
+
@server = :cgi
|
134
|
+
Logger.set(Logger.new('log/app.log'))
|
135
|
+
end
|
136
|
+
|
137
|
+
opts.on('-C', '--console', 'Start a console attached to an instance of the application.') do
|
138
|
+
if RUBY_PLATFORM =~ /mswin32/
|
139
|
+
irb_name = 'irb.bat'
|
140
|
+
else
|
141
|
+
irb_name = 'irb'
|
142
|
+
end
|
143
|
+
ENV['NITRO_INVOKE'] = 'irb'
|
144
|
+
conf_file = File.basename(caller.last.split(':').first)
|
145
|
+
exec "#{irb_name} -r #{conf_file} -r irb/completion --noinspect"
|
146
|
+
exit
|
147
|
+
end
|
148
|
+
|
149
|
+
opts.on('--crawl', 'Crawl the application.') do
|
150
|
+
@server = :webrick
|
151
|
+
@spider = :crawl
|
152
|
+
end
|
153
|
+
|
154
|
+
opts.on('--render', 'Crawl the application and render all pages as static html files.') do
|
155
|
+
@server = :webrick
|
156
|
+
@spider = :render
|
157
|
+
end
|
158
|
+
|
159
|
+
opts.on_tail('-v', '--version', 'Show version.') do
|
160
|
+
puts "Nitro #{Nitro::Version}"
|
161
|
+
exit
|
162
|
+
end
|
163
|
+
|
164
|
+
opts.on_tail('-h', '--help', 'Show this message.') do
|
165
|
+
puts opts
|
166
|
+
exit
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
parser.parse!(ARGV)
|
172
|
+
|
173
|
+
return self
|
174
|
+
end
|
175
|
+
|
176
|
+
# Setup the declared execution mode,
|
177
|
+
# using the passed configuration parameters.
|
178
|
+
|
179
|
+
def setup_mode
|
180
|
+
case @mode
|
181
|
+
when :debug
|
182
|
+
setup_debug
|
183
|
+
|
184
|
+
when :stage
|
185
|
+
setup_stage
|
186
|
+
|
187
|
+
when :live
|
188
|
+
setup_live
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# Setup in debug mode.
|
193
|
+
|
194
|
+
def setup_debug
|
195
|
+
$DBG = true
|
196
|
+
Compiler.reload = true
|
197
|
+
require 'glue/autoreload'
|
198
|
+
autoreload(3)
|
199
|
+
Caching.caching_enabled = false
|
200
|
+
|
201
|
+
load_external_configuration(:debug)
|
202
|
+
end
|
203
|
+
|
204
|
+
def setup_stage
|
205
|
+
$DBG = false
|
206
|
+
Compiler.reload = true
|
207
|
+
Logger.set(Logger.new('log/app.log'))
|
208
|
+
|
209
|
+
load_external_configuration(:stage)
|
210
|
+
end
|
211
|
+
|
212
|
+
def setup_live
|
213
|
+
$DBG = false
|
214
|
+
Compiler.reload = false
|
215
|
+
Logger.set(Logger.new('log/app.log'))
|
216
|
+
|
217
|
+
load_external_configuration(:live)
|
218
|
+
load_external_configuration(:production)
|
219
|
+
end
|
220
|
+
alias_method :setup_production, :setup_live
|
221
|
+
|
222
|
+
# ...
|
223
|
+
|
224
|
+
def invoke(server)
|
225
|
+
if 'fcgi_proc' == ENV['NITRO_INVOKE']
|
226
|
+
require 'nitro/adapter/fastcgi'
|
227
|
+
FastCGI.start(server)
|
228
|
+
|
229
|
+
elsif 'cgi_proc' == ENV['NITRO_INVOKE']
|
230
|
+
require 'nitro/adapter/cgi'
|
231
|
+
Cgi.start(server)
|
232
|
+
|
233
|
+
elsif 'irb' == ENV['NITRO_INVOKE']
|
234
|
+
$server = server
|
235
|
+
|
236
|
+
else
|
237
|
+
invoke_server(server)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# ...
|
242
|
+
|
243
|
+
def invoke_server(server)
|
244
|
+
spider_thread = nil
|
245
|
+
|
246
|
+
case @action
|
247
|
+
when :start
|
248
|
+
|
249
|
+
case @spider
|
250
|
+
when :render
|
251
|
+
spider_thread = Thread.new do
|
252
|
+
sleep(6)
|
253
|
+
`wget -k -m -p #{server.address}:#{server.port} -directory-prefix=rendered`
|
254
|
+
end
|
255
|
+
when :crawl
|
256
|
+
spider_thread = Thread.new do
|
257
|
+
sleep(6)
|
258
|
+
`wget -m --spider #{server.host}:#{server.port}`
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
@server ||= Runner.adapter
|
263
|
+
|
264
|
+
puts "\n==> Listening at #{server.address}:#{server.port}. (#{@mode} mode)\n\n"
|
265
|
+
|
266
|
+
case @server
|
267
|
+
when :webrick
|
268
|
+
require 'nitro/adapter/webrick'
|
269
|
+
Webrick.start(server)
|
270
|
+
|
271
|
+
when :lhttpd
|
272
|
+
require 'nitro/adapter/fastcgi'
|
273
|
+
`lighttpd -f conf/lhttpd.conf`
|
274
|
+
|
275
|
+
when :apache
|
276
|
+
require 'nitro/adapter/fastcgi'
|
277
|
+
`apachectl -d #{Dir.pwd} -f conf/apache.conf -k start`
|
278
|
+
|
279
|
+
when :cgi
|
280
|
+
require 'nitro/adapter/cgi'
|
281
|
+
end
|
282
|
+
|
283
|
+
when :stop
|
284
|
+
|
285
|
+
case @server
|
286
|
+
when :webrick
|
287
|
+
|
288
|
+
when :lhttpd
|
289
|
+
|
290
|
+
when :apache
|
291
|
+
`apachectl -d #{Dir.pwd} -f conf/apache.conf -k stop`
|
292
|
+
end
|
293
|
+
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# :section: Utilities
|
298
|
+
|
299
|
+
# Run this proccess as a daemon (UNIX only).
|
300
|
+
|
301
|
+
def daemonize
|
302
|
+
require 'daemons/daemonize'
|
303
|
+
pwd = Dir.pwd
|
304
|
+
Daemonize.daemonize(File.join(pwd, 'log/app.log'))
|
305
|
+
# Restore the original pwd (daemonize sets the
|
306
|
+
# pwd to '/').
|
307
|
+
Dir.chdir(pwd)
|
308
|
+
# Set the logger to a file (daemonize closes the
|
309
|
+
# std streams).
|
310
|
+
Logger.set(Logger.new('log/app.log'))
|
311
|
+
end
|
312
|
+
|
313
|
+
# Attempt to load external configuration in Ruby or
|
314
|
+
# YAML format. The files:
|
315
|
+
#
|
316
|
+
# * conf/mode.rb
|
317
|
+
# * conf/mode.yaml
|
318
|
+
#
|
319
|
+
# are considered.
|
320
|
+
|
321
|
+
def load_external_configuration(mode = :debug)
|
322
|
+
begin
|
323
|
+
# gmosx: Workaround for an RDoc bug.
|
324
|
+
# require "conf/#{mode}.rb"
|
325
|
+
eval %|require 'conf/#{mode}.rb'|
|
326
|
+
rescue Object
|
327
|
+
end
|
328
|
+
|
329
|
+
# Try to configure from a yaml file.
|
330
|
+
begin
|
331
|
+
Configuration.load "conf/#{mode}.yml"
|
332
|
+
rescue Object => ex
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
337
|
+
|
338
|
+
end
|
339
|
+
|
340
|
+
# * George Moschovitis <gm@navel.gr>
|
341
|
+
# * James Britt <james_b@neurogami.com>
|