merb-core 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +61 -11
- data/bin/merb +5 -1
- data/lib/merb-core.rb +202 -25
- data/lib/merb-core/autoload.rb +19 -17
- data/lib/merb-core/bootloader.rb +84 -71
- data/lib/merb-core/config.rb +19 -14
- data/lib/merb-core/controller/abstract_controller.rb +16 -17
- data/lib/merb-core/controller/exceptions.rb +115 -70
- data/lib/merb-core/controller/merb_controller.rb +62 -38
- data/lib/merb-core/controller/mime.rb +1 -1
- data/lib/merb-core/controller/mixins/authentication.rb +87 -0
- data/lib/merb-core/controller/mixins/controller.rb +16 -15
- data/lib/merb-core/controller/mixins/render.rb +113 -19
- data/lib/merb-core/controller/mixins/responder.rb +8 -2
- data/lib/merb-core/controller/template.rb +1 -1
- data/lib/merb-core/core_ext.rb +1 -0
- data/lib/merb-core/core_ext/class.rb +113 -6
- data/lib/merb-core/core_ext/hash.rb +43 -39
- data/lib/merb-core/core_ext/kernel.rb +75 -38
- data/lib/merb-core/core_ext/mash.rb +4 -4
- data/lib/merb-core/core_ext/object.rb +18 -7
- data/lib/merb-core/core_ext/set.rb +9 -4
- data/lib/merb-core/core_ext/string.rb +29 -9
- data/lib/merb-core/core_ext/time.rb +13 -0
- data/lib/merb-core/dispatch/cookies.rb +1 -2
- data/lib/merb-core/dispatch/dispatcher.rb +18 -10
- data/lib/merb-core/dispatch/exceptions.html.erb +1 -1
- data/lib/merb-core/dispatch/request.rb +3 -0
- data/lib/merb-core/dispatch/router.rb +10 -7
- data/lib/merb-core/dispatch/router/behavior.rb +36 -27
- data/lib/merb-core/dispatch/router/route.rb +7 -2
- data/lib/merb-core/dispatch/session/cookie.rb +4 -4
- data/lib/merb-core/dispatch/session/memcached.rb +17 -5
- data/lib/merb-core/logger.rb +2 -2
- data/lib/merb-core/plugins.rb +16 -4
- data/lib/merb-core/rack/adapter/ebb.rb +4 -1
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -0
- data/lib/merb-core/rack/adapter/fcgi.rb +1 -0
- data/lib/merb-core/rack/adapter/mongrel.rb +1 -0
- data/lib/merb-core/rack/adapter/runner.rb +1 -0
- data/lib/merb-core/rack/adapter/thin.rb +3 -1
- data/lib/merb-core/rack/adapter/webrick.rb +1 -0
- data/lib/merb-core/rack/application.rb +17 -1
- data/lib/merb-core/server.rb +78 -28
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -3
- data/lib/merb-core/test/helpers/request_helper.rb +81 -27
- data/lib/merb-core/test/helpers/view_helper.rb +1 -1
- data/lib/merb-core/test/matchers/controller_matchers.rb +55 -5
- data/lib/merb-core/test/matchers/route_matchers.rb +8 -17
- data/lib/merb-core/test/matchers/view_matchers.rb +53 -11
- data/lib/merb-core/test/run_specs.rb +22 -14
- data/lib/merb-core/test/tasks/spectasks.rb +54 -33
- data/lib/merb-core/vendor/facets/inflect.rb +91 -2
- data/lib/merb-core/version.rb +2 -2
- data/spec/private/config/config_spec.rb +54 -26
- data/spec/private/core_ext/class_spec.rb +22 -0
- data/spec/private/core_ext/hash_spec.rb +70 -54
- data/spec/private/core_ext/kernel_spec.rb +149 -14
- data/spec/private/core_ext/object_spec.rb +92 -10
- data/spec/private/core_ext/string_spec.rb +162 -4
- data/spec/private/core_ext/time_spec.rb +16 -0
- data/spec/private/dispatch/bootloader_spec.rb +24 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +1 -1
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +1 -1
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +1 -1
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +1 -1
- data/spec/private/dispatch/fixture/config/black_hole.rb +12 -0
- data/spec/private/dispatch/fixture/log/merb_test.log +138 -0
- data/spec/private/plugins/plugin_spec.rb +79 -8
- data/spec/private/rack/application_spec.rb +1 -1
- data/spec/public/abstract_controller/controllers/filters.rb +26 -0
- data/spec/public/abstract_controller/controllers/helpers.rb +2 -2
- data/spec/public/abstract_controller/controllers/partial.rb +2 -2
- data/spec/public/abstract_controller/controllers/render.rb +16 -4
- data/spec/public/abstract_controller/filter_spec.rb +8 -0
- data/spec/public/abstract_controller/render_spec.rb +12 -0
- data/spec/public/controller/authentication_spec.rb +103 -0
- data/spec/public/controller/base_spec.rb +4 -3
- data/spec/public/controller/controllers/authentication.rb +47 -0
- data/spec/public/controller/controllers/base.rb +1 -0
- data/spec/public/controller/controllers/display.rb +30 -0
- data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +1 -0
- data/spec/public/controller/display_spec.rb +17 -0
- data/spec/public/controller/spec_helper.rb +1 -0
- data/spec/public/controller/url_spec.rb +25 -7
- data/spec/public/core/merb_core_spec.rb +34 -0
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +2 -2
- data/spec/public/directory_structure/directory/log/merb_test.log +48 -0
- data/spec/public/logger/logger_spec.rb +10 -4
- data/spec/public/reloading/directory/app/controllers/reload.rb +1 -1
- data/spec/public/reloading/directory/log/merb_test.log +13 -0
- data/spec/public/reloading/reload_spec.rb +23 -22
- data/spec/public/request/request_spec.rb +2 -0
- data/spec/public/router/nested_resources_spec.rb +7 -0
- data/spec/public/router/resources_spec.rb +46 -1
- data/spec/public/router/special_spec.rb +5 -1
- data/spec/public/test/controller_matchers_spec.rb +25 -1
- data/spec/public/test/controllers/spec_helper_controller.rb +8 -0
- data/spec/public/test/request_helper_spec.rb +52 -1
- data/spec/public/test/route_matchers_spec.rb +27 -25
- data/spec/public/test/view_helper_spec.rb +1 -1
- data/spec/public/test/view_matchers_spec.rb +148 -72
- metadata +23 -3
data/Rakefile
CHANGED
@@ -40,7 +40,7 @@ spec = Gem::Specification.new do |s|
|
|
40
40
|
s.platform = Gem::Platform::RUBY
|
41
41
|
s.author = "Ezra Zygmuntowicz"
|
42
42
|
s.email = "ez@engineyard.com"
|
43
|
-
s.homepage = "http://
|
43
|
+
s.homepage = "http://merbivore.com"
|
44
44
|
s.summary = "Merb. Pocket rocket web framework."
|
45
45
|
s.bindir = "bin"
|
46
46
|
s.description = s.summary
|
@@ -85,6 +85,40 @@ task :uninstall => :clean do
|
|
85
85
|
sh %{#{SUDO} gem uninstall #{NAME}}
|
86
86
|
end
|
87
87
|
|
88
|
+
namespace :github do
|
89
|
+
desc "Update Github Gemspec"
|
90
|
+
task :update_gemspec do
|
91
|
+
skip_fields = %w(new_platform original_platform)
|
92
|
+
integer_fields = %w(specification_version)
|
93
|
+
|
94
|
+
result = "Gem::Specification.new do |s|\n"
|
95
|
+
spec.instance_variables.each do |ivar|
|
96
|
+
value = spec.instance_variable_get(ivar)
|
97
|
+
name = ivar.split("@").last
|
98
|
+
next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
|
99
|
+
if name == "dependencies"
|
100
|
+
value.each do |d|
|
101
|
+
dep, *ver = d.to_s.split(" ")
|
102
|
+
result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
|
103
|
+
end
|
104
|
+
else
|
105
|
+
case value
|
106
|
+
when Array
|
107
|
+
value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
|
108
|
+
when String
|
109
|
+
value = value.to_i if integer_fields.include?(name)
|
110
|
+
value = value.inspect
|
111
|
+
else
|
112
|
+
value = value.to_s.inspect
|
113
|
+
end
|
114
|
+
result << " s.#{name} = #{value}\n"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
result << "end"
|
118
|
+
File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
88
122
|
##############################################################################
|
89
123
|
# Documentation
|
90
124
|
##############################################################################
|
@@ -127,20 +161,36 @@ task :aok => [:specs, :rcov]
|
|
127
161
|
# t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
128
162
|
# end
|
129
163
|
|
130
|
-
def setup_specs(name, spec_cmd='spec')
|
164
|
+
def setup_specs(name, spec_cmd='spec', run_opts = "-c -f s")
|
131
165
|
desc "Run all specs (#{name})"
|
132
166
|
task "specs:#{name}" do
|
133
|
-
run_specs("spec/**/*_spec.rb", spec_cmd)
|
167
|
+
run_specs("spec/**/*_spec.rb", spec_cmd, ENV['RSPEC_OPTS'] || run_opts)
|
134
168
|
end
|
135
169
|
|
136
170
|
desc "Run private specs (#{name})"
|
137
171
|
task "specs:#{name}:private" do
|
138
|
-
run_specs("spec/private/**/*_spec.rb", spec_cmd)
|
172
|
+
run_specs("spec/private/**/*_spec.rb", spec_cmd, ENV['RSPEC_OPTS'] || run_opts)
|
139
173
|
end
|
140
174
|
|
141
175
|
desc "Run public specs (#{name})"
|
142
176
|
task "specs:#{name}:public" do
|
143
|
-
run_specs("spec/public/**/*_spec.rb", spec_cmd)
|
177
|
+
run_specs("spec/public/**/*_spec.rb", spec_cmd, ENV['RSPEC_OPTS'] || run_opts)
|
178
|
+
end
|
179
|
+
|
180
|
+
# With profiling formatter
|
181
|
+
desc "Run all specs (#{name}) with profiling formatter"
|
182
|
+
task "specs:#{name}_profiled" do
|
183
|
+
run_specs("spec/**/*_spec.rb", spec_cmd, "-c -f o")
|
184
|
+
end
|
185
|
+
|
186
|
+
desc "Run private specs (#{name}) with profiling formatter"
|
187
|
+
task "specs:#{name}_profiled:private" do
|
188
|
+
run_specs("spec/private/**/*_spec.rb", spec_cmd, "-c -f o")
|
189
|
+
end
|
190
|
+
|
191
|
+
desc "Run public specs (#{name}) with profiling formatter"
|
192
|
+
task "specs:#{name}_profiled:public" do
|
193
|
+
run_specs("spec/public/**/*_spec.rb", spec_cmd, "-c -f o")
|
144
194
|
end
|
145
195
|
end
|
146
196
|
|
@@ -244,7 +294,7 @@ namespace :repo do
|
|
244
294
|
system "svn update"
|
245
295
|
end
|
246
296
|
end
|
247
|
-
|
297
|
+
|
248
298
|
desc "commit modified changes to the repository"
|
249
299
|
task :commit do
|
250
300
|
if File.directory?(".git")
|
@@ -253,24 +303,24 @@ namespace :repo do
|
|
253
303
|
system "svn commit"
|
254
304
|
end
|
255
305
|
end
|
256
|
-
|
306
|
+
|
257
307
|
end
|
258
308
|
|
259
309
|
# Run specific tests or test files. Searches nested spec directories as well.
|
260
|
-
#
|
310
|
+
#
|
261
311
|
# Based on a technique popularized by Geoffrey Grosenbach
|
262
312
|
rule "" do |t|
|
263
313
|
spec_cmd = (RUBY_PLATFORM =~ /java/) ? "jruby -S spec" : "spec"
|
264
314
|
# spec:spec_file:spec_name
|
265
315
|
if /spec:(.*)$/.match(t.name)
|
266
316
|
arguments = t.name.split(':')
|
267
|
-
|
317
|
+
|
268
318
|
file_name = arguments[1]
|
269
319
|
spec_name = arguments[2..-1]
|
270
320
|
|
271
321
|
spec_filename = "#{file_name}_spec.rb"
|
272
322
|
specs = Dir["spec/**/#{spec_filename}"]
|
273
|
-
|
323
|
+
|
274
324
|
if path = specs.detect { |f| spec_filename == File.basename(f) }
|
275
325
|
run_file_name = path
|
276
326
|
else
|
@@ -279,7 +329,7 @@ rule "" do |t|
|
|
279
329
|
end
|
280
330
|
|
281
331
|
example = " -e '#{spec_name}'" unless spec_name.empty?
|
282
|
-
|
332
|
+
|
283
333
|
sh "#{spec_cmd} #{run_file_name} --format specdoc --colour #{example}"
|
284
334
|
end
|
285
335
|
end
|
data/bin/merb
CHANGED
data/lib/merb-core.rb
CHANGED
@@ -14,6 +14,7 @@ module Merb
|
|
14
14
|
class << self
|
15
15
|
|
16
16
|
# Startup Merb by setting up the Config and starting the server.
|
17
|
+
# This is where Merb application environment and root path are set.
|
17
18
|
#
|
18
19
|
# ==== Parameters
|
19
20
|
# argv<String, Hash>::
|
@@ -26,9 +27,16 @@ module Merb
|
|
26
27
|
end
|
27
28
|
Merb.environment = Merb::Config[:environment]
|
28
29
|
Merb.root = Merb::Config[:merb_root]
|
29
|
-
|
30
|
+
case Merb::Config[:action]
|
31
|
+
when :kill
|
32
|
+
Merb::Server.kill(Merb::Config[:port], 1)
|
33
|
+
when :kill_9
|
34
|
+
Merb::Server.kill(Merb::Config[:port], 9)
|
35
|
+
else
|
36
|
+
Merb::Server.start(Merb::Config[:port], Merb::Config[:cluster])
|
37
|
+
end
|
30
38
|
end
|
31
|
-
|
39
|
+
|
32
40
|
# Start the Merb environment, but only if it hasn't been loaded yet.
|
33
41
|
#
|
34
42
|
# ==== Parameters
|
@@ -40,7 +48,7 @@ module Merb
|
|
40
48
|
@started = true
|
41
49
|
end
|
42
50
|
end
|
43
|
-
|
51
|
+
|
44
52
|
# Restart the Merb environment explicitly.
|
45
53
|
#
|
46
54
|
# ==== Parameters
|
@@ -52,14 +60,53 @@ module Merb
|
|
52
60
|
end
|
53
61
|
|
54
62
|
attr_accessor :environment, :load_paths, :adapter
|
55
|
-
|
63
|
+
|
56
64
|
alias :env :environment
|
57
|
-
|
65
|
+
|
58
66
|
Merb.load_paths = Hash.new { [Merb.root] } unless Merb.load_paths.is_a?(Hash)
|
59
67
|
|
60
|
-
# This is the core mechanism for setting up your application layout
|
61
|
-
#
|
62
|
-
#
|
68
|
+
# This is the core mechanism for setting up your application layout.
|
69
|
+
# There are three application layouts in Merb:
|
70
|
+
#
|
71
|
+
# Regular app/:type layout of Ruby on Rails fame:
|
72
|
+
#
|
73
|
+
# app/models for models
|
74
|
+
# app/mailers for mailers (special type of controllers)
|
75
|
+
# app/parts for parts, Merb components
|
76
|
+
# app/views for templates
|
77
|
+
# app/controllers for controller
|
78
|
+
# lib for libraries
|
79
|
+
#
|
80
|
+
# Flat application layout:
|
81
|
+
#
|
82
|
+
# application.rb for models, controllers, mailers, etc
|
83
|
+
# config/init.rb for initialization and router configuration
|
84
|
+
# config/framework.rb for framework and dependencies configuration
|
85
|
+
# views for views
|
86
|
+
#
|
87
|
+
# and Camping-style "very flat" application layout, where the whole Merb
|
88
|
+
# application and configs fit into a single file.
|
89
|
+
#
|
90
|
+
# ==== Notes
|
91
|
+
# Autoloading for lib uses empty glob by default. If you
|
92
|
+
# want to have your libraries under lib use autoload, add
|
93
|
+
# the following to Merb init file:
|
94
|
+
#
|
95
|
+
# Merb.push_path(:lib, Merb.root / "lib", "**/*.rb") # glob set explicity.
|
96
|
+
#
|
97
|
+
# Then lib/magicwand/lib/magicwand.rb with MagicWand module will
|
98
|
+
# be autoloaded when you first access that constant.
|
99
|
+
#
|
100
|
+
# ==== Examples
|
101
|
+
# This method gives you a way to build up your own application
|
102
|
+
# structure, for instance, to reflect the structure Rails
|
103
|
+
# uses to simplify transition of legacy application, you can
|
104
|
+
# set it up like this:
|
105
|
+
#
|
106
|
+
# Merb.push_path(:models, Merb.root / "app" / "models", "**/*.rb")
|
107
|
+
# Merb.push_path(:mailers, Merb.root / "app" / "models", "**/*.rb")
|
108
|
+
# Merb.push_path(:controllers, Merb.root / "app" / "controllers", "**/*.rb")
|
109
|
+
# Merb.push_path(:views, Merb.root / "app" / "views", "**/*.rb")
|
63
110
|
#
|
64
111
|
# ==== Parameters
|
65
112
|
# type<Symbol>:: The type of path being registered (i.e. :view)
|
@@ -72,6 +119,23 @@ module Merb
|
|
72
119
|
load_paths[type] = [path, file_glob]
|
73
120
|
end
|
74
121
|
|
122
|
+
# Removes given types of application components
|
123
|
+
# from load path Merb uses for autoloading.
|
124
|
+
#
|
125
|
+
# ==== Parameters
|
126
|
+
# *args<Array(Symbol)>::
|
127
|
+
# components names, for instance, :views, :models
|
128
|
+
#
|
129
|
+
# ==== Examples
|
130
|
+
# Using this combined with Merb::GlobalHelpers.push_path
|
131
|
+
# you can make your Merb application use legacy Rails
|
132
|
+
# application components.
|
133
|
+
#
|
134
|
+
# Merb.root = "path/to/legacy/app/root"
|
135
|
+
# Merb.remove_paths(:mailers)
|
136
|
+
# Merb.push_path(:mailers, Merb.root / "app" / "models", "**/*.rb")
|
137
|
+
#
|
138
|
+
# Will make Merb use app/models for mailers just like Ruby on Rails does.
|
75
139
|
def remove_paths(*args)
|
76
140
|
args.each {|arg| load_paths.delete(arg)}
|
77
141
|
end
|
@@ -134,7 +198,7 @@ module Merb
|
|
134
198
|
end
|
135
199
|
|
136
200
|
# ==== Returns
|
137
|
-
# String::
|
201
|
+
# String:: Path to directory that contains the log file.
|
138
202
|
def log_path
|
139
203
|
case Merb::Config[:log_file]
|
140
204
|
when String then File.dirname(Merb::Config[:log_file])
|
@@ -143,9 +207,27 @@ module Merb
|
|
143
207
|
end
|
144
208
|
|
145
209
|
# ==== Returns
|
146
|
-
# String:: The root directory of the Merb framework.
|
210
|
+
# String:: The path of root directory of the Merb framework.
|
147
211
|
def framework_root() @framework_root ||= File.dirname(__FILE__) end
|
148
212
|
|
213
|
+
# ==== Returns
|
214
|
+
# RegExp::
|
215
|
+
# Regular expression against which deferred actions
|
216
|
+
# are matched by Rack application handler.
|
217
|
+
#
|
218
|
+
# ==== Notes
|
219
|
+
# Concatenates :deferred_actions configuration option
|
220
|
+
# values.
|
221
|
+
def deferred_actions
|
222
|
+
@deferred ||= begin
|
223
|
+
if Merb::Config[:deferred_actions].empty?
|
224
|
+
/^\0$/
|
225
|
+
else
|
226
|
+
/#{Merb::Config[:deferred_actions].join("|")}/
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
149
231
|
# Allows flat apps by setting no default framework directories and yielding
|
150
232
|
# a Merb::Router instance. This is optional since the router will
|
151
233
|
# automatically configure the app with default routes.
|
@@ -173,6 +255,10 @@ module Merb
|
|
173
255
|
# name<~to_s>:: Name of the session type to register.
|
174
256
|
# file<String>:: The file that defines this session type.
|
175
257
|
# description<String>:: An optional description of the session type.
|
258
|
+
#
|
259
|
+
# ==== Notes
|
260
|
+
# Merb currently supports memory, cookie and memcache session
|
261
|
+
# types.
|
176
262
|
def register_session_type(name, file, description = nil)
|
177
263
|
@registered_session_types ||= Dictionary.new
|
178
264
|
@registered_session_types[name] = {
|
@@ -185,24 +271,86 @@ module Merb
|
|
185
271
|
|
186
272
|
# ==== Returns
|
187
273
|
# Boolean:: True if Merb is running via script/frozen-merb or other freezer.
|
274
|
+
#
|
275
|
+
# ==== Notes
|
276
|
+
# Freezing means bundling framework libraries with your application
|
277
|
+
# making it independent from environment it runs in. This is a good
|
278
|
+
# practice to freeze application framework and gems it uses and
|
279
|
+
# very useful when application is run in some sort of sandbox,
|
280
|
+
# for instance, shared hosting with preconfigured gems.
|
188
281
|
def frozen?
|
189
282
|
@frozen
|
190
283
|
end
|
191
284
|
|
192
285
|
# Used by script/frozen-merb and other freezers to mark Merb as frozen.
|
286
|
+
# See Merb::GlobalHelpers.frozen? for more details on framework freezing.
|
193
287
|
def frozen!
|
194
288
|
@frozen = true
|
195
289
|
end
|
196
|
-
|
290
|
+
|
197
291
|
# Load configuration and assign logger.
|
198
292
|
#
|
199
293
|
# ==== Parameters
|
200
294
|
# options<Hash>:: Options to pass on to the Merb config.
|
295
|
+
#
|
296
|
+
# ==== Options
|
297
|
+
# :host<String>:: host to bind to,
|
298
|
+
# default is 0.0.0.0.
|
299
|
+
#
|
300
|
+
# :port<Fixnum>:: port to run Merb application on,
|
301
|
+
# default is 4000.
|
302
|
+
#
|
303
|
+
# :adapter<String>:: name of Rack adapter to use,
|
304
|
+
# default is "runner"
|
305
|
+
#
|
306
|
+
# :rackup<String>:: name of Rack init file to use,
|
307
|
+
# default is "rack.rb"
|
308
|
+
#
|
309
|
+
# :reload_classes<Boolean>:: whether Merb should reload
|
310
|
+
# classes on each request,
|
311
|
+
# default is true
|
312
|
+
#
|
313
|
+
# :environment<String>:: name of environment to use,
|
314
|
+
# default is development
|
315
|
+
#
|
316
|
+
# :merb_root<String>:: Merb application root,
|
317
|
+
# default is Dir.pwd
|
318
|
+
#
|
319
|
+
# :use_mutex<Boolean>:: turns action dispatch synchronization
|
320
|
+
# on or off, default is on (true)
|
321
|
+
#
|
322
|
+
# :session_id_key<String>:: session identifier,
|
323
|
+
# default is _session_id
|
324
|
+
#
|
325
|
+
# :log_delimiter<String>:: what Merb logger uses as delimiter
|
326
|
+
# between message sections, default is " ~ "
|
327
|
+
#
|
328
|
+
# :log_auto_flush<Boolean>:: whether the log should automatically
|
329
|
+
# flush after new messages are
|
330
|
+
# added, defaults to true.
|
331
|
+
#
|
332
|
+
# :log_file<IO>:: IO for logger. Default is STDOUT.
|
333
|
+
#
|
334
|
+
# :log_level<Symbol>:: logger level, default is :warn
|
335
|
+
#
|
336
|
+
# :disabled_components<Array[Symbol]>::
|
337
|
+
# array of disabled component names,
|
338
|
+
# for instance, to disable json gem,
|
339
|
+
# specify :json. Default is empty array.
|
340
|
+
#
|
341
|
+
# :deferred_actions<Array(Symbol, String)]>::
|
342
|
+
# names of actions that should be deferred
|
343
|
+
# no matter what controller they belong to.
|
344
|
+
# Default is empty array.
|
345
|
+
#
|
346
|
+
# Some of these options come from command line on Merb
|
347
|
+
# application start, some of them are set in Merb init file
|
348
|
+
# or environment-specific.
|
201
349
|
def load_config(options = {})
|
202
350
|
Merb::Config.setup({ :log_file => STDOUT, :log_level => :warn, :log_auto_flush => true }.merge(options))
|
203
351
|
Merb::BootLoader::Logger.run
|
204
352
|
end
|
205
|
-
|
353
|
+
|
206
354
|
# Load all basic dependencies (selected BootLoaders only).
|
207
355
|
#
|
208
356
|
# ==== Parameters
|
@@ -213,18 +361,32 @@ module Merb
|
|
213
361
|
Merb::BootLoader::Dependencies.run
|
214
362
|
Merb::BootLoader::BeforeAppRuns.run
|
215
363
|
end
|
216
|
-
|
217
|
-
# Reload
|
364
|
+
|
365
|
+
# Reload application and framework classes.
|
366
|
+
# See Merb::BootLoader::ReloadClasses for details.
|
218
367
|
def reload
|
219
368
|
Merb::BootLoader::ReloadClasses.reload
|
220
369
|
end
|
221
|
-
|
370
|
+
|
222
371
|
# ==== Returns
|
223
|
-
# Boolean:: True if Merb is
|
372
|
+
# Boolean:: True if Merb environment is testing for instance,
|
373
|
+
# Merb is running with RSpec, Test::Unit of other testing facility.
|
224
374
|
def testing?
|
225
375
|
$TESTING || Merb::Config[:testing]
|
226
376
|
end
|
227
377
|
|
378
|
+
# Ask the question about which environment you're in.
|
379
|
+
# ==== Parameters
|
380
|
+
# env<Symbol, String>:: Name of the environment to query
|
381
|
+
#
|
382
|
+
# ==== Examples
|
383
|
+
# Merb.env #=> production
|
384
|
+
# Merb.env?(:production) #=> true
|
385
|
+
# Merb.env?(:development) #=> false
|
386
|
+
def env?(env)
|
387
|
+
Merb.env == env.to_s
|
388
|
+
end
|
389
|
+
|
228
390
|
# If block was given configures using the block.
|
229
391
|
#
|
230
392
|
# ==== Parameters
|
@@ -233,6 +395,10 @@ module Merb
|
|
233
395
|
# ==== Returns
|
234
396
|
# Hash:: The current configuration.
|
235
397
|
#
|
398
|
+
# ==== Notes
|
399
|
+
# See Merb::GlobalHelpers.load_config for configuration
|
400
|
+
# options list.
|
401
|
+
#
|
236
402
|
# ==== Examples
|
237
403
|
# Merb.config do
|
238
404
|
# beer "good"
|
@@ -244,13 +410,13 @@ module Merb
|
|
244
410
|
# session_secret_key "0d05a226affa226623eb18700"
|
245
411
|
# exception_details true
|
246
412
|
# reload_classes true
|
247
|
-
# reload_time 0.5
|
413
|
+
# reload_time 0.5
|
248
414
|
# end
|
249
415
|
def config(&block)
|
250
416
|
Merb::Config.configure(&block) if block_given?
|
251
417
|
Config
|
252
418
|
end
|
253
|
-
|
419
|
+
|
254
420
|
# Disables the given core components, like a Gem for example.
|
255
421
|
#
|
256
422
|
# ==== Parameters
|
@@ -258,37 +424,48 @@ module Merb
|
|
258
424
|
def disable(*components)
|
259
425
|
disabled_components.push *components
|
260
426
|
end
|
261
|
-
|
427
|
+
|
262
428
|
# ==== Parameters
|
263
429
|
# Array:: All components that should be disabled.
|
264
430
|
def disabled_components=(components)
|
265
431
|
disabled_components.replace components
|
266
432
|
end
|
267
|
-
|
433
|
+
|
268
434
|
# ==== Returns
|
269
435
|
# Array:: All components that have been disabled.
|
270
436
|
def disabled_components
|
271
437
|
Merb::Config[:disabled_components] ||= []
|
272
438
|
end
|
273
|
-
|
439
|
+
|
274
440
|
# ==== Returns
|
275
441
|
# Boolean:: True if all components (or just one) are disabled.
|
276
442
|
def disabled?(*components)
|
277
443
|
components.all? { |c| disabled_components.include?(c) }
|
278
444
|
end
|
279
|
-
|
445
|
+
|
280
446
|
# ==== Returns
|
281
|
-
# Array::
|
447
|
+
# Array(String):: Paths Rakefiles are loaded from.
|
448
|
+
#
|
449
|
+
# ==== Notes
|
450
|
+
# Recommended way to find out what paths Rakefiles
|
451
|
+
# are loaded from.
|
282
452
|
def rakefiles
|
283
453
|
@rakefiles ||= ['merb-core/test/tasks/spectasks']
|
284
454
|
end
|
285
455
|
|
286
456
|
# ==== Parameters
|
287
|
-
# *rakefiles::
|
457
|
+
# *rakefiles:: Rakefile pathss to add to the list of Rakefiles.
|
458
|
+
#
|
459
|
+
# ==== Notes
|
460
|
+
# Recommended way to add Rakefiles load path for plugins authors.
|
288
461
|
def add_rakefiles(*rakefiles)
|
289
462
|
@rakefiles ||= ['merb-core/test/tasks/spectasks']
|
290
463
|
@rakefiles += rakefiles
|
291
464
|
end
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
292
469
|
end
|
293
470
|
end
|
294
471
|
|
@@ -301,4 +478,4 @@ require 'merb-core/controller/mime'
|
|
301
478
|
require 'merb-core/vendor/facets'
|
302
479
|
|
303
480
|
# Set the environment if it hasn't already been set.
|
304
|
-
Merb.environment ||= ENV['MERB_ENV'] || Merb::Config[:environment] || (Merb.testing? ? 'test' : 'development')
|
481
|
+
Merb.environment ||= ENV['MERB_ENV'] || Merb::Config[:environment] || (Merb.testing? ? 'test' : 'development')
|