rad_core 0.0.13 → 0.0.14
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/Rakefile +4 -3
- data/lib/components/config.rb +6 -0
- data/lib/components/controller.rb +5 -0
- data/lib/components/controller.yml +3 -0
- data/lib/components/conveyors.rb +7 -0
- data/lib/components/environment.rb +5 -0
- data/lib/components/environment.yml +3 -0
- data/lib/components/flash.rb +5 -0
- data/lib/components/html.rb +4 -0
- data/lib/components/html.yml +3 -0
- data/lib/components/http.rb +6 -0
- data/lib/components/http.yml +13 -0
- data/lib/components/logger.rb +5 -0
- data/lib/components/mailer.rb +9 -0
- data/lib/components/remote.rb +4 -0
- data/lib/components/router.rb +13 -0
- data/lib/components/router.yml +2 -0
- data/lib/components/template.rb +8 -0
- data/lib/components/template.yml +1 -0
- data/lib/components/web.rb +8 -0
- data/lib/components/workspace.rb +1 -0
- data/lib/rad/{support → _support}/active_support/locales/en/actionpack.yml +0 -0
- data/lib/rad/{support → _support}/active_support/locales/en/activesupport.yml +0 -0
- data/lib/rad/_support/active_support/locales/ru/actionview.yml +162 -0
- data/lib/rad/_support/active_support/locales/ru/activesupport.yml +16 -0
- data/lib/rad/_support/active_support/locales/ru/datetime.yml +49 -0
- data/lib/rad/{support → _support}/active_support/micelaneous.rb +0 -0
- data/lib/rad/{support → _support}/active_support/time.rb +0 -0
- data/lib/rad/{support → _support}/active_support.rb +14 -2
- data/lib/rad/{support → _support}/addressable.rb +0 -0
- data/lib/rad/_support/callbacks.rb +166 -0
- data/lib/rad/_support/class_loader.rb +9 -0
- data/lib/rad/_support/encoding.rb +3 -0
- data/lib/rad/_support/exception.rb +45 -0
- data/lib/rad/_support/extensions.rb +20 -0
- data/lib/rad/_support/filters.rb +32 -0
- data/lib/rad/{support → _support}/hacks_and_fixes.rb +0 -0
- data/lib/rad/{support → _support}/mime.rb +6 -0
- data/lib/rad/{support → _support}/module.rb +7 -9
- data/lib/rad/_support/require.rb +62 -0
- data/lib/rad/{support → _support}/rson.rb +0 -0
- data/lib/rad/{support → _support}/ruby_ext_with_active_support.rb +0 -0
- data/lib/rad/{support → _support}/string.rb +9 -1
- data/lib/rad/controller/_abstract/micelaneous.rb +27 -0
- data/lib/rad/controller/_abstract/render.rb +159 -0
- data/lib/rad/controller/_abstract/responder.rb +13 -0
- data/lib/rad/controller/_abstract.rb +37 -0
- data/lib/rad/controller/_context.rb +15 -0
- data/lib/rad/controller/_http.rb +50 -0
- data/lib/rad/controller/_require.rb +19 -0
- data/lib/rad/controller/abstract.rb +1 -0
- data/lib/rad/controller/context.rb +1 -0
- data/lib/rad/controller/http.rb +1 -0
- data/lib/rad/controller/processors/controller_caller.rb +22 -24
- data/lib/rad/controller/processors/controller_error_handling.rb +46 -48
- data/lib/rad/controller/processors/controller_logger.rb +7 -9
- data/lib/rad/controller.rb +1 -28
- data/lib/rad/conveyors/_conveyor.rb +73 -0
- data/lib/rad/conveyors/_conveyors.rb +19 -0
- data/lib/rad/conveyors/_params.rb +10 -0
- data/lib/rad/conveyors/_processor.rb +13 -0
- data/lib/rad/conveyors/_require.rb +10 -0
- data/lib/rad/conveyors/_workspace.rb +34 -0
- data/lib/rad/conveyors/params.rb +1 -0
- data/lib/rad/conveyors/processor.rb +1 -0
- data/lib/rad/conveyors/processors/conveyor_logger.rb +23 -0
- data/lib/rad/conveyors/workspace.rb +1 -0
- data/lib/rad/conveyors.rb +1 -0
- data/lib/rad/core_web/_controller_micelaneous_helper.rb +17 -0
- data/lib/rad/core_web/_require.rb +25 -0
- data/lib/rad/core_web/_router/abstract_routing_helper.rb +20 -0
- data/lib/rad/core_web/_router/controller_routing_helper.rb +56 -0
- data/lib/rad/core_web/_router/view_routing_helper.rb +57 -0
- data/lib/rad/environment/_config.rb +27 -0
- data/lib/rad/environment/_environment.rb +17 -0
- data/lib/rad/environment/_files_helper.rb +55 -0
- data/lib/rad/environment/_logger.rb +53 -0
- data/lib/rad/environment/_require.rb +24 -0
- data/lib/rad/environment/config.rb +1 -111
- data/lib/rad/environment.rb +1 -55
- data/lib/{rad_core → rad}/gems.rb +2 -3
- data/lib/rad/html/_flash.rb +40 -0
- data/lib/rad/html/_helpers/basic_html_helper.rb +72 -0
- data/lib/rad/html/_helpers/flash_helper.rb +3 -0
- data/lib/rad/html/_helpers/form_helper.rb +114 -0
- data/lib/rad/html/_helpers/html_helper.rb +3 -0
- data/lib/rad/html/_helpers/javascript_helper.rb +27 -0
- data/lib/rad/html/_helpers/model_helper.rb +143 -0
- data/lib/rad/html/_require.rb +15 -0
- data/lib/rad/html/processors/prepare_flash.rb +22 -23
- data/lib/rad/html/processors/scoped_params.rb +18 -21
- data/lib/rad/html.rb +1 -26
- data/lib/rad/http/_http.rb +11 -0
- data/lib/rad/http/_http_adapter.rb +44 -0
- data/lib/rad/http/_request.rb +50 -0
- data/lib/rad/http/_require.rb +33 -0
- data/lib/rad/http/_response.rb +84 -0
- data/lib/rad/http/{support → _support}/rack/fixes.rb +0 -0
- data/lib/rad/http/_support/rack/rack_adapter.rb +57 -0
- data/lib/rad/http/processors/evaluate_format.rb +16 -19
- data/lib/rad/http/processors/http_logger.rb +10 -12
- data/lib/rad/http/processors/http_writer.rb +24 -26
- data/lib/rad/http/processors/prepare_params.rb +19 -18
- data/lib/rad/http/request.rb +1 -0
- data/lib/rad/http/response.rb +1 -0
- data/lib/rad/http.rb +1 -48
- data/lib/rad/mailer/_letter.rb +28 -0
- data/lib/rad/mailer/_mailer.rb +13 -0
- data/lib/rad/mailer/_mailer_controller.rb +38 -0
- data/lib/rad/mailer/_require.rb +7 -0
- data/lib/rad/mailer/mailer_controller.rb +1 -0
- data/lib/rad/mailer/processors/letter_builder.rb +34 -0
- data/lib/rad/mailer.rb +1 -0
- data/lib/rad/profiles/mailer.rb +5 -0
- data/lib/rad/profiles/web.rb +29 -52
- data/lib/rad/remote/_remote_controller.rb +9 -0
- data/lib/rad/remote/_require.rb +6 -0
- data/lib/rad/remote/processors/remote_caller.rb +44 -46
- data/lib/rad/remote/processors/remote_logger.rb +8 -10
- data/lib/rad/remote/remote_controller.rb +1 -0
- data/lib/rad/remote.rb +1 -9
- data/lib/rad/router/_abstract_router.rb +50 -0
- data/lib/rad/router/_alias_router.rb +124 -0
- data/lib/rad/router/_basic_router.rb +72 -0
- data/lib/rad/router/_configurator.rb +19 -0
- data/lib/rad/router/_core_routing_helper.rb +39 -0
- data/lib/rad/router/_default_format_processor.rb +10 -0
- data/lib/rad/router/_object_router.rb +184 -0
- data/lib/rad/router/_require.rb +31 -0
- data/lib/rad/router/_restful_router.rb +124 -0
- data/lib/rad/router/_router.rb +294 -0
- data/lib/rad/router/_simple_router.rb +21 -0
- data/lib/rad/router/abstract_router.rb +1 -0
- data/lib/rad/router/alias_router.rb +1 -0
- data/lib/rad/router/configurator.rb +1 -0
- data/lib/rad/router/micelaneous_router.rb +1 -0
- data/lib/rad/router/object_router.rb +1 -0
- data/lib/rad/router/processors/router.rb +23 -0
- data/lib/rad/router/restful_router.rb +1 -0
- data/lib/rad/{html/include_into_controller.rb → router/simple_router.rb} +0 -0
- data/lib/rad/router.rb +1 -29
- data/lib/rad/spec/controller.rb +20 -11
- data/lib/rad/spec/environment.rb +22 -38
- data/lib/rad/spec/http.rb +13 -86
- data/lib/rad/spec/http_controller.rb +105 -0
- data/lib/rad/spec/mailer.rb +27 -0
- data/lib/rad/spec/remote.rb +2 -2
- data/lib/rad/spec/router.rb +9 -11
- data/lib/rad/spec/template.rb +8 -2
- data/lib/rad/spec/xhtml.rb +0 -2
- data/lib/rad/spec.rb +4 -2
- data/lib/rad/template/_context.rb +92 -0
- data/lib/rad/template/_relative_path_resolver.rb +8 -0
- data/lib/rad/template/_require.rb +15 -0
- data/lib/rad/template/{support → _support}/tilt.rb +0 -0
- data/lib/rad/template/{support → _support}/tilt_fixes.rb +0 -0
- data/lib/rad/template/_template.rb +175 -0
- data/lib/rad/template/template_context.rb +1 -62
- data/lib/rad/template.rb +1 -25
- data/lib/rad.rb +8 -0
- data/readme.md +40 -12
- data/spec/controller/{abstract_controller_spec → abstract_spec}/views/OperationsOrderSpec/action.erb +0 -0
- data/spec/controller/{abstract_controller_spec → abstract_spec}/views/ViewVariablesSpec/action.erb +0 -0
- data/spec/controller/abstract_spec.rb +126 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/NamespaceSpec/ClassSpec}/show.erb +0 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/actions.erb +0 -0
- data/spec/controller/{controller_context_spec/views/NamespaceSpec/ClassSpec → context_spec/views/item_spec}/show.erb +0 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/update.erb +0 -0
- data/spec/controller/{controller_context_spec → context_spec}/views/namespace_spec/class_spec/update.erb +0 -0
- data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/actions.erb +0 -0
- data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/show.erb +0 -0
- data/spec/controller/context_spec.rb +123 -0
- data/spec/controller/error_handling_spec.rb +21 -27
- data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperMethodSpec/action.erb +0 -0
- data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperSpec/action.erb +0 -0
- data/spec/controller/{controller_helper_spec.rb → helper_spec.rb} +7 -13
- data/spec/controller/{http_controller_spec.rb → http_spec.rb} +17 -23
- data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/custom_template.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AnotherActionSpec → render_spec/views/another_action_spec}/another_action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AnotherLayout → render_spec/views/another_layout}/action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/ForbidPartialAsActionSpec → render_spec/views/forbid_partial_as_action_spec}/_action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.html.erb +0 -0
- data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.js.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_with_layout.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_without_layout.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutSpec → render_spec/views/layout_spec}/action.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/admin.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.html.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.js.erb +0 -0
- data/spec/controller/{controller_render_spec/views/MultipleActions → render_spec/views/multiple_actions}/actions.haml +0 -0
- data/spec/controller/render_spec/views/relative_spec/a/form.erb +1 -0
- data/spec/controller/render_spec/views/relative_spec/a/show.erb +1 -0
- data/spec/controller/render_spec/views/relative_spec/b/form.erb +1 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/some_template.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/standalone.html.erb +0 -0
- data/spec/controller/{controller_render_spec.rb → render_spec.rb} +37 -27
- data/spec/{conveyor/conveyor_spec.rb → conveyors/conveyors_spec.rb} +36 -14
- data/spec/environment/config_spec.rb +13 -21
- data/spec/environment/environment_spec.rb +14 -41
- data/spec/environment/logger_spec.rb +4 -13
- data/spec/environment/minimal_app_spec/app.rb +1 -1
- data/spec/environment/minimal_app_spec.rb +12 -14
- data/spec/environment/standard_app_spec/app/lib/app/init.rb +1 -1
- data/spec/environment/standard_app_spec/plugin_a/lib/plugin_a/init.rb +1 -1
- data/spec/environment/standard_app_spec.rb +17 -25
- data/spec/html/basic_html_helper_spec.rb +7 -4
- data/spec/html/form_helper_spec.rb +5 -5
- data/spec/html/javascript_helper_spec.rb +9 -5
- data/spec/html/model_helper_spec.rb +9 -6
- data/spec/html/scoped_params_spec.rb +2 -2
- data/spec/html/spec_helper.rb +16 -24
- data/spec/http/http_spec.rb +14 -35
- data/spec/http/micelaneous_spec.rb +3 -3
- data/spec/{mail → mailer}/mail_controller_spec/views/body_template_spec/signup.erb +0 -0
- data/spec/{mail → mailer}/mail_controller_spec.rb +36 -12
- data/spec/mailer/spec_helper.rb +5 -0
- data/spec/remote/remote_spec.rb +23 -8
- data/spec/router/alias_router_spec.rb +29 -30
- data/spec/router/basic_router_spec.rb +44 -0
- data/spec/router/configurator_spec.rb +9 -6
- data/spec/router/integration_spec.rb +10 -7
- data/spec/router/object_router_spec.rb +186 -0
- data/spec/router/persistent_params_spec.rb +4 -4
- data/spec/router/restful_router_spec.rb +61 -53
- data/spec/router/{basic_spec.rb → router_spec.rb} +26 -23
- data/spec/router/routing_helper_spec.rb +5 -6
- data/spec/spec_helper.rb +4 -0
- data/spec/support/callbacks_spec.rb +1 -1
- data/spec/support/filters_spec.rb +2 -2
- data/spec/support/spec_helper.rb +1 -1
- data/spec/template/template_spec/views/format_for_partials/dialog.js.erb +1 -1
- data/spec/template/template_spec/views/nested/format/a.erb +1 -1
- data/spec/template/template_spec/views/nested/format/b.js.erb +1 -0
- data/spec/template/template_spec/views/nesting_format/dialog.js.erb +1 -1
- data/spec/template/template_spec.rb +62 -48
- data/spec/template/tilt_spec/views/concat_and_capture.erb +1 -1
- data/spec/template/tilt_spec/views/concat_and_capture.haml +1 -1
- data/spec/template/tilt_spec.rb +17 -19
- data/spec/{integration → web}/basic_spec/views/smoke_test_spec/action.erb +0 -0
- data/spec/{integration → web}/basic_spec.rb +31 -12
- data/spec/{integration → web}/controller_routing_helper_spec.rb +13 -11
- data/spec/{integration → web}/flash_spec.rb +57 -42
- data/spec/{integration → web}/spec_helper_spec.rb +11 -10
- data/spec/{integration → web}/view_routing_helper_spec.rb +44 -36
- metadata +338 -318
- data/lib/rad/controller/abstract_controller/micelaneous.rb +0 -31
- data/lib/rad/controller/abstract_controller/render.rb +0 -160
- data/lib/rad/controller/abstract_controller/responder.rb +0 -17
- data/lib/rad/controller/abstract_controller.rb +0 -64
- data/lib/rad/controller/controller_context.rb +0 -15
- data/lib/rad/controller/http_controller.rb +0 -48
- data/lib/rad/conveyor/conveyor.rb +0 -74
- data/lib/rad/conveyor/conveyors.rb +0 -20
- data/lib/rad/conveyor/params.rb +0 -14
- data/lib/rad/conveyor/processor.rb +0 -68
- data/lib/rad/conveyor/processors/conveyor_logger.rb +0 -25
- data/lib/rad/conveyor/workspace.rb +0 -36
- data/lib/rad/conveyor.rb +0 -29
- data/lib/rad/environment/dependency_resolver.rb +0 -107
- data/lib/rad/environment/environment.rb +0 -29
- data/lib/rad/environment/files_helper.rb +0 -55
- data/lib/rad/environment/logger.rb +0 -21
- data/lib/rad/html/flash.rb +0 -42
- data/lib/rad/html/helpers/basic_html_helper.rb +0 -83
- data/lib/rad/html/helpers/flash_helper.rb +0 -5
- data/lib/rad/html/helpers/form_helper.rb +0 -115
- data/lib/rad/html/helpers/html_helper.rb +0 -5
- data/lib/rad/html/helpers/javascript_helper.rb +0 -18
- data/lib/rad/html/helpers/model_helper.rb +0 -135
- data/lib/rad/http/http.rb +0 -21
- data/lib/rad/http/http_adapter.rb +0 -36
- data/lib/rad/http/middleware/static_files.rb +0 -21
- data/lib/rad/http/support/rack/rack_adapter.rb +0 -67
- data/lib/rad/http/support/rack/request.rb +0 -42
- data/lib/rad/http/support/rack/response.rb +0 -86
- data/lib/rad/integration/controller_micelaneous_helper.rb +0 -19
- data/lib/rad/integration/router/abstract_routing_helper.rb +0 -22
- data/lib/rad/integration/router/controller_routing_helper.rb +0 -58
- data/lib/rad/integration/router/view_routing_helper.rb +0 -104
- data/lib/rad/integration.rb +0 -30
- data/lib/rad/mail/letter.rb +0 -30
- data/lib/rad/mail/mail_controller.rb +0 -31
- data/lib/rad/mail/mailer.rb +0 -23
- data/lib/rad/mail/processors/letter_builder.rb +0 -36
- data/lib/rad/mail.rb +0 -15
- data/lib/rad/profiles/mail.rb +0 -16
- data/lib/rad/profiles/web_require.rb +0 -5
- data/lib/rad/remote/remote.rb +0 -15
- data/lib/rad/router/core/configurator.rb +0 -25
- data/lib/rad/router/core/core_routing_helper.rb +0 -41
- data/lib/rad/router/core/default_format_processor.rb +0 -12
- data/lib/rad/router/core/processors/router.rb +0 -29
- data/lib/rad/router/core/router.rb +0 -271
- data/lib/rad/router/core/simple_router.rb +0 -23
- data/lib/rad/router/routers/abstract_router.rb +0 -62
- data/lib/rad/router/routers/alias_router.rb +0 -113
- data/lib/rad/router/routers/restful_router.rb +0 -113
- data/lib/rad/spec/mail.rb +0 -31
- data/lib/rad/spec/view.rb +0 -10
- data/lib/rad/support/buffered_logger.rb +0 -44
- data/lib/rad/support/callbacks.rb +0 -168
- data/lib/rad/support/exception.rb +0 -31
- data/lib/rad/support/filters.rb +0 -34
- data/lib/rad/support/format.rb +0 -17
- data/lib/rad/support/micon.rb +0 -13
- data/lib/rad/support.rb +0 -63
- data/lib/rad/template/template.rb +0 -250
- data/spec/controller/abstract_controller_spec.rb +0 -132
- data/spec/controller/controller_context_spec.rb +0 -123
- data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/action.erb +0 -1
- data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/another_action.erb +0 -1
- data/spec/controller/spec_helper.rb +0 -19
- data/spec/conveyor/spec_helper.rb +0 -3
- data/spec/environment/config_spec/config.default.yml +0 -3
- data/spec/environment/config_spec/config.development.yml +0 -3
- data/spec/environment/config_spec/config.yml +0 -5
- data/spec/environment/spec_helper.rb +0 -1
- data/spec/http/http_spec/app/lib/app/init.rb +0 -10
- data/spec/http/http_spec/app/runtime/public/emptygit +0 -0
- data/spec/http/http_spec/plugin_a/lib/plugin_a/init.rb +0 -0
- data/spec/http/http_spec/plugin_b/lib/plugin_b/init.rb +0 -5
- data/spec/http/http_spec/plugin_b/static/emptygit +0 -0
- data/spec/http/spec_helper.rb +0 -5
- data/spec/integration/spec_helper.rb +0 -5
- data/spec/mail/spec_helper.rb +0 -7
- data/spec/remote/spec_helper.rb +0 -17
- data/spec/router/spec_helper.rb +0 -20
- data/spec/template/spec_helper.rb +0 -6
- data/spec/template/template_spec/views/nested/format/b.erb +0 -1
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
module AbstractController
|
|
3
|
-
module Micelaneous
|
|
4
|
-
#
|
|
5
|
-
# respond_to
|
|
6
|
-
#
|
|
7
|
-
def respond_to &block
|
|
8
|
-
@_responder.must_be.nil
|
|
9
|
-
@_responder = Responder.new
|
|
10
|
-
block.call @_responder
|
|
11
|
-
handler = @_responder.handlers[params.format]
|
|
12
|
-
raise "can't respond to '#{params.format}' format!" unless handler
|
|
13
|
-
handler.call
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
module ClassMethods
|
|
17
|
-
#
|
|
18
|
-
# filter_parameter_logging
|
|
19
|
-
#
|
|
20
|
-
inheritable_accessor :filter_parameter_logging, []
|
|
21
|
-
def filter_parameter_logging_with_sugar *parameters
|
|
22
|
-
if parameters.empty?
|
|
23
|
-
filter_parameter_logging_without_sugar
|
|
24
|
-
else
|
|
25
|
-
filter_parameter_logging_without_sugar.push *parameters.collect(&:to_s)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
module AbstractController
|
|
3
|
-
module Render
|
|
4
|
-
SPECIAL_FORMAT_HANDLERS = {
|
|
5
|
-
json: lambda{|o| o.to_json},
|
|
6
|
-
xml: lambda{|o| o.to_xml},
|
|
7
|
-
js: lambda{|o| o},
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
# SPECIAL_CASES_HANDLERS = [
|
|
11
|
-
# ['inline', lambda{|o| o}],
|
|
12
|
-
# ]
|
|
13
|
-
|
|
14
|
-
def _layout tname = nil
|
|
15
|
-
if tname
|
|
16
|
-
@_layout = tname
|
|
17
|
-
else
|
|
18
|
-
@_layout
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
def _layout= layout
|
|
22
|
-
@_layout = layout
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def render *args
|
|
26
|
-
options = Template.parse_arguments *args
|
|
27
|
-
content = render_with_parsed_arguments options, args
|
|
28
|
-
throw :halt_render, content
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
protected
|
|
32
|
-
def render_action options
|
|
33
|
-
options = options.to_openobject
|
|
34
|
-
options.format ||= params.format
|
|
35
|
-
|
|
36
|
-
render_options = {
|
|
37
|
-
context_class: self.class.controller_context_class,
|
|
38
|
-
format: params.format,
|
|
39
|
-
action: true # this willn't allow to render partial starting with _
|
|
40
|
-
}.to_openobject
|
|
41
|
-
|
|
42
|
-
# rendering content
|
|
43
|
-
content, context = render_content render_options, options
|
|
44
|
-
|
|
45
|
-
render_options.merge!(
|
|
46
|
-
content: content,
|
|
47
|
-
context: context
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
# rendering layout
|
|
51
|
-
render_layout render_options, options
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def render_layout render_options, options
|
|
55
|
-
layout = options.include?(:layout) ? options.layout : self._layout
|
|
56
|
-
if layout
|
|
57
|
-
Template.render_layout layout, render_options
|
|
58
|
-
else
|
|
59
|
-
render_options.content
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def render_content render_options, options
|
|
64
|
-
template = options.template || self.class.template_name_for(options.action, options)
|
|
65
|
-
template = '/rad_default_templates/blank_template' unless Template.exist? template, format: options.format
|
|
66
|
-
|
|
67
|
-
instance_variables = {}
|
|
68
|
-
instance_variable_names.each do |name|
|
|
69
|
-
instance_variables[name[1..-1]] = instance_variable_get name unless name =~ /^@_/
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
instance_variables.merge!(
|
|
73
|
-
action_name: (options.action || workspace.action).to_sym,
|
|
74
|
-
controller_name: self.class.controller_name
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
render_options.merge!(
|
|
78
|
-
template: template,
|
|
79
|
-
instance_variables: instance_variables
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
content, context = Template.basic_render render_options
|
|
83
|
-
return content, context
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def render_with_parsed_arguments options, original_args
|
|
87
|
-
if special_format = SPECIAL_FORMAT_HANDLERS.keys.find{|f| options.include? f}
|
|
88
|
-
handler = SPECIAL_FORMAT_HANDLERS[special_format]
|
|
89
|
-
if special_format.to_s != params.format
|
|
90
|
-
raise "You trying responing with '#{special_format}' to the '#{params.format}' requested format!"
|
|
91
|
-
end
|
|
92
|
-
handler.call options[special_format]
|
|
93
|
-
elsif options.include? :inline
|
|
94
|
-
options.inline
|
|
95
|
-
# elsif special_format_handler = SPECIAL_CASES_HANDLERS.find{|key, handler| options.include? key}
|
|
96
|
-
# key, handler = special_format_handler
|
|
97
|
-
# handler.call options[key]
|
|
98
|
-
else
|
|
99
|
-
render_action options
|
|
100
|
-
# Template.basic_render(options).first
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
module ClassMethods
|
|
107
|
-
def layout layout, options = {}
|
|
108
|
-
before options do |controller|
|
|
109
|
-
controller._layout = layout
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def template_name_for action, options = {}
|
|
114
|
-
action.must_be.a Symbol
|
|
115
|
-
|
|
116
|
-
return _template_name_for(action, options) if config.development?
|
|
117
|
-
|
|
118
|
-
@template_name_for ||= {}
|
|
119
|
-
|
|
120
|
-
key = %(#{action}#{":#{options[:format]}" if options[:format]})
|
|
121
|
-
unless tname = @template_name_for[key]
|
|
122
|
-
tname = _template_name_for(action, options)
|
|
123
|
-
@template_name_for[key] = tname
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
tname
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
protected
|
|
130
|
-
def _template_name_for action, options = {}
|
|
131
|
-
# instance_methods.must.include(action)
|
|
132
|
-
own_tnames = [
|
|
133
|
-
"/#{controller_name.gsub('::', '/')}/#{action}",
|
|
134
|
-
"/#{controller_name.underscore}/#{action}"
|
|
135
|
-
]
|
|
136
|
-
|
|
137
|
-
own_actions_tnames = [
|
|
138
|
-
"/#{controller_name.gsub('::', '/')}/actions",
|
|
139
|
-
"/#{controller_name.underscore}/actions"
|
|
140
|
-
]
|
|
141
|
-
|
|
142
|
-
action_template_exist = lambda do |tname|
|
|
143
|
-
Rad::Template.exist?(tname) and
|
|
144
|
-
(Rad::Template.read(tname) =~ /^.*when.+[^_a-zA-Z0-9]#{action}[^_a-zA-Z0-9].*$/)
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
if existing_template = own_tnames.find{|tname| Rad::Template.exist?(tname, format: options[:format])}
|
|
148
|
-
existing_template
|
|
149
|
-
elsif existing_action_template = own_actions_tnames.find(&action_template_exist)
|
|
150
|
-
existing_action_template
|
|
151
|
-
elsif parent = ancestors[1..-1].find{|a| a.respond_to?(:template_name_for) and a.instance_methods.include?(action)}
|
|
152
|
-
parent.template_name_for(action, options)
|
|
153
|
-
else
|
|
154
|
-
own_tnames.first
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
module AbstractController
|
|
3
|
-
class Responder < BasicObject
|
|
4
|
-
attr_reader :handlers
|
|
5
|
-
|
|
6
|
-
def initialize
|
|
7
|
-
@handlers = {}
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
protected
|
|
11
|
-
def method_missing m, *args, &block
|
|
12
|
-
args.must_be.empty
|
|
13
|
-
handlers[m.to_s] = block.must_be.defined
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
module AbstractController
|
|
3
|
-
inherit Filters
|
|
4
|
-
inherit AbstractController::Render, AbstractController::Micelaneous
|
|
5
|
-
|
|
6
|
-
inject(
|
|
7
|
-
workspace: :workspace,
|
|
8
|
-
logger: :logger,
|
|
9
|
-
config: :config
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
def params
|
|
13
|
-
workspace.params
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# def response
|
|
17
|
-
# workspace.response
|
|
18
|
-
# end
|
|
19
|
-
|
|
20
|
-
module ClassMethods
|
|
21
|
-
inject(
|
|
22
|
-
workspace: :workspace,
|
|
23
|
-
logger: :logger,
|
|
24
|
-
config: :config
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
def controller_name
|
|
28
|
-
self.namespace ? "#{self.namespace.name}::#{self.alias}" : self.alias
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def controller_context_class
|
|
32
|
-
unless @controller_context_class
|
|
33
|
-
parent_context_class = nil
|
|
34
|
-
ancestors[1..-1].each do |anc|
|
|
35
|
-
break if parent_context_class = anc.respond_to(:controller_context_class)
|
|
36
|
-
end
|
|
37
|
-
parent_context_class ||= Rad::ControllerContext
|
|
38
|
-
|
|
39
|
-
class_name = "#{self.name}::#{self.name.split('::').last}ControllerContext"
|
|
40
|
-
|
|
41
|
-
# raise "Tempate context #{class_name} already defined!" if Object.const_defined? class_name
|
|
42
|
-
eval "class #{class_name} < #{parent_context_class}; end", TOPLEVEL_BINDING, __FILE__, __LINE__
|
|
43
|
-
@controller_context_class = class_name.constantize
|
|
44
|
-
end
|
|
45
|
-
@controller_context_class
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def helper *args
|
|
49
|
-
args.to_a.each do |mod|
|
|
50
|
-
mod.must_be.a Module
|
|
51
|
-
controller_context_class.inherit mod
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def helper_method *args
|
|
56
|
-
args = args.first if args.size == 1 and args.first.is_a?(Array)
|
|
57
|
-
# args.each{|m| m.to_s.must_be.in self.instance_methods}
|
|
58
|
-
args.each do |m|
|
|
59
|
-
controller_context_class.delegate m, to: :controller
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
class ControllerContext < TemplateContext
|
|
3
|
-
def controller
|
|
4
|
-
workspace.controller.must_be.defined
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def controller_name
|
|
8
|
-
@controller_name #workspace.controller.class.controller_name
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def action_name
|
|
12
|
-
@action_name #workspace.action.to_sym
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
module HttpController
|
|
3
|
-
inherit AbstractController
|
|
4
|
-
|
|
5
|
-
# def response
|
|
6
|
-
# workspace.response
|
|
7
|
-
# end
|
|
8
|
-
|
|
9
|
-
protected
|
|
10
|
-
def render_with_parsed_arguments options, original_args
|
|
11
|
-
response = workspace.response
|
|
12
|
-
response.set!(
|
|
13
|
-
status: options.status || :ok,
|
|
14
|
-
content_type: options.content_type || Mime[params.format]
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
if original_args.size == 1 and (status = Rad::Response.decode_status_message(original_args.first))
|
|
18
|
-
response.set! status: status
|
|
19
|
-
throw :halt_render, ""
|
|
20
|
-
elsif options.location?
|
|
21
|
-
redirect_to options.location
|
|
22
|
-
else
|
|
23
|
-
super
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
module ClassMethods
|
|
28
|
-
inheritable_accessor :actions_allowed_for_get_request, []
|
|
29
|
-
|
|
30
|
-
def allow_get_for *methods
|
|
31
|
-
enable_protection_from_get_requests!
|
|
32
|
-
actions_allowed_for_get_request.push *methods
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
def enable_protection_from_get_requests!
|
|
37
|
-
unless respond_to? :protect_from_get_request
|
|
38
|
-
define_method :protect_from_get_request do
|
|
39
|
-
if workspace.request.get? and !self.class.actions_allowed_for_get_request.include?(workspace.action)
|
|
40
|
-
raise "Get requests not allowed for :#{workspace.action} action!"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
before :protect_from_get_request
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
class Conveyor
|
|
3
|
-
inject workspace: :workspace
|
|
4
|
-
|
|
5
|
-
def definitions
|
|
6
|
-
@definitions ||= []
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def use processor_class, *initialization_arguments
|
|
10
|
-
definitions << [processor_class, initialization_arguments]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def build!
|
|
14
|
-
@chain = lambda{}
|
|
15
|
-
definitions.reverse.collect do |klass, args|
|
|
16
|
-
klass.must_be.a Class
|
|
17
|
-
@chain = klass.new @chain, *args
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def call workspace_content = {}, &block
|
|
22
|
-
build! unless @chain
|
|
23
|
-
|
|
24
|
-
rad.activate :cycle, {} do
|
|
25
|
-
self.workspace = Workspace.new
|
|
26
|
-
workspace.merge! workspace_content
|
|
27
|
-
|
|
28
|
-
if block
|
|
29
|
-
block.call(@chain)
|
|
30
|
-
else
|
|
31
|
-
@chain.call
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
workspace
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def inspect
|
|
39
|
-
definitions.inspect
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# def trace name, &block
|
|
43
|
-
# start_time = Time.now
|
|
44
|
-
# block.call
|
|
45
|
-
# (workspace.trace ||= []) << [name, Time.now - start_time]
|
|
46
|
-
# end
|
|
47
|
-
|
|
48
|
-
protected
|
|
49
|
-
# def build_chain
|
|
50
|
-
# next_processor_call = nil
|
|
51
|
-
# chain = reverse.collect do |processor|
|
|
52
|
-
# next_processor_call = if next_processor_call
|
|
53
|
-
# lambda{processor.call next_processor}
|
|
54
|
-
# else
|
|
55
|
-
# lambda{processor.call lambda{}}
|
|
56
|
-
# end
|
|
57
|
-
# end
|
|
58
|
-
# next_processor_call
|
|
59
|
-
# end
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# def add_before key, *processors
|
|
63
|
-
# index = index{|processor| processor.name == key or processor.class == key}
|
|
64
|
-
# raise "Can't find Processor '#{name}'!" unless index
|
|
65
|
-
# insert index, *Array(processors)
|
|
66
|
-
# end
|
|
67
|
-
#
|
|
68
|
-
# def add_after key, *processors
|
|
69
|
-
# index = rindex{|processor| processor.name == key or processor.class == key}
|
|
70
|
-
# raise "Can't find Processor '#{name}'!" unless index
|
|
71
|
-
# insert index + 1, *Array(processors)
|
|
72
|
-
# end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
class Conveyors
|
|
3
|
-
|
|
4
|
-
def initialize
|
|
5
|
-
@hash = {}
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def [] conveyor_name
|
|
9
|
-
@hash[conveyor_name.to_s] ||= Rad::Conveyor.new
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def method_missing m, &block
|
|
13
|
-
if block
|
|
14
|
-
block.call self[m]
|
|
15
|
-
else
|
|
16
|
-
self[m]
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
data/lib/rad/conveyor/params.rb
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
class Processor
|
|
3
|
-
inject(
|
|
4
|
-
config: :config,
|
|
5
|
-
workspace: :workspace,
|
|
6
|
-
logger: :logger
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
attr_accessor :next_processor
|
|
10
|
-
|
|
11
|
-
def initialize next_processor
|
|
12
|
-
@next_processor = next_processor
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.inspect
|
|
16
|
-
self.name.split('::').last
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
#
|
|
21
|
-
# # def call
|
|
22
|
-
# # if workspace.error?
|
|
23
|
-
# # respond_to :on_error
|
|
24
|
-
# # else
|
|
25
|
-
# # begin
|
|
26
|
-
# # trace self.inspect do
|
|
27
|
-
# # respond_to :process
|
|
28
|
-
# # end
|
|
29
|
-
# # rescue Exception => e
|
|
30
|
-
# # workspace.error = e
|
|
31
|
-
# # respond_to :on_error
|
|
32
|
-
# # end
|
|
33
|
-
# # end
|
|
34
|
-
# # end
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
# #
|
|
39
|
-
# # Unwrapping Call Stack
|
|
40
|
-
# #
|
|
41
|
-
# def result_error= error
|
|
42
|
-
# @result_error = error
|
|
43
|
-
# end
|
|
44
|
-
#
|
|
45
|
-
# def result!
|
|
46
|
-
# @result_called.must_be.false
|
|
47
|
-
# @result_called = true
|
|
48
|
-
# raise @result_error if @result_error
|
|
49
|
-
# end
|
|
50
|
-
#
|
|
51
|
-
# def result_called?
|
|
52
|
-
# @result_called
|
|
53
|
-
# end
|
|
54
|
-
# attr_writer :result_called
|
|
55
|
-
#
|
|
56
|
-
# attr_accessor :after_block
|
|
57
|
-
# def after &block
|
|
58
|
-
# # @after_called.must_be.false
|
|
59
|
-
# @after_block = block.must_be.defined
|
|
60
|
-
# # @after_called = true
|
|
61
|
-
# end
|
|
62
|
-
#
|
|
63
|
-
# # def after_called?
|
|
64
|
-
# # @after_called
|
|
65
|
-
# # end
|
|
66
|
-
#
|
|
67
|
-
# end
|
|
68
|
-
# end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
module Processors
|
|
3
|
-
class ConveyorLogger < Processor
|
|
4
|
-
def call
|
|
5
|
-
begin
|
|
6
|
-
start_time = Time.now
|
|
7
|
-
next_processor.call
|
|
8
|
-
|
|
9
|
-
# if workspace.trace?
|
|
10
|
-
# total_time = workspace.trace.inject(0){|memo, pair| memo += pair.last}
|
|
11
|
-
# max_pair = workspace.trace.max_by{|pair| pair.last}
|
|
12
|
-
# logger.info "Completed in #{(total_time * 1000).round} ms (#{(max_pair.last * 1000).round} ms taken by #{max_pair.first})\n\n"
|
|
13
|
-
# else
|
|
14
|
-
logger.info " Completed in #{((Time.now - start_time) * 1000).round} ms\n\n"
|
|
15
|
-
# end
|
|
16
|
-
rescue StandardError => e
|
|
17
|
-
raise e if config.test?
|
|
18
|
-
|
|
19
|
-
logger.error e
|
|
20
|
-
logger.info "\n"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module Rad
|
|
2
|
-
class Workspace < OpenObject
|
|
3
|
-
def params
|
|
4
|
-
self[:params] || Params.new
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def params?
|
|
8
|
-
!!params
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
alias_method :set_without_params, :[]=
|
|
12
|
-
def []= k, v
|
|
13
|
-
if k.to_s == 'params'
|
|
14
|
-
self.params = v
|
|
15
|
-
else
|
|
16
|
-
set_without_params k, v
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def params= v
|
|
21
|
-
if v.is_a? Params
|
|
22
|
-
set_without_params :params, v
|
|
23
|
-
else
|
|
24
|
-
set_without_params :params, Params.new(v)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def inspect
|
|
29
|
-
h = {}
|
|
30
|
-
each{|k, v| h[k] = v}
|
|
31
|
-
h['env'] = "..." if h.include? 'env'
|
|
32
|
-
h['request'] = "..." if h.include? 'request'
|
|
33
|
-
h.inspect
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
data/lib/rad/conveyor.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Conveyor is the heart of Rad, it allows for Processors to process request and build responce.
|
|
2
|
-
|
|
3
|
-
require 'rad/environment'
|
|
4
|
-
|
|
5
|
-
[
|
|
6
|
-
# 'config',
|
|
7
|
-
'params',
|
|
8
|
-
'workspace',
|
|
9
|
-
'processor',
|
|
10
|
-
'conveyor',
|
|
11
|
-
'conveyors',
|
|
12
|
-
'processors/conveyor_logger',
|
|
13
|
-
].each{|f| require "rad/conveyor/#{f}"}
|
|
14
|
-
|
|
15
|
-
Rad.metaclass_eval do
|
|
16
|
-
inject conveyors: :conveyors
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
# Initializations
|
|
21
|
-
#
|
|
22
|
-
rad do
|
|
23
|
-
register :workspace, scope: :cycle, depends_on: :environment
|
|
24
|
-
register :conveyors, depends_on: :environment do
|
|
25
|
-
Rad::Conveyors.new
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
Rad::Config::DEFAULTS[:show_exceptions] = false
|