merb-core 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +136 -2
- data/CONTRIBUTORS +6 -0
- data/PUBLIC_CHANGELOG +38 -0
- data/Rakefile +38 -30
- data/lib/merb-core.rb +88 -23
- data/lib/merb-core/bootloader.rb +235 -51
- data/lib/merb-core/config.rb +121 -36
- data/lib/merb-core/controller/abstract_controller.rb +59 -36
- data/lib/merb-core/controller/exceptions.rb +2 -15
- data/lib/merb-core/controller/merb_controller.rb +44 -1
- data/lib/merb-core/controller/mime.rb +4 -0
- data/lib/merb-core/controller/mixins/controller.rb +38 -21
- data/lib/merb-core/controller/mixins/render.rb +44 -29
- data/lib/merb-core/controller/mixins/responder.rb +3 -31
- data/lib/merb-core/controller/template.rb +45 -21
- data/lib/merb-core/core_ext/kernel.rb +60 -32
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +2 -2
- data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +3 -1
- data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +71 -67
- data/lib/merb-core/dispatch/default_exception/views/index.html.erb +7 -3
- data/lib/merb-core/dispatch/dispatcher.rb +3 -3
- data/lib/merb-core/dispatch/request.rb +56 -9
- data/lib/merb-core/dispatch/router.rb +159 -133
- data/lib/merb-core/dispatch/router/behavior.rb +462 -703
- data/lib/merb-core/dispatch/router/cached_proc.rb +3 -3
- data/lib/merb-core/dispatch/router/resources.rb +289 -0
- data/lib/merb-core/dispatch/router/route.rb +514 -294
- data/lib/merb-core/dispatch/session.rb +4 -2
- data/lib/merb-core/logger.rb +213 -202
- data/lib/merb-core/plugins.rb +9 -1
- data/lib/merb-core/rack.rb +3 -1
- data/lib/merb-core/rack/adapter.rb +7 -4
- data/lib/merb-core/rack/adapter/abstract.rb +188 -0
- data/lib/merb-core/rack/adapter/ebb.rb +12 -13
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -15
- data/lib/merb-core/rack/adapter/irb.rb +3 -2
- data/lib/merb-core/rack/adapter/mongrel.rb +22 -15
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +4 -16
- data/lib/merb-core/rack/adapter/thin.rb +21 -22
- data/lib/merb-core/rack/adapter/thin_turbo.rb +4 -11
- data/lib/merb-core/rack/adapter/webrick.rb +54 -18
- data/lib/merb-core/rack/application.rb +4 -4
- data/lib/merb-core/rack/handler/mongrel.rb +12 -13
- data/lib/merb-core/rack/middleware/csrf.rb +1 -1
- data/lib/merb-core/rack/stream_wrapper.rb +41 -0
- data/lib/merb-core/server.rb +157 -90
- data/lib/merb-core/tasks/gem_management.rb +267 -0
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +48 -34
- data/lib/merb-core/tasks/stats.rake +1 -1
- data/lib/merb-core/test.rb +9 -3
- data/lib/merb-core/test/helpers.rb +1 -0
- data/lib/merb-core/test/helpers/mock_request_helper.rb +393 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -2
- data/lib/merb-core/test/helpers/request_helper.rb +40 -372
- data/lib/merb-core/test/helpers/route_helper.rb +16 -2
- data/lib/merb-core/test/matchers.rb +1 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +4 -247
- data/lib/merb-core/test/matchers/request_matchers.rb +140 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +22 -4
- data/lib/merb-core/test/run_specs.rb +118 -26
- data/lib/merb-core/test/test_ext/rspec.rb +181 -0
- data/lib/merb-core/version.rb +1 -9
- metadata +10 -342
- data/docs/bootloading.dox +0 -58
- data/docs/documentation_standards +0 -40
- data/docs/merb-core-call-stack-diagram.mmap +0 -0
- data/docs/merb-core-call-stack-diagram.pdf +0 -0
- data/docs/merb-core-call-stack-diagram.png +0 -0
- data/docs/new_render_api +0 -51
- data/lib/merb-core/vendor/facets.rb +0 -2
- data/lib/merb-core/vendor/facets/dictionary.rb +0 -433
- data/lib/merb-core/vendor/facets/inflect.rb +0 -342
- data/spec/private/config/adapter_spec.rb +0 -32
- data/spec/private/config/config_spec.rb +0 -202
- data/spec/private/config/environment_spec.rb +0 -13
- data/spec/private/config/merb_spec.rb +0 -34
- data/spec/private/config/spec_helper.rb +0 -1
- data/spec/private/core_ext/kernel_spec.rb +0 -159
- data/spec/private/dispatch/bootloader_spec.rb +0 -24
- data/spec/private/dispatch/fixture/app/controllers/application.rb +0 -4
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +0 -25
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +0 -19
- data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +0 -8
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +0 -37
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +0 -40
- data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +0 -11
- data/spec/private/dispatch/fixture/config/black_hole.rb +0 -12
- data/spec/private/dispatch/fixture/config/environments/development.rb +0 -6
- data/spec/private/dispatch/fixture/config/environments/production.rb +0 -5
- data/spec/private/dispatch/fixture/config/environments/test.rb +0 -6
- data/spec/private/dispatch/fixture/config/init.rb +0 -45
- data/spec/private/dispatch/fixture/config/rack.rb +0 -11
- data/spec/private/dispatch/fixture/config/router.rb +0 -35
- data/spec/private/dispatch/fixture/log/merb_test.log +0 -8839
- data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
- data/spec/private/dispatch/fixture/public/merb.fcgi +0 -4
- data/spec/private/dispatch/fixture/public/stylesheets/master.css +0 -119
- data/spec/private/dispatch/route_params_spec.rb +0 -23
- data/spec/private/dispatch/spec_helper.rb +0 -1
- data/spec/private/router/behavior_spec.rb +0 -60
- data/spec/private/router/fixture/log/merb_test.log +0 -35
- data/spec/private/router/route_spec.rb +0 -418
- data/spec/private/router/router_spec.rb +0 -183
- data/spec/private/vendor/facets/plural_spec.rb +0 -564
- data/spec/private/vendor/facets/singular_spec.rb +0 -489
- data/spec/public/DEFINITIONS +0 -11
- data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/cousins.rb +0 -41
- data/spec/public/abstract_controller/controllers/display.rb +0 -60
- data/spec/public/abstract_controller/controllers/filters.rb +0 -260
- data/spec/public/abstract_controller/controllers/helpers.rb +0 -41
- data/spec/public/abstract_controller/controllers/partial.rb +0 -121
- data/spec/public/abstract_controller/controllers/render.rb +0 -113
- data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/alt.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/custom.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_app_layout/index.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_custom_layout/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +0 -1
- data/spec/public/abstract_controller/display_spec.rb +0 -37
- data/spec/public/abstract_controller/filter_spec.rb +0 -136
- data/spec/public/abstract_controller/helper_spec.rb +0 -21
- data/spec/public/abstract_controller/partial_spec.rb +0 -61
- data/spec/public/abstract_controller/render_spec.rb +0 -90
- data/spec/public/abstract_controller/spec_helper.rb +0 -31
- data/spec/public/boot_loader/boot_loader_spec.rb +0 -33
- data/spec/public/boot_loader/spec_helper.rb +0 -1
- data/spec/public/controller/authentication_spec.rb +0 -174
- data/spec/public/controller/base_spec.rb +0 -88
- data/spec/public/controller/conditional_get_spec.rb +0 -100
- data/spec/public/controller/config/init.rb +0 -6
- data/spec/public/controller/controllers/authentication.rb +0 -74
- data/spec/public/controller/controllers/base.rb +0 -65
- data/spec/public/controller/controllers/conditional_get.rb +0 -35
- data/spec/public/controller/controllers/cookies.rb +0 -36
- data/spec/public/controller/controllers/dispatcher.rb +0 -35
- data/spec/public/controller/controllers/display.rb +0 -118
- data/spec/public/controller/controllers/redirect.rb +0 -36
- data/spec/public/controller/controllers/responder.rb +0 -93
- data/spec/public/controller/controllers/url.rb +0 -7
- data/spec/public/controller/controllers/views/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +0 -1
- data/spec/public/controller/cookies_spec.rb +0 -95
- data/spec/public/controller/dispatcher_spec.rb +0 -410
- data/spec/public/controller/display_spec.rb +0 -84
- data/spec/public/controller/redirect_spec.rb +0 -33
- data/spec/public/controller/responder_spec.rb +0 -169
- data/spec/public/controller/spec_helper.rb +0 -13
- data/spec/public/controller/url_spec.rb +0 -255
- data/spec/public/core/merb_core_spec.rb +0 -45
- data/spec/public/core_ext/fixtures/core_ext_dependency.rb +0 -2
- data/spec/public/core_ext/kernel_spec.rb +0 -88
- data/spec/public/core_ext/spec_helper.rb +0 -1
- data/spec/public/directory_structure/directory/app/controllers/application.rb +0 -3
- data/spec/public/directory_structure/directory/app/controllers/base.rb +0 -13
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +0 -19
- data/spec/public/directory_structure/directory/app/views/base/template.html.erb +0 -1
- data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +0 -1
- data/spec/public/directory_structure/directory/config/router.rb +0 -3
- data/spec/public/directory_structure/directory/log/merb_test.log +0 -4588
- data/spec/public/directory_structure/directory_spec.rb +0 -43
- data/spec/public/logger/logger_spec.rb +0 -181
- data/spec/public/logger/spec_helper.rb +0 -1
- data/spec/public/rack/conditinal_get_middleware_spec.rb +0 -127
- data/spec/public/rack/csrf_middleware_spec.rb +0 -70
- data/spec/public/rack/rack_middleware_spec.rb +0 -99
- data/spec/public/rack/shared_example_groups.rb +0 -35
- data/spec/public/reloading/directory/app/controllers/application.rb +0 -3
- data/spec/public/reloading/directory/app/controllers/reload.rb +0 -6
- data/spec/public/reloading/directory/config/init.rb +0 -2
- data/spec/public/reloading/directory/log/merb_test.log +0 -288231
- data/spec/public/reloading/reload_spec.rb +0 -103
- data/spec/public/request/multipart_spec.rb +0 -41
- data/spec/public/request/request_spec.rb +0 -250
- data/spec/public/router/default_spec.rb +0 -21
- data/spec/public/router/deferred_spec.rb +0 -22
- data/spec/public/router/fixation_spec.rb +0 -49
- data/spec/public/router/fixture/log/merb_test.log +0 -524
- data/spec/public/router/namespace_spec.rb +0 -113
- data/spec/public/router/nested_matches_spec.rb +0 -97
- data/spec/public/router/nested_resources_spec.rb +0 -41
- data/spec/public/router/resource_spec.rb +0 -37
- data/spec/public/router/resources_spec.rb +0 -82
- data/spec/public/router/spec_helper.rb +0 -90
- data/spec/public/router/special_spec.rb +0 -61
- data/spec/public/router/string_spec.rb +0 -61
- data/spec/public/session/controllers/sessions.rb +0 -56
- data/spec/public/session/cookie_session_spec.rb +0 -73
- data/spec/public/session/memcached_session_spec.rb +0 -31
- data/spec/public/session/memory_session_spec.rb +0 -28
- data/spec/public/session/multiple_sessions_spec.rb +0 -74
- data/spec/public/session/no_session_spec.rb +0 -12
- data/spec/public/session/session_spec.rb +0 -106
- data/spec/public/template/template_spec.rb +0 -104
- data/spec/public/template/templates/error.html.erb +0 -2
- data/spec/public/template/templates/template.html.erb +0 -1
- data/spec/public/template/templates/template.html.myt +0 -1
- data/spec/public/test/controller_matchers_spec.rb +0 -412
- data/spec/public/test/controllers/controller_assertion_mock.rb +0 -7
- data/spec/public/test/controllers/dispatch_controller.rb +0 -11
- data/spec/public/test/controllers/spec_helper_controller.rb +0 -39
- data/spec/public/test/multipart_request_helper_spec.rb +0 -159
- data/spec/public/test/multipart_upload_text_file.txt +0 -1
- data/spec/public/test/request_helper_spec.rb +0 -269
- data/spec/public/test/route_helper_spec.rb +0 -78
- data/spec/public/test/route_matchers_spec.rb +0 -166
- data/spec/public/test/view_helper_spec.rb +0 -96
- data/spec/public/test/view_matchers_spec.rb +0 -183
- data/spec/spec_helper.rb +0 -121
@@ -101,7 +101,7 @@ module Merb
|
|
101
101
|
:_session_expiry
|
102
102
|
|
103
103
|
base._session_id_key = Merb::Config[:session_id_key] || '_session_id'
|
104
|
-
base._session_expiry = Merb::Config[:session_expiry] ||
|
104
|
+
base._session_expiry = Merb::Config[:session_expiry] || 0
|
105
105
|
base._session_secret_key = Merb::Config[:session_secret_key]
|
106
106
|
end
|
107
107
|
|
@@ -199,7 +199,9 @@ module Merb
|
|
199
199
|
# value<String>:: The value of the session cookie; either the session id or the actual encoded data.
|
200
200
|
# options<Hash>:: Cookie options like domain, path and expired.
|
201
201
|
def set_session_cookie_value(value, options = {})
|
202
|
-
|
202
|
+
defaults = {}
|
203
|
+
defaults[:expires] = Time.now + _session_expiry if _session_expiry > 0
|
204
|
+
cookies.set_cookie(_session_id_key, value, defaults.merge(options))
|
203
205
|
end
|
204
206
|
alias :set_session_id_cookie :set_session_cookie_value
|
205
207
|
|
data/lib/merb-core/logger.rb
CHANGED
@@ -1,203 +1,214 @@
|
|
1
|
-
Merb::Logger = Extlib::Logger
|
1
|
+
# Merb::Logger = Extlib::Logger
|
2
|
+
|
3
|
+
class Merb::Logger < Extlib::Logger
|
4
|
+
def verbose!(message, level = :warn)
|
5
|
+
send("#{level}!", message) if Merb::Config[:verbose]
|
6
|
+
end
|
7
|
+
|
8
|
+
def verbose(message, level = :warn)
|
9
|
+
send(level, message) if Merb::Config[:verbose]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
2
13
|
# require "time" # httpdate
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
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
|
-
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
#
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
#
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
#
|
186
|
-
#
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
#
|
194
|
-
#
|
195
|
-
|
196
|
-
#
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
14
|
+
# ==== Public Merb Logger API
|
15
|
+
#
|
16
|
+
# To replace an existing logger with a new one:
|
17
|
+
# Merb::Logger.set_log(log{String, IO},level{Symbol, String})
|
18
|
+
#
|
19
|
+
# Available logging levels are
|
20
|
+
# Merb::Logger::{ Fatal, Error, Warn, Info, Debug }
|
21
|
+
#
|
22
|
+
# Logging via:
|
23
|
+
# Merb.logger.fatal(message<String>,&block)
|
24
|
+
# Merb.logger.error(message<String>,&block)
|
25
|
+
# Merb.logger.warn(message<String>,&block)
|
26
|
+
# Merb.logger.info(message<String>,&block)
|
27
|
+
# Merb.logger.debug(message<String>,&block)
|
28
|
+
#
|
29
|
+
# Logging with autoflush:
|
30
|
+
# Merb.logger.fatal!(message<String>,&block)
|
31
|
+
# Merb.logger.error!(message<String>,&block)
|
32
|
+
# Merb.logger.warn!(message<String>,&block)
|
33
|
+
# Merb.logger.info!(message<String>,&block)
|
34
|
+
# Merb.logger.debug!(message<String>,&block)
|
35
|
+
#
|
36
|
+
# Flush the buffer to
|
37
|
+
# Merb.logger.flush
|
38
|
+
#
|
39
|
+
# Remove the current log object
|
40
|
+
# Merb.logger.close
|
41
|
+
#
|
42
|
+
# ==== Private Merb Logger API
|
43
|
+
#
|
44
|
+
# To initialize the logger you create a new object, proxies to set_log.
|
45
|
+
# Merb::Logger.new(log{String, IO},level{Symbol, String})
|
46
|
+
module Merb
|
47
|
+
|
48
|
+
class Logger
|
49
|
+
|
50
|
+
attr_accessor :level
|
51
|
+
attr_accessor :delimiter
|
52
|
+
attr_accessor :auto_flush
|
53
|
+
attr_reader :buffer
|
54
|
+
attr_reader :log
|
55
|
+
attr_reader :init_args
|
56
|
+
|
57
|
+
# ==== Notes
|
58
|
+
# Ruby (standard) logger levels:
|
59
|
+
# :fatal:: An unhandleable error that results in a program crash
|
60
|
+
# :error:: A handleable error condition
|
61
|
+
# :warn:: A warning
|
62
|
+
# :info:: generic (useful) information about system operation
|
63
|
+
# :debug:: low-level information for developers
|
64
|
+
Levels = Mash.new({
|
65
|
+
:fatal => 7,
|
66
|
+
:error => 6,
|
67
|
+
:warn => 4,
|
68
|
+
:info => 3,
|
69
|
+
:debug => 0
|
70
|
+
}) unless const_defined?(:Levels)
|
71
|
+
|
72
|
+
@@mutex = {}
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
# Readies a log for writing.
|
77
|
+
#
|
78
|
+
# ==== Parameters
|
79
|
+
# log<IO, String>:: Either an IO object or a name of a logfile.
|
80
|
+
def initialize_log(log)
|
81
|
+
close if @log # be sure that we don't leave open files laying around.
|
82
|
+
|
83
|
+
if log.respond_to?(:write)
|
84
|
+
@log = log
|
85
|
+
elsif File.exist?(log)
|
86
|
+
@log = open(log, (File::WRONLY | File::APPEND))
|
87
|
+
@log.sync = true
|
88
|
+
else
|
89
|
+
FileUtils.mkdir_p(File.dirname(log)) unless File.directory?(File.dirname(log))
|
90
|
+
@log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
|
91
|
+
@log.sync = true
|
92
|
+
@log.write("#{Time.now.httpdate} #{delimiter} info #{delimiter} Logfile created\n")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
public
|
97
|
+
|
98
|
+
# To initialize the logger you create a new object, proxies to set_log.
|
99
|
+
#
|
100
|
+
# ==== Parameters
|
101
|
+
# *args:: Arguments to create the log from. See set_logs for specifics.
|
102
|
+
def initialize(*args)
|
103
|
+
set_log(*args)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Replaces an existing logger with a new one.
|
107
|
+
#
|
108
|
+
# ==== Parameters
|
109
|
+
# log<IO, String>:: Either an IO object or a name of a logfile.
|
110
|
+
# log_level<~to_sym>::
|
111
|
+
# The log level from, e.g. :fatal or :info. Defaults to :error in the
|
112
|
+
# production environment and :debug otherwise.
|
113
|
+
# delimiter<String>::
|
114
|
+
# Delimiter to use between message sections. Defaults to " ~ ".
|
115
|
+
# auto_flush<Boolean>::
|
116
|
+
# Whether the log should automatically flush after new messages are
|
117
|
+
# added. Defaults to false.
|
118
|
+
def set_log(stream = Merb::Config[:log_stream],
|
119
|
+
log_level = Merb::Config[:log_level],
|
120
|
+
delimiter = Merb::Config[:log_delimiter],
|
121
|
+
auto_flush = Merb::Config[:log_auto_flush])
|
122
|
+
|
123
|
+
@buffer = []
|
124
|
+
@delimiter = delimiter
|
125
|
+
@auto_flush = auto_flush
|
126
|
+
|
127
|
+
if Levels[log_level]
|
128
|
+
@level = Levels[log_level]
|
129
|
+
else
|
130
|
+
@level = log_level
|
131
|
+
end
|
132
|
+
|
133
|
+
@log = stream
|
134
|
+
@mutex = (@@mutex[@log] ||= Mutex.new)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Flush the entire buffer to the log object.
|
138
|
+
def flush
|
139
|
+
return unless @buffer.size > 0
|
140
|
+
@mutex.synchronize do
|
141
|
+
@log.write(@buffer.slice!(0..-1).to_s)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Close and remove the current log object.
|
146
|
+
def close
|
147
|
+
flush
|
148
|
+
@log.close if @log.respond_to?(:close) && !@log.tty?
|
149
|
+
@log = nil
|
150
|
+
end
|
151
|
+
|
152
|
+
# Appends a message to the log. The methods yield to an optional block and
|
153
|
+
# the output of this block will be appended to the message.
|
154
|
+
#
|
155
|
+
# ==== Parameters
|
156
|
+
# string<String>:: The message to be logged. Defaults to nil.
|
157
|
+
#
|
158
|
+
# ==== Returns
|
159
|
+
# String:: The resulting message added to the log file.
|
160
|
+
def <<(string = nil)
|
161
|
+
message = ""
|
162
|
+
message << delimiter
|
163
|
+
message << string if string
|
164
|
+
message << "\n" unless message[-1] == ?\n
|
165
|
+
@buffer << message
|
166
|
+
flush if @auto_flush
|
167
|
+
|
168
|
+
message
|
169
|
+
end
|
170
|
+
alias :push :<<
|
171
|
+
|
172
|
+
# Generate the logging methods for Merb.logger for each log level.
|
173
|
+
Levels.each_pair do |name, number|
|
174
|
+
class_eval <<-LEVELMETHODS, __FILE__, __LINE__
|
175
|
+
|
176
|
+
# Appends a message to the log if the log level is at least as high as
|
177
|
+
# the log level of the logger.
|
178
|
+
#
|
179
|
+
# ==== Parameters
|
180
|
+
# string<String>:: The message to be logged. Defaults to nil.
|
181
|
+
#
|
182
|
+
# ==== Returns
|
183
|
+
# self:: The logger object for chaining.
|
184
|
+
def #{name}(message = nil)
|
185
|
+
self << message if #{number} >= level
|
186
|
+
self
|
187
|
+
end
|
188
|
+
|
189
|
+
# Appends a message to the log if the log level is at least as high as
|
190
|
+
# the log level of the logger. The bang! version of the method also auto
|
191
|
+
# flushes the log buffer to disk.
|
192
|
+
#
|
193
|
+
# ==== Parameters
|
194
|
+
# string<String>:: The message to be logged. Defaults to nil.
|
195
|
+
#
|
196
|
+
# ==== Returns
|
197
|
+
# self:: The logger object for chaining.
|
198
|
+
def #{name}!(message = nil)
|
199
|
+
self << message if #{number} >= level
|
200
|
+
flush if #{number} >= level
|
201
|
+
self
|
202
|
+
end
|
203
|
+
|
204
|
+
# ==== Returns
|
205
|
+
# Boolean:: True if this level will be logged by this logger.
|
206
|
+
def #{name}?
|
207
|
+
#{number} >= level
|
208
|
+
end
|
209
|
+
LEVELMETHODS
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
data/lib/merb-core/plugins.rb
CHANGED
@@ -11,7 +11,15 @@ module Merb
|
|
11
11
|
# this is so you can do Merb.plugins.config[:helpers][:awesome] = "bar"
|
12
12
|
config_hash = Hash.new {|h,k| h[k] = {}}
|
13
13
|
file = Merb.root / "config" / "plugins.yml"
|
14
|
-
|
14
|
+
|
15
|
+
if File.exists?(file)
|
16
|
+
require 'yaml'
|
17
|
+
to_merge = YAML.load_file(file)
|
18
|
+
else
|
19
|
+
to_merge = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
config_hash.merge(to_merge)
|
15
23
|
end
|
16
24
|
end
|
17
25
|
|