thorero 0.9.4.4 → 0.9.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/README +21 -0
- data/Rakefile +275 -108
- data/TODO +0 -0
- data/bin/merb +12 -0
- data/bin/merb-specs +5 -0
- data/docs/bootloading.dox +58 -0
- data/docs/documentation_standards +40 -0
- 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 +51 -0
- data/lib/merb-core.rb +603 -0
- data/lib/merb-core/autoload.rb +32 -0
- data/lib/merb-core/bootloader.rb +708 -0
- data/lib/merb-core/config.rb +303 -0
- data/lib/merb-core/constants.rb +43 -0
- data/lib/merb-core/controller/abstract_controller.rb +578 -0
- data/lib/merb-core/controller/exceptions.rb +302 -0
- data/lib/merb-core/controller/merb_controller.rb +256 -0
- data/lib/merb-core/controller/mime.rb +106 -0
- data/lib/merb-core/controller/mixins/authentication.rb +87 -0
- data/lib/merb-core/controller/mixins/controller.rb +290 -0
- data/lib/merb-core/controller/mixins/render.rb +481 -0
- data/lib/merb-core/controller/mixins/responder.rb +472 -0
- data/lib/merb-core/controller/template.rb +254 -0
- data/lib/merb-core/core_ext.rb +8 -0
- data/lib/merb-core/core_ext/kernel.rb +319 -0
- data/lib/merb-core/dispatch/cookies.rb +91 -0
- data/lib/merb-core/dispatch/dispatcher.rb +278 -0
- data/lib/merb-core/dispatch/exceptions.html.erb +303 -0
- data/lib/merb-core/dispatch/request.rb +603 -0
- data/lib/merb-core/dispatch/router.rb +179 -0
- data/lib/merb-core/dispatch/router/behavior.rb +867 -0
- data/lib/merb-core/dispatch/router/cached_proc.rb +52 -0
- data/lib/merb-core/dispatch/router/route.rb +321 -0
- data/lib/merb-core/dispatch/session.rb +78 -0
- data/lib/merb-core/dispatch/session/cookie.rb +168 -0
- data/lib/merb-core/dispatch/session/memcached.rb +184 -0
- data/lib/merb-core/dispatch/session/memory.rb +241 -0
- data/lib/merb-core/dispatch/worker.rb +28 -0
- data/lib/merb-core/gem_ext/erubis.rb +77 -0
- data/lib/{extlib → merb-core}/logger.rb +2 -2
- data/lib/merb-core/plugins.rb +59 -0
- data/lib/merb-core/rack.rb +21 -0
- data/lib/merb-core/rack/adapter.rb +44 -0
- data/lib/merb-core/rack/adapter/ebb.rb +25 -0
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +26 -0
- data/lib/merb-core/rack/adapter/fcgi.rb +17 -0
- data/lib/merb-core/rack/adapter/irb.rb +118 -0
- data/lib/merb-core/rack/adapter/mongrel.rb +26 -0
- data/lib/merb-core/rack/adapter/runner.rb +28 -0
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +26 -0
- data/lib/merb-core/rack/adapter/thin.rb +39 -0
- data/lib/merb-core/rack/adapter/thin_turbo.rb +24 -0
- data/lib/merb-core/rack/adapter/webrick.rb +36 -0
- data/lib/merb-core/rack/application.rb +18 -0
- data/lib/merb-core/rack/handler/mongrel.rb +97 -0
- data/lib/merb-core/rack/middleware.rb +26 -0
- data/lib/merb-core/rack/middleware/path_prefix.rb +31 -0
- data/lib/merb-core/rack/middleware/profiler.rb +19 -0
- data/lib/merb-core/rack/middleware/static.rb +45 -0
- data/lib/merb-core/server.rb +252 -0
- data/lib/merb-core/tasks/audit.rake +68 -0
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +12 -0
- data/lib/merb-core/test.rb +11 -0
- data/lib/merb-core/test/helpers.rb +9 -0
- data/lib/merb-core/test/helpers/controller_helper.rb +8 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +175 -0
- data/lib/merb-core/test/helpers/request_helper.rb +344 -0
- data/lib/merb-core/test/helpers/route_helper.rb +33 -0
- data/lib/merb-core/test/helpers/view_helper.rb +121 -0
- data/lib/merb-core/test/matchers.rb +9 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +319 -0
- data/lib/merb-core/test/matchers/route_matchers.rb +136 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +335 -0
- data/lib/merb-core/test/run_specs.rb +47 -0
- data/lib/merb-core/test/tasks/spectasks.rb +68 -0
- data/lib/merb-core/test/test_ext/hpricot.rb +32 -0
- data/lib/merb-core/test/test_ext/object.rb +14 -0
- data/lib/merb-core/test/test_ext/string.rb +14 -0
- data/lib/merb-core/vendor/facets.rb +2 -0
- data/lib/merb-core/vendor/facets/dictionary.rb +433 -0
- data/lib/merb-core/vendor/facets/inflect.rb +345 -0
- data/lib/merb-core/version.rb +11 -0
- data/spec/private/config/adapter_spec.rb +32 -0
- data/spec/private/config/config_spec.rb +202 -0
- data/spec/private/config/environment_spec.rb +13 -0
- data/spec/private/config/spec_helper.rb +1 -0
- data/spec/private/core_ext/kernel_spec.rb +169 -0
- data/spec/private/dispatch/bootloader_spec.rb +24 -0
- data/spec/private/dispatch/cookies_spec.rb +107 -0
- data/spec/private/dispatch/dispatch_spec.rb +35 -0
- data/spec/private/dispatch/fixture/app/controllers/application.rb +4 -0
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +27 -0
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +21 -0
- data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +8 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +37 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +40 -0
- data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +11 -0
- data/spec/private/dispatch/fixture/config/black_hole.rb +12 -0
- data/spec/private/dispatch/fixture/config/environments/development.rb +6 -0
- data/spec/private/dispatch/fixture/config/environments/production.rb +5 -0
- data/spec/private/dispatch/fixture/config/environments/test.rb +6 -0
- data/spec/private/dispatch/fixture/config/init.rb +45 -0
- data/spec/private/dispatch/fixture/config/rack.rb +11 -0
- data/spec/private/dispatch/fixture/config/router.rb +35 -0
- data/spec/private/dispatch/fixture/log/merb_test.log +1874 -0
- data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
- data/spec/private/dispatch/fixture/public/merb.fcgi +4 -0
- data/spec/private/dispatch/fixture/public/stylesheets/master.css +119 -0
- data/spec/private/dispatch/route_params_spec.rb +24 -0
- data/spec/private/dispatch/session_mixin_spec.rb +47 -0
- data/spec/private/dispatch/spec_helper.rb +1 -0
- data/spec/private/plugins/plugin_spec.rb +166 -0
- data/spec/private/rack/application_spec.rb +49 -0
- data/spec/private/router/behavior_spec.rb +60 -0
- data/spec/private/router/fixture/log/merb_test.log +139 -0
- data/spec/private/router/route_spec.rb +414 -0
- data/spec/private/router/router_spec.rb +175 -0
- data/spec/private/vendor/facets/plural_spec.rb +564 -0
- data/spec/private/vendor/facets/singular_spec.rb +489 -0
- data/spec/public/DEFINITIONS +11 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/cousins.rb +41 -0
- data/spec/public/abstract_controller/controllers/display.rb +54 -0
- data/spec/public/abstract_controller/controllers/filters.rb +193 -0
- data/spec/public/abstract_controller/controllers/helpers.rb +41 -0
- data/spec/public/abstract_controller/controllers/partial.rb +121 -0
- data/spec/public/abstract_controller/controllers/render.rb +113 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/layout/alt.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/layout/custom.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +1 -0
- 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 +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +1 -0
- data/spec/public/abstract_controller/display_spec.rb +33 -0
- data/spec/public/abstract_controller/filter_spec.rb +106 -0
- data/spec/public/abstract_controller/helper_spec.rb +21 -0
- data/spec/public/abstract_controller/partial_spec.rb +61 -0
- data/spec/public/abstract_controller/render_spec.rb +90 -0
- data/spec/public/abstract_controller/spec_helper.rb +31 -0
- data/spec/public/boot_loader/boot_loader_spec.rb +33 -0
- data/spec/public/boot_loader/spec_helper.rb +1 -0
- data/spec/public/controller/authentication_spec.rb +103 -0
- data/spec/public/controller/base_spec.rb +36 -0
- data/spec/public/controller/controllers/authentication.rb +45 -0
- data/spec/public/controller/controllers/base.rb +36 -0
- data/spec/public/controller/controllers/display.rb +118 -0
- data/spec/public/controller/controllers/redirect.rb +30 -0
- data/spec/public/controller/controllers/responder.rb +93 -0
- data/spec/public/controller/controllers/url.rb +7 -0
- data/spec/public/controller/controllers/views/layout/custom.html.erb +1 -0
- data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +1 -0
- data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.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/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +1 -0
- data/spec/public/controller/display_spec.rb +84 -0
- data/spec/public/controller/redirect_spec.rb +27 -0
- data/spec/public/controller/responder_spec.rb +163 -0
- data/spec/public/controller/spec_helper.rb +11 -0
- data/spec/public/controller/url_spec.rb +180 -0
- data/spec/public/core/merb_core_spec.rb +45 -0
- data/spec/public/core_ext/class_spec.rb +91 -0
- data/spec/public/core_ext/fixtures/core_ext_dependency.rb +2 -0
- data/spec/public/core_ext/kernel_spec.rb +9 -0
- data/spec/public/core_ext/spec_helper.rb +1 -0
- data/spec/public/directory_structure/directory/app/controllers/application.rb +3 -0
- data/spec/public/directory_structure/directory/app/controllers/base.rb +13 -0
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +19 -0
- data/spec/public/directory_structure/directory/app/views/base/template.html.erb +1 -0
- data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +1 -0
- data/spec/public/directory_structure/directory/config/router.rb +3 -0
- data/spec/public/directory_structure/directory/log/merb_test.log +562 -0
- data/spec/public/directory_structure/directory_spec.rb +44 -0
- data/spec/public/logger/logger_spec.rb +181 -0
- data/spec/public/logger/spec_helper.rb +1 -0
- data/spec/public/reloading/directory/app/controllers/application.rb +3 -0
- data/spec/public/reloading/directory/app/controllers/reload.rb +6 -0
- data/spec/public/reloading/directory/config/init.rb +2 -0
- data/spec/public/reloading/directory/log/merb_test.log +138 -0
- data/spec/public/reloading/reload_spec.rb +103 -0
- data/spec/public/request/multipart_spec.rb +41 -0
- data/spec/public/request/request_spec.rb +228 -0
- data/spec/public/router/default_spec.rb +21 -0
- data/spec/public/router/deferred_spec.rb +22 -0
- data/spec/public/router/fixation_spec.rb +27 -0
- data/spec/public/router/fixture/log/merb_test.log +1556 -0
- data/spec/public/router/namespace_spec.rb +113 -0
- data/spec/public/router/nested_matches_spec.rb +97 -0
- data/spec/public/router/nested_resources_spec.rb +41 -0
- data/spec/public/router/resource_spec.rb +37 -0
- data/spec/public/router/resources_spec.rb +82 -0
- data/spec/public/router/spec_helper.rb +90 -0
- data/spec/public/router/special_spec.rb +61 -0
- data/spec/public/router/string_spec.rb +61 -0
- data/spec/public/template/template_spec.rb +104 -0
- data/spec/public/template/templates/error.html.erb +2 -0
- data/spec/public/template/templates/template.html.erb +1 -0
- data/spec/public/template/templates/template.html.myt +1 -0
- data/spec/public/test/controller_matchers_spec.rb +402 -0
- data/spec/public/test/controllers/controller_assertion_mock.rb +7 -0
- data/spec/public/test/controllers/dispatch_controller.rb +11 -0
- data/spec/public/test/controllers/spec_helper_controller.rb +38 -0
- data/spec/public/test/multipart_request_helper_spec.rb +159 -0
- data/spec/public/test/multipart_upload_text_file.txt +1 -0
- data/spec/public/test/request_helper_spec.rb +221 -0
- data/spec/public/test/route_helper_spec.rb +71 -0
- data/spec/public/test/route_matchers_spec.rb +162 -0
- data/spec/public/test/view_helper_spec.rb +96 -0
- data/spec/public/test/view_matchers_spec.rb +183 -0
- data/spec/spec_helper.rb +68 -0
- metadata +493 -41
- data/README.txt +0 -3
- data/lib/extlib.rb +0 -32
- data/lib/extlib/assertions.rb +0 -8
- data/lib/extlib/blank.rb +0 -42
- data/lib/extlib/class.rb +0 -175
- data/lib/extlib/hash.rb +0 -410
- data/lib/extlib/hook.rb +0 -366
- data/lib/extlib/inflection.rb +0 -141
- data/lib/extlib/lazy_array.rb +0 -106
- data/lib/extlib/mash.rb +0 -143
- data/lib/extlib/module.rb +0 -37
- data/lib/extlib/object.rb +0 -165
- data/lib/extlib/object_space.rb +0 -13
- data/lib/extlib/pathname.rb +0 -5
- data/lib/extlib/pooling.rb +0 -233
- data/lib/extlib/rubygems.rb +0 -38
- data/lib/extlib/simple_set.rb +0 -39
- data/lib/extlib/string.rb +0 -132
- data/lib/extlib/struct.rb +0 -8
- data/lib/extlib/tasks/release.rb +0 -9
- data/lib/extlib/time.rb +0 -12
- data/lib/extlib/version.rb +0 -3
- data/lib/extlib/virtual_file.rb +0 -10
data/TODO
ADDED
File without changes
|
data/bin/merb
ADDED
data/bin/merb-specs
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
The Merb boot process starts when you run the Merb binary, which calls `Merb.start`. Merb.start performs the
|
2
|
+
following tasks:
|
3
|
+
|
4
|
+
list.
|
5
|
+
* Loads merb.yml from the root directory or config directory and puts them in the Merb::Config hash
|
6
|
+
* Parses config arguments from the command-line and adds them to the Merb::Config hash
|
7
|
+
* Runs the BootLoaders (see below)
|
8
|
+
* Starts the Merb Rack adapter
|
9
|
+
|
10
|
+
The BootLoader is a configurable process, which, by default, runs the following processes:
|
11
|
+
|
12
|
+
deflist.
|
13
|
+
Environment: Sets the Merb environment based on any -e flag passed the merb binary
|
14
|
+
BuildFramework: Set the framework paths, which can either be set in the Merb::Config[:framework]
|
15
|
+
variable or defaults to the paths described below.
|
16
|
+
Dependencies: Load dependencies.rb, which should include any plugins that will be loaded, as well
|
17
|
+
as an after_app_loaded hook.
|
18
|
+
Logger: Set up the logger in the `Merb.dir_for(:log)` directory. In test mode, it will be called
|
19
|
+
`test_logger`. In other modes, it will be set to `merb.#{pid}.log`. The log level will default
|
20
|
+
to `info` but can be specified via the Merb::Config[:log_level] option.
|
21
|
+
LoadRouter: The router is loaded from `Merb.dir_for(:config)/router.rb`.
|
22
|
+
LoadClasses: Files in all of the load paths are `require`d, and classes added during the load of
|
23
|
+
each files are tracked so they can be removed later during the reloading process.
|
24
|
+
Templates: All templates under the `_template_root` of any loaded controllers, as well as all
|
25
|
+
templates under `Merb.dir_for(:view)` are registered as inlined templates.
|
26
|
+
MimeTypes: Register all MimeTypes (see below for defaults).
|
27
|
+
AfterAppLoads: Call any `after_app_loads` hooks that were registered in dependencies.rb
|
28
|
+
MixinSessionContainer: Register the session types and set the app to use one if
|
29
|
+
`Merb::Config[:session_type]` is set.
|
30
|
+
ChooseAdapter: Set `Merb.adapter` to be the adapter chosen via Merb::Config[:adapter] (which
|
31
|
+
can be specified via the `-a foo` command-line parameter).
|
32
|
+
RackUpApplication: Set up a default rack application. Alternatively, allow for additional configuration
|
33
|
+
in `Merb.dir_for(:config)/rack.rb`, which will be evaluated in the context of a Rack::Builder.new
|
34
|
+
block.
|
35
|
+
ReloadClasses: If Merb::Config[:reload_classes] is set, begin the process of reloading classes
|
36
|
+
every time a class is modified.
|
37
|
+
|
38
|
+
deflist: Default Framework Paths.
|
39
|
+
application: Merb.root/app/controller/application.rb
|
40
|
+
config: Merb.root/config
|
41
|
+
lib: Merb.root/lib
|
42
|
+
log: Merb.root/log
|
43
|
+
view: Merb.root/app/views
|
44
|
+
model: Merb.root/app/models
|
45
|
+
controller: Merb.root/app/controllers
|
46
|
+
helper: Merb.root/app/helpers
|
47
|
+
mailer: Merb.root/app/mailers
|
48
|
+
part: Merb.root/app/parts
|
49
|
+
|
50
|
+
deflist: MimeTypes.
|
51
|
+
\:all: no transform, */*
|
52
|
+
\:yaml: to_yaml, application/x-yaml or text/yaml
|
53
|
+
\:text: to_text, text/plain
|
54
|
+
\:html: to_html, text/html or application/xhtml+xml or application/html
|
55
|
+
\:xml: to_xml, application/xml or text/xml or application/x-xml, adds "Encoding: UTF-8" response header
|
56
|
+
\:js: to_json, text/javascript ot application/javascript or application/x-javascript
|
57
|
+
\:json: to_json, application/json or text/x-json
|
58
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Every method should have documentation above the method definition that fits this basic model...
|
2
|
+
|
3
|
+
# Render the specified item, with the specified options.
|
4
|
+
#
|
5
|
+
# ==== Parameters
|
6
|
+
# thing<String, Symbol, nil>::
|
7
|
+
# The thing to render. This will default to the current action
|
8
|
+
# opts<Hash>:: An options hash (see below)
|
9
|
+
#
|
10
|
+
# ==== Options (opts)
|
11
|
+
# :format<Symbol>:: A registered mime-type format
|
12
|
+
# :template<String>::
|
13
|
+
# The path to the template relative to the template root
|
14
|
+
# :status<~to_i>::
|
15
|
+
# The status to send to the client. Typically, this would
|
16
|
+
# be an integer (200), or a Merb status code (Accepted)
|
17
|
+
# :layout<~to_s>::
|
18
|
+
# A layout to use instead of the default. This should be
|
19
|
+
# relative to the layout root. By default, the layout will
|
20
|
+
# be either the controller_name or application. If you
|
21
|
+
# want to use an alternative content-type than the one
|
22
|
+
# that the base template was rendered as, you will need
|
23
|
+
# to do :layout => “foo.#{content_type}” (i.e. “foo.json”)
|
24
|
+
#
|
25
|
+
# ==== Returns
|
26
|
+
# String:: The rendered template, including layout, if appropriate.
|
27
|
+
#
|
28
|
+
# ==== Raises
|
29
|
+
# TemplateNotFound::
|
30
|
+
# There is no template for the specified location.
|
31
|
+
#
|
32
|
+
# ==== Alternatives
|
33
|
+
# If you pass a Hash as the first parameter, it will be moved to
|
34
|
+
# opts and “thing” will be the current action
|
35
|
+
#
|
36
|
+
#—
|
37
|
+
# @public
|
38
|
+
def render(thing = nil, opts = {})
|
39
|
+
<snip>
|
40
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
data/docs/new_render_api
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
## TEMPLATES
|
2
|
+
|
3
|
+
# Render an action
|
4
|
+
render :symbol
|
5
|
+
|
6
|
+
# Render a string
|
7
|
+
render "string"
|
8
|
+
|
9
|
+
# Render an object; will call to_#{content-type} on this if the default template is not found
|
10
|
+
display @obj
|
11
|
+
|
12
|
+
# Provide an alternative default thing to render; note that we can use strings here for template paths
|
13
|
+
# because strings would never fail and fallback to the @obj
|
14
|
+
display @obj, :symbol
|
15
|
+
display @obj, "full/path/to/template"
|
16
|
+
|
17
|
+
# Render a template
|
18
|
+
render_template "full/path/to/template"
|
19
|
+
|
20
|
+
# Render with a mime-type (same as render, but with added mime-type set)
|
21
|
+
render_json :symbol
|
22
|
+
render_json "string"
|
23
|
+
|
24
|
+
# Render nothing at all
|
25
|
+
render_nothing
|
26
|
+
|
27
|
+
# TEMPLATE OPTIONS (all functions above can use these options)
|
28
|
+
|
29
|
+
# :format can be used to override the mime-type arrived at via content-negotiation
|
30
|
+
render :symbol, :format => :xml
|
31
|
+
|
32
|
+
# :status can set the status that will be returned to the browser
|
33
|
+
render :symbol, :status => Successful::Accepted
|
34
|
+
# or
|
35
|
+
render :symbol, :status => 202
|
36
|
+
|
37
|
+
# :layout sets the layout to use; default: controller.to_path || :application; :none means no layout
|
38
|
+
render :symbol, :layout => :none
|
39
|
+
|
40
|
+
## PARTIALS
|
41
|
+
|
42
|
+
# Render a partial
|
43
|
+
partial :symbol
|
44
|
+
|
45
|
+
# Render a partial with an object (it will default to the local var "symbol" in the partial)
|
46
|
+
partial :symbol, :with => @object
|
47
|
+
partial :symbol, :with => @object, :as => "something"
|
48
|
+
|
49
|
+
# Render a partial with a collection of objects (same :as semantics)
|
50
|
+
partial :symbol, :with => [col, lec, tion]
|
51
|
+
partial :symbol, :with => [col, lec, tion], :as => "name"
|
data/lib/merb-core.rb
ADDED
@@ -0,0 +1,603 @@
|
|
1
|
+
#---
|
2
|
+
# require 'merb' must happen after Merb::Config is instantiated
|
3
|
+
require 'rubygems'
|
4
|
+
require 'set'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'socket'
|
7
|
+
require 'pathname'
|
8
|
+
require "extlib"
|
9
|
+
|
10
|
+
__DIR__ = File.dirname(__FILE__)
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift __DIR__ unless
|
13
|
+
$LOAD_PATH.include?(__DIR__) ||
|
14
|
+
$LOAD_PATH.include?(File.expand_path(__DIR__))
|
15
|
+
|
16
|
+
require 'merb-core' / 'vendor' / 'facets'
|
17
|
+
|
18
|
+
module Merb
|
19
|
+
module GlobalHelpers; end
|
20
|
+
class << self
|
21
|
+
|
22
|
+
# Merge environment settings
|
23
|
+
# Can allow you to have a "localdev" that runs like your "development"
|
24
|
+
# OR
|
25
|
+
# A "staging" environment that runs like your "production"
|
26
|
+
#
|
27
|
+
# ==== Examples
|
28
|
+
# From any environment config file (ie, development.rb, custom.rb, localdev.rb, etc)
|
29
|
+
# staging.rb:
|
30
|
+
# Merb.merge_env "production" #We want to use all the settings production uses
|
31
|
+
# Merb::Config.use { |c|
|
32
|
+
# c[:log_level] = "debug" #except we want debug log level
|
33
|
+
# c[:exception_details] = true #and we want to see exception details
|
34
|
+
# }
|
35
|
+
#
|
36
|
+
# ==== Parameters
|
37
|
+
# env<~String>:: Environment to run like
|
38
|
+
# use_db<~Boolean>:: Should Merb use the merged environments DB connection
|
39
|
+
# Defaults to +false+
|
40
|
+
def merge_env(env,use_db=false)
|
41
|
+
if Merb.environment_info.nil?
|
42
|
+
Merb.environment_info = {
|
43
|
+
:real_env => Merb.environment,
|
44
|
+
:merged_envs => [],
|
45
|
+
:db_env => Merb.environment
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
#Only load if it hasn't been loaded
|
50
|
+
unless Merb.environment_info[:merged_envs].member? env
|
51
|
+
Merb.environment_info[:merged_envs] << env
|
52
|
+
|
53
|
+
env_file = Merb.dir_for(:config) / "environments" / ("#{env}.rb")
|
54
|
+
if File.exists?(env_file)
|
55
|
+
load(env_file)
|
56
|
+
else
|
57
|
+
Merb.logger.warn! "Environment file does not exist! #{env_file}"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
# Mark specific environment to load when ORM loads,
|
63
|
+
# if multiple environments are loaded, the last one
|
64
|
+
# with use_db as TRUE will be loaded
|
65
|
+
if use_db
|
66
|
+
Merb.environment_info[:db_env] = env
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
# Startup Merb by setting up the Config and starting the server.
|
72
|
+
# This is where Merb application environment and root path are set.
|
73
|
+
#
|
74
|
+
# ==== Parameters
|
75
|
+
# argv<String, Hash>::
|
76
|
+
# The config arguments to start Merb with. Defaults to +ARGV+.
|
77
|
+
def start(argv=ARGV)
|
78
|
+
if Hash === argv
|
79
|
+
Merb::Config.setup(argv)
|
80
|
+
else
|
81
|
+
Merb::Config.parse_args(argv)
|
82
|
+
end
|
83
|
+
Merb.environment = Merb::Config[:environment]
|
84
|
+
Merb.root = Merb::Config[:merb_root]
|
85
|
+
case Merb::Config[:action]
|
86
|
+
when :kill
|
87
|
+
Merb::Server.kill(Merb::Config[:port], 1)
|
88
|
+
when :kill_9
|
89
|
+
Merb::Server.kill(Merb::Config[:port], 9)
|
90
|
+
else
|
91
|
+
Merb::Server.start(Merb::Config[:port], Merb::Config[:cluster])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Start the Merb environment, but only if it hasn't been loaded yet.
|
96
|
+
#
|
97
|
+
# ==== Parameters
|
98
|
+
# argv<String, Hash>::
|
99
|
+
# The config arguments to start Merb with. Defaults to +ARGV+.
|
100
|
+
def start_environment(argv=ARGV)
|
101
|
+
unless (@started ||= false)
|
102
|
+
start(argv)
|
103
|
+
@started = true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Restart the Merb environment explicitly.
|
108
|
+
#
|
109
|
+
# ==== Parameters
|
110
|
+
# argv<String, Hash>::
|
111
|
+
# The config arguments to restart Merb with. Defaults to +Merb::Config+.
|
112
|
+
def restart_environment(argv={})
|
113
|
+
@started = false
|
114
|
+
start_environment(Merb::Config.to_hash.merge(argv))
|
115
|
+
end
|
116
|
+
|
117
|
+
attr_accessor :environment, :load_paths, :adapter, :environment_info, :started
|
118
|
+
|
119
|
+
alias :env :environment
|
120
|
+
alias :started? :started
|
121
|
+
|
122
|
+
Merb.load_paths = Dictionary.new { [Merb.root] } unless Merb.load_paths.is_a?(Dictionary)
|
123
|
+
|
124
|
+
# This is the core mechanism for setting up your application layout.
|
125
|
+
# There are three application layouts in Merb:
|
126
|
+
#
|
127
|
+
# Regular app/:type layout of Ruby on Rails fame:
|
128
|
+
#
|
129
|
+
# app/models for models
|
130
|
+
# app/mailers for mailers (special type of controllers)
|
131
|
+
# app/parts for parts, Merb components
|
132
|
+
# app/views for templates
|
133
|
+
# app/controllers for controller
|
134
|
+
# lib for libraries
|
135
|
+
#
|
136
|
+
# Flat application layout:
|
137
|
+
#
|
138
|
+
# application.rb for models, controllers, mailers, etc
|
139
|
+
# config/init.rb for initialization and router configuration
|
140
|
+
# config/framework.rb for framework and dependencies configuration
|
141
|
+
# views for views
|
142
|
+
#
|
143
|
+
# and Camping-style "very flat" application layout, where the whole Merb
|
144
|
+
# application and configs fit into a single file.
|
145
|
+
#
|
146
|
+
# ==== Notes
|
147
|
+
# Autoloading for lib uses empty glob by default. If you
|
148
|
+
# want to have your libraries under lib use autoload, add
|
149
|
+
# the following to Merb init file:
|
150
|
+
#
|
151
|
+
# Merb.push_path(:lib, Merb.root / "lib", "**/*.rb") # glob set explicity.
|
152
|
+
#
|
153
|
+
# Then lib/magicwand/lib/magicwand.rb with MagicWand module will
|
154
|
+
# be autoloaded when you first access that constant.
|
155
|
+
#
|
156
|
+
# ==== Examples
|
157
|
+
# This method gives you a way to build up your own application
|
158
|
+
# structure, for instance, to reflect the structure Rails
|
159
|
+
# uses to simplify transition of legacy application, you can
|
160
|
+
# set it up like this:
|
161
|
+
#
|
162
|
+
# Merb.push_path(:model, Merb.root / "app" / "models", "**/*.rb")
|
163
|
+
# Merb.push_path(:mailer, Merb.root / "app" / "models", "**/*.rb")
|
164
|
+
# Merb.push_path(:controller, Merb.root / "app" / "controllers", "**/*.rb")
|
165
|
+
# Merb.push_path(:view, Merb.root / "app" / "views", "**/*.rb")
|
166
|
+
#
|
167
|
+
# ==== Parameters
|
168
|
+
# type<Symbol>:: The type of path being registered (i.e. :view)
|
169
|
+
# path<String>:: The full path
|
170
|
+
# file_glob<String>::
|
171
|
+
# A glob that will be used to autoload files under the path. Defaults to
|
172
|
+
# "**/*.rb".
|
173
|
+
def push_path(type, path, file_glob = "**/*.rb")
|
174
|
+
enforce!(type => Symbol)
|
175
|
+
load_paths[type] = [Pathname.new(path), file_glob]
|
176
|
+
end
|
177
|
+
|
178
|
+
# Removes given types of application components
|
179
|
+
# from load path Merb uses for autoloading.
|
180
|
+
#
|
181
|
+
# ==== Parameters
|
182
|
+
# *args<Array(Symbol)>::
|
183
|
+
# components names, for instance, :views, :models
|
184
|
+
#
|
185
|
+
# ==== Examples
|
186
|
+
# Using this combined with Merb::GlobalHelpers.push_path
|
187
|
+
# you can make your Merb application use legacy Rails
|
188
|
+
# application components.
|
189
|
+
#
|
190
|
+
# Merb.root = "path/to/legacy/app/root"
|
191
|
+
# Merb.remove_paths(:mailer)
|
192
|
+
# Merb.push_path(:mailer, Merb.root / "app" / "models", "**/*.rb")
|
193
|
+
#
|
194
|
+
# Will make Merb use app/models for mailers just like Ruby on Rails does.
|
195
|
+
def remove_paths(*args)
|
196
|
+
args.each {|arg| load_paths.delete(arg)}
|
197
|
+
end
|
198
|
+
|
199
|
+
# ==== Parameters
|
200
|
+
# type<Symbol>:: The type of path to retrieve directory for, e.g. :view.
|
201
|
+
#
|
202
|
+
# ==== Returns
|
203
|
+
# String:: The directory for the requested type.
|
204
|
+
def dir_for(type)
|
205
|
+
Merb.load_paths[type].first
|
206
|
+
end
|
207
|
+
|
208
|
+
# ==== Parameters
|
209
|
+
# type<Symbol>:: The type of path to retrieve glob for, e.g. :view.
|
210
|
+
#
|
211
|
+
# ===== Returns
|
212
|
+
# String:: The pattern with which to match files within the type directory.
|
213
|
+
def glob_for(type)
|
214
|
+
Merb.load_paths[type][1]
|
215
|
+
end
|
216
|
+
|
217
|
+
# ==== Returns
|
218
|
+
# String:: The Merb root path.
|
219
|
+
def root
|
220
|
+
app_root = @root || Merb::Config[:merb_root] || Dir.pwd
|
221
|
+
|
222
|
+
Pathname.new(app_root)
|
223
|
+
end
|
224
|
+
|
225
|
+
# ==== Parameters
|
226
|
+
# value<String>:: Path to the root directory.
|
227
|
+
def root=(value)
|
228
|
+
@root = Pathname.new(value)
|
229
|
+
end
|
230
|
+
|
231
|
+
# ==== Parameters
|
232
|
+
# *path::
|
233
|
+
# The relative path (or list of path components) to a directory under the
|
234
|
+
# root of the application.
|
235
|
+
#
|
236
|
+
# ==== Returns
|
237
|
+
# String:: The full path including the root.
|
238
|
+
#
|
239
|
+
# ==== Examples
|
240
|
+
# Merb.root = "/home/merb/app"
|
241
|
+
# Merb.path("images") # => "/home/merb/app/images"
|
242
|
+
# Merb.path("views", "admin") # => "/home/merb/app/views/admin"
|
243
|
+
#---
|
244
|
+
# @public
|
245
|
+
def root_path(*path)
|
246
|
+
Pathname.new(File.join(root, *path))
|
247
|
+
end
|
248
|
+
|
249
|
+
# Logger settings
|
250
|
+
attr_accessor :logger
|
251
|
+
|
252
|
+
# ==== Returns
|
253
|
+
# String::
|
254
|
+
# The path to the log file. If this Merb instance is running as a daemon
|
255
|
+
# this will return +STDOUT+.
|
256
|
+
def log_file
|
257
|
+
if Merb::Config[:log_file]
|
258
|
+
Merb::Config[:log_file]
|
259
|
+
elsif Merb.testing?
|
260
|
+
log_path / "merb_test.log"
|
261
|
+
elsif !(Merb::Config[:daemonize] || Merb::Config[:cluster])
|
262
|
+
STDOUT
|
263
|
+
else
|
264
|
+
log_path / "merb.#{Merb::Config[:port]}.log"
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
# ==== Returns
|
269
|
+
# String:: Path to directory that contains the log file.
|
270
|
+
def log_path
|
271
|
+
path = case Merb::Config[:log_file]
|
272
|
+
when String then File.dirname(Merb::Config[:log_file])
|
273
|
+
else Merb.root_path("log")
|
274
|
+
end
|
275
|
+
|
276
|
+
Pathname.new(path)
|
277
|
+
end
|
278
|
+
|
279
|
+
# ==== Returns
|
280
|
+
# String:: The path of root directory of the Merb framework.
|
281
|
+
def framework_root
|
282
|
+
@framework_root ||= Pathname(File.dirname(__FILE__))
|
283
|
+
end
|
284
|
+
|
285
|
+
# ==== Returns
|
286
|
+
# RegExp::
|
287
|
+
# Regular expression against which deferred actions
|
288
|
+
# are matched by Rack application handler.
|
289
|
+
#
|
290
|
+
# ==== Notes
|
291
|
+
# Concatenates :deferred_actions configuration option
|
292
|
+
# values.
|
293
|
+
def deferred_actions
|
294
|
+
@deferred ||= begin
|
295
|
+
if Merb::Config[:deferred_actions].empty?
|
296
|
+
/^\0$/
|
297
|
+
else
|
298
|
+
/#{Merb::Config[:deferred_actions].join("|")}/
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
# Allows flat apps by setting no default framework directories and yielding
|
304
|
+
# a Merb::Router instance. This is optional since the router will
|
305
|
+
# automatically configure the app with default routes.
|
306
|
+
#
|
307
|
+
# ==== Block parameters
|
308
|
+
# r<Merb::Router::Behavior>::
|
309
|
+
# The root behavior upon which new routes can be added.
|
310
|
+
def flat!(framework = {})
|
311
|
+
Merb::Config[:framework] = framework
|
312
|
+
|
313
|
+
Merb::Router.prepare do |r|
|
314
|
+
yield(r) if block_given?
|
315
|
+
r.default_routes
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
# Set up default variables under Merb
|
320
|
+
attr_accessor :generator_scope, :klass_hashes, :orm_generator_scope, :test_framework_generator_scope
|
321
|
+
|
322
|
+
# Returns registered ORM generators as symbols,
|
323
|
+
# for instance, :datamapper.
|
324
|
+
#
|
325
|
+
# ==== Returns
|
326
|
+
# <Array(Symbol>:: registered ORM generators.
|
327
|
+
def orm_generator_scope
|
328
|
+
@orm_generator_scope ||= :merb_default
|
329
|
+
end
|
330
|
+
|
331
|
+
# Returns registered test framework generators.
|
332
|
+
#
|
333
|
+
# ==== Returns
|
334
|
+
# <Array(Symbol>:: registred test framework generators.
|
335
|
+
def test_framework_generator_scope
|
336
|
+
@test_framework_generator_scope ||= :rspec
|
337
|
+
end
|
338
|
+
|
339
|
+
# Returns all registered generators plus Merb generator.
|
340
|
+
#
|
341
|
+
# ==== Returns
|
342
|
+
# <Array(Symbol>::
|
343
|
+
# all registered generators, inc. needed by Merb itself.
|
344
|
+
def generator_scope
|
345
|
+
[:merb, orm_generator_scope, test_framework_generator_scope]
|
346
|
+
end
|
347
|
+
|
348
|
+
|
349
|
+
Merb.klass_hashes = []
|
350
|
+
|
351
|
+
attr_reader :registered_session_types
|
352
|
+
|
353
|
+
# ==== Parameters
|
354
|
+
# name<~to_s>:: Name of the session type to register.
|
355
|
+
# file<String>:: The file that defines this session type.
|
356
|
+
# description<String>:: An optional description of the session type.
|
357
|
+
#
|
358
|
+
# ==== Notes
|
359
|
+
# Merb currently supports memory, cookie and memcache session
|
360
|
+
# types.
|
361
|
+
def register_session_type(name, file, description = nil)
|
362
|
+
@registered_session_types ||= Dictionary.new
|
363
|
+
@registered_session_types[name] = {
|
364
|
+
:file => file,
|
365
|
+
:description => (description || "Using #{name} sessions")
|
366
|
+
}
|
367
|
+
end
|
368
|
+
|
369
|
+
attr_accessor :frozen
|
370
|
+
|
371
|
+
# ==== Returns
|
372
|
+
# Boolean:: True if Merb is running via merb-freezer or other freezer.
|
373
|
+
#
|
374
|
+
# ==== Notes
|
375
|
+
# Freezing means bundling framework libraries with your application
|
376
|
+
# making it independent from environment it runs in. This is a good
|
377
|
+
# practice to freeze application framework and gems it uses and
|
378
|
+
# very useful when application is run in some sort of sandbox,
|
379
|
+
# for instance, shared hosting with preconfigured gems.
|
380
|
+
def frozen?
|
381
|
+
@frozen
|
382
|
+
end
|
383
|
+
|
384
|
+
# Used by merb-freezer and other freezers to mark Merb as frozen.
|
385
|
+
# See Merb::GlobalHelpers.frozen? for more details on framework freezing.
|
386
|
+
def frozen!
|
387
|
+
@frozen = true
|
388
|
+
end
|
389
|
+
|
390
|
+
# Load configuration and assign logger.
|
391
|
+
#
|
392
|
+
# ==== Parameters
|
393
|
+
# options<Hash>:: Options to pass on to the Merb config.
|
394
|
+
#
|
395
|
+
# ==== Options
|
396
|
+
# :host<String>:: host to bind to,
|
397
|
+
# default is 0.0.0.0.
|
398
|
+
#
|
399
|
+
# :port<Fixnum>:: port to run Merb application on,
|
400
|
+
# default is 4000.
|
401
|
+
#
|
402
|
+
# :adapter<String>:: name of Rack adapter to use,
|
403
|
+
# default is "runner"
|
404
|
+
#
|
405
|
+
# :rackup<String>:: name of Rack init file to use,
|
406
|
+
# default is "rack.rb"
|
407
|
+
#
|
408
|
+
# :reload_classes<Boolean>:: whether Merb should reload
|
409
|
+
# classes on each request,
|
410
|
+
# default is true
|
411
|
+
#
|
412
|
+
# :environment<String>:: name of environment to use,
|
413
|
+
# default is development
|
414
|
+
#
|
415
|
+
# :merb_root<String>:: Merb application root,
|
416
|
+
# default is Dir.pwd
|
417
|
+
#
|
418
|
+
# :use_mutex<Boolean>:: turns action dispatch synchronization
|
419
|
+
# on or off, default is on (true)
|
420
|
+
#
|
421
|
+
# :session_id_key<String>:: session identifier,
|
422
|
+
# default is _session_id
|
423
|
+
#
|
424
|
+
# :session_store<String>:: session store to use (one of cookies,
|
425
|
+
# memcache or memory)
|
426
|
+
#
|
427
|
+
# :log_delimiter<String>:: what Merb logger uses as delimiter
|
428
|
+
# between message sections, default is " ~ "
|
429
|
+
#
|
430
|
+
# :log_auto_flush<Boolean>:: whether the log should automatically
|
431
|
+
# flush after new messages are
|
432
|
+
# added, defaults to true.
|
433
|
+
#
|
434
|
+
# :log_file<IO>:: IO for logger. Default is STDOUT.
|
435
|
+
#
|
436
|
+
# :log_level<Symbol>:: logger level, default is :warn
|
437
|
+
#
|
438
|
+
# :disabled_components<Array[Symbol]>::
|
439
|
+
# array of disabled component names,
|
440
|
+
# for instance, to disable json gem,
|
441
|
+
# specify :json. Default is empty array.
|
442
|
+
#
|
443
|
+
# :deferred_actions<Array(Symbol, String)]>::
|
444
|
+
# names of actions that should be deferred
|
445
|
+
# no matter what controller they belong to.
|
446
|
+
# Default is empty array.
|
447
|
+
#
|
448
|
+
# Some of these options come from command line on Merb
|
449
|
+
# application start, some of them are set in Merb init file
|
450
|
+
# or environment-specific.
|
451
|
+
def load_config(options = {})
|
452
|
+
Merb::Config.setup({ :log_file => STDOUT, :log_level => :warn, :log_auto_flush => true }.merge(options))
|
453
|
+
Merb::BootLoader::Logger.run
|
454
|
+
end
|
455
|
+
|
456
|
+
# Load all basic dependencies (selected BootLoaders only).
|
457
|
+
# This sets up Merb framework component paths
|
458
|
+
# (directories for models, controllers, etc) using
|
459
|
+
# framework.rb or default layout, loads init file
|
460
|
+
# and dependencies specified in it and runs before_app_loads hooks.
|
461
|
+
#
|
462
|
+
# ==== Parameters
|
463
|
+
# options<Hash>:: Options to pass on to the Merb config.
|
464
|
+
def load_dependencies(options = {})
|
465
|
+
load_config(options)
|
466
|
+
Merb::BootLoader::BuildFramework.run
|
467
|
+
Merb::BootLoader::Dependencies.run
|
468
|
+
Merb::BootLoader::BeforeAppLoads.run
|
469
|
+
end
|
470
|
+
|
471
|
+
# Reload application and framework classes.
|
472
|
+
# See Merb::BootLoader::ReloadClasses for details.
|
473
|
+
def reload
|
474
|
+
Merb::BootLoader::ReloadClasses.reload
|
475
|
+
end
|
476
|
+
|
477
|
+
# ==== Returns
|
478
|
+
# Boolean:: True if Merb environment is testing for instance,
|
479
|
+
# Merb is running with RSpec, Test::Unit of other testing facility.
|
480
|
+
def testing?
|
481
|
+
$TESTING || Merb::Config[:testing]
|
482
|
+
end
|
483
|
+
|
484
|
+
# Ask the question about which environment you're in.
|
485
|
+
# ==== Parameters
|
486
|
+
# env<Symbol, String>:: Name of the environment to query
|
487
|
+
#
|
488
|
+
# ==== Examples
|
489
|
+
# Merb.env #=> production
|
490
|
+
# Merb.env?(:production) #=> true
|
491
|
+
# Merb.env?(:development) #=> false
|
492
|
+
def env?(env)
|
493
|
+
Merb.env == env.to_s
|
494
|
+
end
|
495
|
+
|
496
|
+
# If block was given configures using the block.
|
497
|
+
#
|
498
|
+
# ==== Parameters
|
499
|
+
# &block:: Configuration parameter block, see example below.
|
500
|
+
#
|
501
|
+
# ==== Returns
|
502
|
+
# Hash:: The current configuration.
|
503
|
+
#
|
504
|
+
# ==== Notes
|
505
|
+
# See Merb::GlobalHelpers.load_config for configuration
|
506
|
+
# options list.
|
507
|
+
#
|
508
|
+
# ==== Examples
|
509
|
+
# Merb.config do
|
510
|
+
# beer "good"
|
511
|
+
# hashish :foo => "bar"
|
512
|
+
# environment "development"
|
513
|
+
# log_level "debug"
|
514
|
+
# use_mutex false
|
515
|
+
# session_store "cookie"
|
516
|
+
# session_secret_key "0d05a226affa226623eb18700"
|
517
|
+
# exception_details true
|
518
|
+
# reload_classes true
|
519
|
+
# reload_time 0.5
|
520
|
+
# end
|
521
|
+
def config(&block)
|
522
|
+
Merb::Config.configure(&block) if block_given?
|
523
|
+
Config
|
524
|
+
end
|
525
|
+
|
526
|
+
# Disables the given core components, like a Gem for example.
|
527
|
+
#
|
528
|
+
# ==== Parameters
|
529
|
+
# *args:: One or more symbols of Merb internal components.
|
530
|
+
def disable(*components)
|
531
|
+
disabled_components.push *components
|
532
|
+
end
|
533
|
+
|
534
|
+
# ==== Parameters
|
535
|
+
# Array:: All components that should be disabled.
|
536
|
+
def disabled_components=(components)
|
537
|
+
disabled_components.replace components
|
538
|
+
end
|
539
|
+
|
540
|
+
# ==== Returns
|
541
|
+
# Array:: All components that have been disabled.
|
542
|
+
def disabled_components
|
543
|
+
Merb::Config[:disabled_components] ||= []
|
544
|
+
end
|
545
|
+
|
546
|
+
# ==== Returns
|
547
|
+
# Boolean:: True if all components (or just one) are disabled.
|
548
|
+
def disabled?(*components)
|
549
|
+
components.all? { |c| disabled_components.include?(c) }
|
550
|
+
end
|
551
|
+
|
552
|
+
# ==== Returns
|
553
|
+
# Array(String):: Paths Rakefiles are loaded from.
|
554
|
+
#
|
555
|
+
# ==== Notes
|
556
|
+
# Recommended way to find out what paths Rakefiles
|
557
|
+
# are loaded from.
|
558
|
+
def rakefiles
|
559
|
+
@rakefiles ||= ['merb-core' / 'test' / 'tasks' / 'spectasks']
|
560
|
+
end
|
561
|
+
|
562
|
+
# === Returns
|
563
|
+
# Array(String):: Paths generators are loaded from
|
564
|
+
#
|
565
|
+
# === Notes
|
566
|
+
# Recommended way to find out what paths generators
|
567
|
+
# are loaded from.
|
568
|
+
def generators
|
569
|
+
@generators ||= []
|
570
|
+
end
|
571
|
+
|
572
|
+
# ==== Parameters
|
573
|
+
# *rakefiles:: Rakefile pathss to add to the list of Rakefiles.
|
574
|
+
#
|
575
|
+
# ==== Notes
|
576
|
+
# Recommended way to add Rakefiles load path for plugins authors.
|
577
|
+
def add_rakefiles(*rakefiles)
|
578
|
+
@rakefiles ||= ['merb-core' / 'test' / 'tasks' / 'spectasks']
|
579
|
+
@rakefiles += rakefiles
|
580
|
+
end
|
581
|
+
|
582
|
+
# ==== Parameters
|
583
|
+
# *generators:: Generator paths to add to the list of generators.
|
584
|
+
#
|
585
|
+
# ==== Notes
|
586
|
+
# Recommended way to add Generator load paths for plugin authors.
|
587
|
+
def add_generators(*generators)
|
588
|
+
@generators ||= []
|
589
|
+
@generators += generators
|
590
|
+
end
|
591
|
+
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
595
|
+
require 'merb-core' / 'autoload'
|
596
|
+
require 'merb-core' / 'server'
|
597
|
+
require 'merb-core' / 'gem_ext/erubis'
|
598
|
+
require 'merb-core' / 'logger'
|
599
|
+
require 'merb-core' / 'version'
|
600
|
+
require 'merb-core' / 'controller/mime'
|
601
|
+
|
602
|
+
# Set the environment if it hasn't already been set.
|
603
|
+
Merb.environment ||= ENV['MERB_ENV'] || Merb::Config[:environment] || (Merb.testing? ? 'test' : 'development')
|