rad_core 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- 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,12 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
next_processor.call
|
9
|
-
end
|
1
|
+
rad.controller
|
2
|
+
|
3
|
+
class ControllerLogger < Rad::Conveyors::Processor
|
4
|
+
def call
|
5
|
+
if (klass = workspace.class) and (method = workspace.method_name)
|
6
|
+
logger.info "RAD processing #{klass.name}.#{method} with #{workspace.params.inspect}"
|
10
7
|
end
|
8
|
+
next_processor.call
|
11
9
|
end
|
12
10
|
end
|
data/lib/rad/controller.rb
CHANGED
@@ -1,28 +1 @@
|
|
1
|
-
|
2
|
-
require 'rad/template'
|
3
|
-
|
4
|
-
%w(
|
5
|
-
abstract_controller/render
|
6
|
-
abstract_controller/responder
|
7
|
-
abstract_controller/micelaneous
|
8
|
-
abstract_controller
|
9
|
-
controller_context
|
10
|
-
|
11
|
-
processors/controller_logger
|
12
|
-
processors/controller_caller
|
13
|
-
processors/controller_error_handling
|
14
|
-
).each{|f| require "rad/controller/#{f}"}
|
15
|
-
|
16
|
-
module Rad
|
17
|
-
autoload :HttpController, 'rad/controller/http_controller'
|
18
|
-
end
|
19
|
-
|
20
|
-
#
|
21
|
-
# Initialization
|
22
|
-
#
|
23
|
-
Rad::Config::DEFAULTS.merge!(
|
24
|
-
development_error_template: "/rad_default_templates/development/error",
|
25
|
-
production_error_template: nil,
|
26
|
-
test_error_template: "/rad_default_templates/development/error",
|
27
|
-
)
|
28
|
-
Rad::Config::DEFAULTS[:default_method] ||= 'call'
|
1
|
+
rad.controller
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class Rad::Conveyors::Conveyor
|
2
|
+
inject workspace: :workspace
|
3
|
+
|
4
|
+
def definitions
|
5
|
+
@definitions ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def use processor_class, *initialization_arguments
|
9
|
+
definitions << [processor_class, initialization_arguments]
|
10
|
+
end
|
11
|
+
|
12
|
+
def build!
|
13
|
+
@chain = lambda{}
|
14
|
+
definitions.reverse.collect do |klass, args|
|
15
|
+
klass.must_be.a Class
|
16
|
+
@chain = klass.new @chain, *args
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def call workspace_content = {}, &block
|
21
|
+
build! unless @chain
|
22
|
+
|
23
|
+
scope = (rad.custom_scopes[:cycle] || {}).clone
|
24
|
+
rad.activate :cycle, scope do
|
25
|
+
self.workspace = ::Rad::Conveyors::Workspace.new unless self.workspace?
|
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
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Rad::Conveyors
|
2
|
+
def initialize
|
3
|
+
@hash = {}
|
4
|
+
end
|
5
|
+
|
6
|
+
def [] conveyor_name
|
7
|
+
@hash[conveyor_name.to_s] ||= Conveyor.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def size; @hash.size 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
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Rad::Conveyors::Workspace < OpenObject
|
2
|
+
def params
|
3
|
+
self[:params] || ::Rad::Conveyors::Params.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def params?
|
7
|
+
!!params
|
8
|
+
end
|
9
|
+
|
10
|
+
alias_method :set_without_params, :[]=
|
11
|
+
def []= k, v
|
12
|
+
if k.to_s == 'params'
|
13
|
+
self.params = v
|
14
|
+
else
|
15
|
+
set_without_params k, v
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def params= v
|
20
|
+
if v.is_a? ::Rad::Conveyors::Params
|
21
|
+
set_without_params :params, v
|
22
|
+
else
|
23
|
+
set_without_params :params, ::Rad::Conveyors::Params.new(v)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def inspect
|
28
|
+
h = {}
|
29
|
+
each{|k, v| h[k] = v}
|
30
|
+
h['env'] = "..." if h.include? 'env'
|
31
|
+
h['request'] = "..." if h.include? 'request'
|
32
|
+
h.inspect
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
rad.conveyors
|
@@ -0,0 +1 @@
|
|
1
|
+
rad.conveyors
|
@@ -0,0 +1,23 @@
|
|
1
|
+
rad.conveyors
|
2
|
+
|
3
|
+
class ConveyorLogger < Rad::Conveyors::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 "RAD completed in #{((Time.now - start_time) * 1000).round} ms\n"
|
15
|
+
# end
|
16
|
+
rescue StandardError => e
|
17
|
+
raise e if rad.test?
|
18
|
+
|
19
|
+
logger.error e
|
20
|
+
logger.info "\n"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
rad.conveyors
|
@@ -0,0 +1 @@
|
|
1
|
+
rad.conveyors
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rad::ControllerMicelaneousHelper
|
2
|
+
def reload_page
|
3
|
+
params = workspace.params
|
4
|
+
params.format.must_be.in 'html', 'js'
|
5
|
+
|
6
|
+
keep_flash!
|
7
|
+
if params.format == 'js'
|
8
|
+
workspace.response.set!(
|
9
|
+
status: :ok,
|
10
|
+
content_type: Mime[params.format]
|
11
|
+
)
|
12
|
+
throw :halt, "window.location.reload();"
|
13
|
+
else
|
14
|
+
redirect_to workspace.request.env["HTTP_REFERER"]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
%w(
|
2
|
+
_controller_micelaneous_helper
|
3
|
+
|
4
|
+
_router/abstract_routing_helper
|
5
|
+
_router/view_routing_helper
|
6
|
+
_router/controller_routing_helper
|
7
|
+
).each{|f| require "rad/core_web/#{f}"}
|
8
|
+
|
9
|
+
|
10
|
+
# View helpers
|
11
|
+
[
|
12
|
+
Rad::Html::HtmlHelper,
|
13
|
+
Rad::Router::CoreRoutingHelper, Rad::ViewRoutingHelper
|
14
|
+
].each do |helper|
|
15
|
+
Rad::Template::Context.inherit helper
|
16
|
+
end
|
17
|
+
|
18
|
+
# Controller helpers
|
19
|
+
[
|
20
|
+
Rad::Html::FlashHelper,
|
21
|
+
Rad::Router::CoreRoutingHelper, Rad::ControllerRoutingHelper,
|
22
|
+
Rad::ControllerMicelaneousHelper
|
23
|
+
].each do |helper|
|
24
|
+
Rad::Controller::Abstract.inherit helper
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rad::AbstractRoutingHelper
|
2
|
+
protected
|
3
|
+
def special_url key
|
4
|
+
return nil unless (key.is_a?(Symbol) or key.is_a?(String))
|
5
|
+
|
6
|
+
if key == :back
|
7
|
+
workspace.request.env["HTTP_REFERER"] || 'javascript:history.back()'
|
8
|
+
elsif key == '#'
|
9
|
+
'#'
|
10
|
+
# elsif key =~ /^http:\/\// # /^[\/0-9_a-z]+$/i
|
11
|
+
# key
|
12
|
+
else
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def keep_flash!
|
18
|
+
rad[:flash].keep! if rad.include? :flash
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Rad::ControllerRoutingHelper
|
2
|
+
inherit Rad::AbstractRoutingHelper
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
#
|
7
|
+
# persist_params controller filters
|
8
|
+
#
|
9
|
+
def persist_params *args
|
10
|
+
if args.empty?
|
11
|
+
before :persist_params
|
12
|
+
elsif args.first.is_a? Hash
|
13
|
+
before :persist_params, args.first
|
14
|
+
else
|
15
|
+
before :persist_params, only: args.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# redirect_to
|
22
|
+
#
|
23
|
+
def redirect_to *args
|
24
|
+
params, response = workspace.params, workspace.response
|
25
|
+
params.format.must_be.in 'html', 'js'
|
26
|
+
|
27
|
+
if url = special_url(args.first)
|
28
|
+
args.size.must_be <= 1
|
29
|
+
else
|
30
|
+
url = url_for(*args)
|
31
|
+
end
|
32
|
+
content_type = Mime[params.format]
|
33
|
+
|
34
|
+
content = if params.format == 'js'
|
35
|
+
response.set!(
|
36
|
+
status: :ok,
|
37
|
+
content_type: content_type
|
38
|
+
)
|
39
|
+
|
40
|
+
"window.location = '#{url}';"
|
41
|
+
else
|
42
|
+
response.set!(
|
43
|
+
status: :redirect,
|
44
|
+
content_type: content_type
|
45
|
+
)
|
46
|
+
response.headers['Location'] = url
|
47
|
+
|
48
|
+
%(<html><body>You are being <a href="#{url.html_escape if url}">redirected</a>.</body></html>)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Flash need to know if we using redirect
|
52
|
+
keep_flash!
|
53
|
+
|
54
|
+
throw :halt, content
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Rad::ViewRoutingHelper
|
2
|
+
inherit Rad::AbstractRoutingHelper
|
3
|
+
|
4
|
+
def link_to *args, &block
|
5
|
+
# content
|
6
|
+
content = if block
|
7
|
+
capture(&block)
|
8
|
+
else
|
9
|
+
args.shift
|
10
|
+
end
|
11
|
+
|
12
|
+
# url, html_options
|
13
|
+
if args.first.is_a? String
|
14
|
+
args.size.must_be.in 1..2
|
15
|
+
url, html_options = args
|
16
|
+
html_options ||= {}
|
17
|
+
else
|
18
|
+
if url = special_url(args.first)
|
19
|
+
args.size.must_be <= 2
|
20
|
+
html_options = args[1] || {}
|
21
|
+
else
|
22
|
+
html_options = if args[-1].is_a?(Hash) and args[-2].is_a?(Hash)
|
23
|
+
args.pop
|
24
|
+
else
|
25
|
+
{}
|
26
|
+
end
|
27
|
+
|
28
|
+
args << {} unless args[-1].is_a?(Hash)
|
29
|
+
url = url_for(*args)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# add javascript
|
34
|
+
html_options[:href] = url
|
35
|
+
add_js_link_options! url, html_options
|
36
|
+
tag :a, content, html_options
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
def add_js_link_options! url, html_options
|
41
|
+
remote = html_options.delete(:remote) || rad.html.remote_link_formats.include?(url.marks.format)
|
42
|
+
method = html_options.delete(:method)
|
43
|
+
|
44
|
+
if remote or method
|
45
|
+
action = html_options.delete(:href).must_be.defined
|
46
|
+
html_options[:href] = '#'
|
47
|
+
|
48
|
+
html_options['data-action'] = action
|
49
|
+
html_options['data-remote'] = 'true' if remote
|
50
|
+
html_options['data-method'] = method || 'post'
|
51
|
+
end
|
52
|
+
|
53
|
+
if confirm = html_options.delete(:confirm)
|
54
|
+
html_options['data-confirm'] = confirm
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Rad::Config
|
2
|
+
def subset; raise "you probably mistuped, it's config, not hash" end
|
3
|
+
|
4
|
+
def initialize hash = {}
|
5
|
+
hash.each do |k, v|
|
6
|
+
instance_variable_set :"@#{k}", v
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def deep_clone
|
11
|
+
clone = Rad::Config.new
|
12
|
+
instance_variable_names.each do |k|
|
13
|
+
clone.instance_variable_set k, instance_variable_get(k).deep_clone
|
14
|
+
end
|
15
|
+
clone
|
16
|
+
end
|
17
|
+
alias_method :clone, :deep_clone
|
18
|
+
|
19
|
+
protected
|
20
|
+
def method_missing m, *args
|
21
|
+
if m =~ /=$/
|
22
|
+
instance_variable_set :"@#{m[0..-2]}", args.first
|
23
|
+
else
|
24
|
+
instance_variable_get :"@#{m}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# Environment
|
3
|
+
#
|
4
|
+
class Rad::Environment
|
5
|
+
inherit Rad::Environment::FilesHelper
|
6
|
+
|
7
|
+
inject logger: :logger
|
8
|
+
|
9
|
+
attr_writer :available_languages
|
10
|
+
def available_languages; @available_languages ||= [] end
|
11
|
+
|
12
|
+
attr_accessor :language
|
13
|
+
|
14
|
+
class << self
|
15
|
+
inject logger: :logger
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Rad::Environment::FilesHelper
|
2
|
+
def directories
|
3
|
+
$LOAD_PATH
|
4
|
+
end
|
5
|
+
|
6
|
+
def file_exist? path, directories = nil
|
7
|
+
find_files(path, directories).size > 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_files fname, directories = nil
|
11
|
+
directories ||= self.directories
|
12
|
+
Rad::Environment::FilesHelper.find_files fname, directories
|
13
|
+
end
|
14
|
+
|
15
|
+
def find_files_without_cache fname, directories = nil
|
16
|
+
# directories ||= self.directories
|
17
|
+
Rad::Environment::FilesHelper.find_files_without_cache fname, directories
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_file fname, directories = nil
|
21
|
+
files = find_files(fname, directories)
|
22
|
+
raise "Found multiple files for '#{fname}'" if files.size > 1
|
23
|
+
files.first
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_file! fname, directories = nil
|
27
|
+
find_file(fname, directories) || raise("File '#{fname}' not found!")
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_files_by_pattern_without_cache pattern, directories = nil
|
31
|
+
directories ||= self.directories
|
32
|
+
patterns = directories.to_a.collect{|d| "#{d}#{pattern}"}
|
33
|
+
Dir.glob patterns
|
34
|
+
end
|
35
|
+
alias_method :find_files_by_pattern, :find_files_by_pattern_without_cache
|
36
|
+
|
37
|
+
def find_file_by_pattern pattern
|
38
|
+
files = find_files_by_pattern(pattern)
|
39
|
+
raise "File '#{pattern}' not found!" if files.size == 0
|
40
|
+
raise "Found multiple files for '#{pattern}'" if files.size > 1
|
41
|
+
files.first
|
42
|
+
end
|
43
|
+
|
44
|
+
class << self
|
45
|
+
# don't move this class method to module, because there will be then
|
46
|
+
# multiple cache for every object that includes it.
|
47
|
+
def find_files fname, directories
|
48
|
+
fname.must =~ /\//
|
49
|
+
directories.must_be.present # || raise('directories ')= self.directories
|
50
|
+
files = directories.collect{|dir| "#{dir}#{fname}"}
|
51
|
+
files.select{|f| File.exist? f}
|
52
|
+
end
|
53
|
+
cache_method_with_params_in_production :find_files
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Rad::Logger
|
2
|
+
def initialize stream
|
3
|
+
@stream = stream
|
4
|
+
end
|
5
|
+
|
6
|
+
def silence &b
|
7
|
+
begin
|
8
|
+
@silence = true
|
9
|
+
b.call
|
10
|
+
ensure
|
11
|
+
@silence = false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def info obj
|
16
|
+
!@silence && stream && stream.write(indent(obj_to_string(obj)) + "\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def warn obj
|
20
|
+
!@silence && stream && stream.write(indent("WARN: " + obj_to_string(obj)) + "\n")
|
21
|
+
end
|
22
|
+
|
23
|
+
def error obj
|
24
|
+
!@silence && stream && stream.write(indent("ERROR: " + obj_to_string(obj)) + "\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
def debug obj
|
28
|
+
if !@silence && stream
|
29
|
+
# cutting annoying BSON::ObjectId('4dec6a8d360501476d000004') stuff
|
30
|
+
stream.write(indent(obj_to_string(obj).gsub(/BSON::ObjectId\(([a-z0-9'"]+)\)/, "\\1")) + "\n")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
IDENTATION = " "
|
36
|
+
attr_reader :stream
|
37
|
+
|
38
|
+
def indent string
|
39
|
+
IDENTATION + string.gsub("\n", "\n" + IDENTATION)
|
40
|
+
end
|
41
|
+
|
42
|
+
def obj_to_string obj
|
43
|
+
if obj.is_a? Exception
|
44
|
+
backtrace = (obj.backtrace && obj.backtrace.sfilter(Exception.filters)) || []
|
45
|
+
%{\
|
46
|
+
#{obj.message}
|
47
|
+
#{backtrace.join("\n ")}
|
48
|
+
}
|
49
|
+
else
|
50
|
+
obj.to_s
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Rad::Environment
|
2
|
+
end
|
3
|
+
|
4
|
+
%w(
|
5
|
+
_config
|
6
|
+
_logger
|
7
|
+
_files_helper
|
8
|
+
_environment
|
9
|
+
).each{|f| require "rad/environment/#{f}"}
|
10
|
+
|
11
|
+
|
12
|
+
#
|
13
|
+
# Handy mehtods
|
14
|
+
#
|
15
|
+
class Micon::Core
|
16
|
+
|
17
|
+
def development?; mode == :development end
|
18
|
+
def production?; mode == :production end
|
19
|
+
def test?; mode == :test end
|
20
|
+
|
21
|
+
def development █ block.call if development? end
|
22
|
+
def production █ block.call if production? end
|
23
|
+
def test █ block.call if test? end
|
24
|
+
end
|