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
data/docs/bootloading.dox
DELETED
@@ -1,58 +0,0 @@
|
|
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
|
-
|
@@ -1,40 +0,0 @@
|
|
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
DELETED
@@ -1,51 +0,0 @@
|
|
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"
|
@@ -1,433 +0,0 @@
|
|
1
|
-
# TITLE:
|
2
|
-
#
|
3
|
-
# Dictionary
|
4
|
-
#
|
5
|
-
# AUTHORS:
|
6
|
-
#
|
7
|
-
# - Jan Molic
|
8
|
-
# - Thomas Sawyer
|
9
|
-
#
|
10
|
-
# CREDIT:
|
11
|
-
#
|
12
|
-
# - Andrew Johnson (merge, to_a, inspect, shift and Hash[])
|
13
|
-
# - Jeff Sharpe (reverse and reverse!)
|
14
|
-
# - Thomas Leitner (has_key? and key?)
|
15
|
-
#
|
16
|
-
# LICENSE:
|
17
|
-
#
|
18
|
-
# Copyright (c) 2005 Jan Molic, Thomas Sawyer
|
19
|
-
#
|
20
|
-
# Ruby License
|
21
|
-
#
|
22
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
23
|
-
# software under the same terms as Ruby.
|
24
|
-
#
|
25
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
26
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
27
|
-
# FOR A PARTICULAR PURPOSE.
|
28
|
-
#
|
29
|
-
# Originally ported from OrderHash 2.0, Copyright (c) 2005 jan molic
|
30
|
-
#
|
31
|
-
# LOG:
|
32
|
-
#
|
33
|
-
# - 2007.10.31 trans
|
34
|
-
# Fixed initialize so the constructor blocks correctly effected dictionary
|
35
|
-
# rather then just the internal hash.
|
36
|
-
|
37
|
-
# = Dictionary
|
38
|
-
#
|
39
|
-
# The Dictionary class is a Hash that preserves order.
|
40
|
-
# So it has some array-like extensions also. By defualt
|
41
|
-
# a Dictionary object preserves insertion order, but any
|
42
|
-
# order can be specified including alphabetical key order.
|
43
|
-
#
|
44
|
-
# == Usage
|
45
|
-
#
|
46
|
-
# Just require this file and use Dictionary instead of Hash.
|
47
|
-
#
|
48
|
-
# # You can do simply
|
49
|
-
# hsh = Dictionary.new
|
50
|
-
# hsh['z'] = 1
|
51
|
-
# hsh['a'] = 2
|
52
|
-
# hsh['c'] = 3
|
53
|
-
# p hsh.keys #=> ['z','a','c']
|
54
|
-
#
|
55
|
-
# # or using Dictionary[] method
|
56
|
-
# hsh = Dictionary['z', 1, 'a', 2, 'c', 3]
|
57
|
-
# p hsh.keys #=> ['z','a','c']
|
58
|
-
#
|
59
|
-
# # but this doesn't preserve order
|
60
|
-
# hsh = Dictionary['z'=>1, 'a'=>2, 'c'=>3]
|
61
|
-
# p hsh.keys #=> ['a','c','z']
|
62
|
-
#
|
63
|
-
# # Dictionary has useful extensions: push, pop and unshift
|
64
|
-
# p hsh.push('to_end', 15) #=> true, key added
|
65
|
-
# p hsh.push('to_end', 30) #=> false, already - nothing happen
|
66
|
-
# p hsh.unshift('to_begin', 50) #=> true, key added
|
67
|
-
# p hsh.unshift('to_begin', 60) #=> false, already - nothing happen
|
68
|
-
# p hsh.keys #=> ["to_begin", "a", "c", "z", "to_end"]
|
69
|
-
# p hsh.pop #=> ["to_end", 15], if nothing remains, return nil
|
70
|
-
# p hsh.keys #=> ["to_begin", "a", "c", "z"]
|
71
|
-
# p hsh.shift #=> ["to_begin", 30], if nothing remains, return nil
|
72
|
-
#
|
73
|
-
# == Usage Notes
|
74
|
-
#
|
75
|
-
# * You can use #order_by to set internal sort order.
|
76
|
-
# * #<< takes a two element [k,v] array and inserts.
|
77
|
-
# * Use ::auto which creates Dictionay sub-entries as needed.
|
78
|
-
# * And ::alpha which creates a new Dictionary sorted by key.
|
79
|
-
|
80
|
-
class Dictionary
|
81
|
-
|
82
|
-
include Enumerable
|
83
|
-
|
84
|
-
class << self
|
85
|
-
#--
|
86
|
-
# TODO is this needed? Doesn't the super class do this?
|
87
|
-
#++
|
88
|
-
def [](*args)
|
89
|
-
hsh = new
|
90
|
-
if Hash === args[0]
|
91
|
-
hsh.replace(args[0])
|
92
|
-
elsif (args.size % 2) != 0
|
93
|
-
raise ArgumentError, "odd number of elements for Hash"
|
94
|
-
else
|
95
|
-
while !args.empty?
|
96
|
-
hsh[args.shift] = args.shift
|
97
|
-
end
|
98
|
-
end
|
99
|
-
hsh
|
100
|
-
end
|
101
|
-
|
102
|
-
# Like #new but the block sets the order.
|
103
|
-
#
|
104
|
-
def new_by(*args, &blk)
|
105
|
-
new(*args).order_by(&blk)
|
106
|
-
end
|
107
|
-
|
108
|
-
# Alternate to #new which creates a dictionary sorted by key.
|
109
|
-
#
|
110
|
-
# d = Dictionary.alpha
|
111
|
-
# d["z"] = 1
|
112
|
-
# d["y"] = 2
|
113
|
-
# d["x"] = 3
|
114
|
-
# d #=> {"x"=>3,"y"=>2,"z"=>2}
|
115
|
-
#
|
116
|
-
# This is equivalent to:
|
117
|
-
#
|
118
|
-
# Dictionary.new.order_by { |key,value| key }
|
119
|
-
def alpha(*args, &block)
|
120
|
-
new(*args, &block).order_by_key
|
121
|
-
end
|
122
|
-
|
123
|
-
# Alternate to #new which auto-creates sub-dictionaries as needed.
|
124
|
-
#
|
125
|
-
# d = Dictionary.auto
|
126
|
-
# d["a"]["b"]["c"] = "abc" #=> { "a"=>{"b"=>{"c"=>"abc"}}}
|
127
|
-
#
|
128
|
-
def auto(*args)
|
129
|
-
#AutoDictionary.new(*args)
|
130
|
-
leet = lambda { |hsh, key| hsh[key] = new(&leet) }
|
131
|
-
new(*args, &leet)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
# New Dictiionary.
|
136
|
-
def initialize(*args, &blk)
|
137
|
-
@order = []
|
138
|
-
@order_by = nil
|
139
|
-
if blk
|
140
|
-
dict = self # This ensure autmatic key entry effect the
|
141
|
-
oblk = lambda{ |hsh, key| blk[dict,key] } # dictionary rather then just the interal hash.
|
142
|
-
@hash = Hash.new(*args, &oblk)
|
143
|
-
else
|
144
|
-
@hash = Hash.new(*args)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def order
|
149
|
-
reorder if @order_by
|
150
|
-
@order
|
151
|
-
end
|
152
|
-
|
153
|
-
# Keep dictionary sorted by a specific sort order.
|
154
|
-
def order_by( &block )
|
155
|
-
@order_by = block
|
156
|
-
order
|
157
|
-
self
|
158
|
-
end
|
159
|
-
|
160
|
-
# Keep dictionary sorted by key.
|
161
|
-
#
|
162
|
-
# d = Dictionary.new.order_by_key
|
163
|
-
# d["z"] = 1
|
164
|
-
# d["y"] = 2
|
165
|
-
# d["x"] = 3
|
166
|
-
# d #=> {"x"=>3,"y"=>2,"z"=>2}
|
167
|
-
#
|
168
|
-
# This is equivalent to:
|
169
|
-
#
|
170
|
-
# Dictionary.new.order_by { |key,value| key }
|
171
|
-
#
|
172
|
-
# The initializer Dictionary#alpha also provides this.
|
173
|
-
def order_by_key
|
174
|
-
@order_by = lambda { |k,v| k }
|
175
|
-
order
|
176
|
-
self
|
177
|
-
end
|
178
|
-
|
179
|
-
# Keep dictionary sorted by value.
|
180
|
-
#
|
181
|
-
# d = Dictionary.new.order_by_value
|
182
|
-
# d["z"] = 1
|
183
|
-
# d["y"] = 2
|
184
|
-
# d["x"] = 3
|
185
|
-
# d #=> {"x"=>3,"y"=>2,"z"=>2}
|
186
|
-
#
|
187
|
-
# This is equivalent to:
|
188
|
-
#
|
189
|
-
# Dictionary.new.order_by { |key,value| value }
|
190
|
-
def order_by_value
|
191
|
-
@order_by = lambda { |k,v| v }
|
192
|
-
order
|
193
|
-
self
|
194
|
-
end
|
195
|
-
|
196
|
-
#
|
197
|
-
def reorder
|
198
|
-
if @order_by
|
199
|
-
assoc = @order.collect{ |k| [k,@hash[k]] }.sort_by(&@order_by)
|
200
|
-
@order = assoc.collect{ |k,v| k }
|
201
|
-
end
|
202
|
-
@order
|
203
|
-
end
|
204
|
-
|
205
|
-
def ==(hsh2)
|
206
|
-
if hsh2.is_a?( Dictionary )
|
207
|
-
@order == hsh2.order &&
|
208
|
-
@hash == hsh2.instance_variable_get("@hash")
|
209
|
-
else
|
210
|
-
false
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def [] k
|
215
|
-
@hash[ k ]
|
216
|
-
end
|
217
|
-
|
218
|
-
def fetch(k, *a, &b)
|
219
|
-
@hash.fetch(k, *a, &b)
|
220
|
-
end
|
221
|
-
|
222
|
-
# Store operator.
|
223
|
-
#
|
224
|
-
# h[key] = value
|
225
|
-
#
|
226
|
-
# Or with additional index.
|
227
|
-
#
|
228
|
-
# h[key,index] = value
|
229
|
-
def []=(k, i=nil, v=nil)
|
230
|
-
if v
|
231
|
-
insert(i,k,v)
|
232
|
-
else
|
233
|
-
store(k,i)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
def insert( i,k,v )
|
238
|
-
@order.insert( i,k )
|
239
|
-
@hash.store( k,v )
|
240
|
-
end
|
241
|
-
|
242
|
-
def store( a,b )
|
243
|
-
@order.push( a ) unless @hash.has_key?( a )
|
244
|
-
@hash.store( a,b )
|
245
|
-
end
|
246
|
-
|
247
|
-
def clear
|
248
|
-
@order = []
|
249
|
-
@hash.clear
|
250
|
-
end
|
251
|
-
|
252
|
-
def delete( key )
|
253
|
-
@order.delete( key )
|
254
|
-
@hash.delete( key )
|
255
|
-
end
|
256
|
-
|
257
|
-
def each_key
|
258
|
-
order.each { |k| yield( k ) }
|
259
|
-
self
|
260
|
-
end
|
261
|
-
|
262
|
-
def each_value
|
263
|
-
order.each { |k| yield( @hash[k] ) }
|
264
|
-
self
|
265
|
-
end
|
266
|
-
|
267
|
-
def each
|
268
|
-
order.each { |k| yield( k,@hash[k] ) }
|
269
|
-
self
|
270
|
-
end
|
271
|
-
alias each_pair each
|
272
|
-
|
273
|
-
def delete_if
|
274
|
-
order.clone.each { |k| delete k if yield(k,@hash[k]) }
|
275
|
-
self
|
276
|
-
end
|
277
|
-
|
278
|
-
def values
|
279
|
-
ary = []
|
280
|
-
order.each { |k| ary.push @hash[k] }
|
281
|
-
ary
|
282
|
-
end
|
283
|
-
|
284
|
-
def keys
|
285
|
-
order
|
286
|
-
end
|
287
|
-
|
288
|
-
def invert
|
289
|
-
hsh2 = self.class.new
|
290
|
-
order.each { |k| hsh2[@hash[k]] = k }
|
291
|
-
hsh2
|
292
|
-
end
|
293
|
-
|
294
|
-
def reject( &block )
|
295
|
-
self.dup.delete_if(&block)
|
296
|
-
end
|
297
|
-
|
298
|
-
def reject!( &block )
|
299
|
-
hsh2 = reject(&block)
|
300
|
-
self == hsh2 ? nil : hsh2
|
301
|
-
end
|
302
|
-
|
303
|
-
def replace( hsh2 )
|
304
|
-
@order = hsh2.order
|
305
|
-
@hash = hsh2.hash
|
306
|
-
end
|
307
|
-
|
308
|
-
def shift
|
309
|
-
key = order.first
|
310
|
-
key ? [key,delete(key)] : super
|
311
|
-
end
|
312
|
-
|
313
|
-
def unshift( k,v )
|
314
|
-
unless @hash.include?( k )
|
315
|
-
@order.unshift( k )
|
316
|
-
@hash.store( k,v )
|
317
|
-
true
|
318
|
-
else
|
319
|
-
false
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
def <<(kv)
|
324
|
-
push( *kv )
|
325
|
-
end
|
326
|
-
|
327
|
-
def push( k,v )
|
328
|
-
unless @hash.include?( k )
|
329
|
-
@order.push( k )
|
330
|
-
@hash.store( k,v )
|
331
|
-
true
|
332
|
-
else
|
333
|
-
false
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
def pop
|
338
|
-
key = order.last
|
339
|
-
key ? [key,delete(key)] : nil
|
340
|
-
end
|
341
|
-
|
342
|
-
def inspect
|
343
|
-
ary = []
|
344
|
-
each {|k,v| ary << k.inspect + "=>" + v.inspect}
|
345
|
-
'{' + ary.join(", ") + '}'
|
346
|
-
end
|
347
|
-
|
348
|
-
def dup
|
349
|
-
a = []
|
350
|
-
each{ |k,v| a << k; a << v }
|
351
|
-
self.class[*a]
|
352
|
-
end
|
353
|
-
|
354
|
-
def update( hsh2 )
|
355
|
-
hsh2.each { |k,v| self[k] = v }
|
356
|
-
reorder
|
357
|
-
self
|
358
|
-
end
|
359
|
-
alias :merge! update
|
360
|
-
|
361
|
-
def merge( hsh2 )
|
362
|
-
self.dup.update(hsh2)
|
363
|
-
end
|
364
|
-
|
365
|
-
def select
|
366
|
-
ary = []
|
367
|
-
each { |k,v| ary << [k,v] if yield k,v }
|
368
|
-
ary
|
369
|
-
end
|
370
|
-
|
371
|
-
def reverse!
|
372
|
-
@order.reverse!
|
373
|
-
self
|
374
|
-
end
|
375
|
-
|
376
|
-
def reverse
|
377
|
-
dup.reverse!
|
378
|
-
end
|
379
|
-
|
380
|
-
def first
|
381
|
-
@hash[order.first]
|
382
|
-
end
|
383
|
-
|
384
|
-
def last
|
385
|
-
@hash[order.last]
|
386
|
-
end
|
387
|
-
|
388
|
-
def length
|
389
|
-
@order.length
|
390
|
-
end
|
391
|
-
alias :size :length
|
392
|
-
|
393
|
-
def empty?
|
394
|
-
@hash.empty?
|
395
|
-
end
|
396
|
-
|
397
|
-
def has_key?(key)
|
398
|
-
@hash.has_key?(key)
|
399
|
-
end
|
400
|
-
|
401
|
-
def key?(key)
|
402
|
-
@hash.key?(key)
|
403
|
-
end
|
404
|
-
|
405
|
-
def to_a
|
406
|
-
ary = []
|
407
|
-
each { |k,v| ary << [k,v] }
|
408
|
-
ary
|
409
|
-
end
|
410
|
-
|
411
|
-
def to_json
|
412
|
-
buf = "["
|
413
|
-
map do |k,v|
|
414
|
-
buf << k.to_json
|
415
|
-
buf << ", "
|
416
|
-
buf << v.to_json
|
417
|
-
end.join(", ")
|
418
|
-
buf << "]"
|
419
|
-
buf
|
420
|
-
end
|
421
|
-
|
422
|
-
def to_s
|
423
|
-
self.to_a.to_s
|
424
|
-
end
|
425
|
-
|
426
|
-
def to_hash
|
427
|
-
@hash.dup
|
428
|
-
end
|
429
|
-
|
430
|
-
def to_h
|
431
|
-
@hash.dup
|
432
|
-
end
|
433
|
-
end
|