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
data/lib/rad/spec/view.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# In development mode log also to STDOUT
|
3
|
-
#
|
4
|
-
ActiveSupport::BufferedLogger.class_eval do
|
5
|
-
|
6
|
-
def flush_with_stdout
|
7
|
-
STDOUT.write(buffer.join) unless buffer.empty?
|
8
|
-
flush_without_stdout
|
9
|
-
end
|
10
|
-
rad.after :config do
|
11
|
-
if rad.include?(:config) and (rad.config.development? or rad.config.stdout_logger(false))
|
12
|
-
alias_method_chain :flush, :stdout
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
def info_with_format obj
|
18
|
-
info_without_format(obj_to_string(obj))
|
19
|
-
end
|
20
|
-
alias_method_chain :info, :format
|
21
|
-
|
22
|
-
def warn_with_format obj
|
23
|
-
warn_without_format("WARN: " + obj_to_string(obj))
|
24
|
-
end
|
25
|
-
alias_method_chain :warn, :format
|
26
|
-
|
27
|
-
def error_with_format obj
|
28
|
-
error_without_format("ERROR: " + obj_to_string(obj))
|
29
|
-
end
|
30
|
-
alias_method_chain :error, :format
|
31
|
-
|
32
|
-
protected
|
33
|
-
def obj_to_string obj
|
34
|
-
if obj.is_a? Exception
|
35
|
-
backtrace = (obj.backtrace && obj.backtrace.sfilter(Exception.common_filters)) || []
|
36
|
-
%{\
|
37
|
-
#{obj.message}
|
38
|
-
#{backtrace.join("\n ")}
|
39
|
-
}
|
40
|
-
else
|
41
|
-
obj.to_s
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module Callbacks
|
3
|
-
class AbstractCallback
|
4
|
-
attr_accessor :executor, :terminator
|
5
|
-
attr_reader :conditions
|
6
|
-
def conditions= conditions
|
7
|
-
@conditions = {}
|
8
|
-
conditions.each do |k, v|
|
9
|
-
@conditions[k.to_sym] = if v.is_a? Symbol
|
10
|
-
v.to_s
|
11
|
-
elsif v.is_a? Array
|
12
|
-
v.collect{|e| e.to_s}
|
13
|
-
else
|
14
|
-
v
|
15
|
-
end
|
16
|
-
end
|
17
|
-
@conditions
|
18
|
-
end
|
19
|
-
|
20
|
-
def terminate? target, result
|
21
|
-
unless terminator.nil?
|
22
|
-
if terminator.is_a? Proc
|
23
|
-
terminator.call target, result
|
24
|
-
else
|
25
|
-
result == terminator
|
26
|
-
end
|
27
|
-
else
|
28
|
-
false
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def run? target, inf
|
33
|
-
if cond = conditions[:if]
|
34
|
-
evaluate_if(cond, target, inf)
|
35
|
-
elsif cond = conditions[:unless]
|
36
|
-
!evaluate_if(cond, target, inf)
|
37
|
-
elsif cond = conditions[:only]
|
38
|
-
evaluate_only(cond, inf)
|
39
|
-
elsif cond = conditions[:except]
|
40
|
-
!evaluate_only(cond, inf)
|
41
|
-
else
|
42
|
-
true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def add_to_chain target, inf, &the_next
|
47
|
-
if run? target, inf
|
48
|
-
build_block target, &the_next
|
49
|
-
else
|
50
|
-
the_next
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
alias_method :deep_clone, :clone
|
55
|
-
|
56
|
-
protected
|
57
|
-
def evaluate_if cond, target, inf
|
58
|
-
if cond.is_a? String
|
59
|
-
target.send cond
|
60
|
-
elsif cond.is_a? Proc
|
61
|
-
cond.call target, inf
|
62
|
-
else
|
63
|
-
must_be.never_called
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def evaluate_only cond, inf
|
68
|
-
method = inf[:method].to_s
|
69
|
-
if cond.is_a? String
|
70
|
-
cond == method
|
71
|
-
elsif cond.is_a? Array
|
72
|
-
cond.include? method
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class BeforeCallback < AbstractCallback
|
78
|
-
def build_block target, &the_next
|
79
|
-
lambda do
|
80
|
-
result = if executor.string_or_symbol?
|
81
|
-
target.send executor
|
82
|
-
elsif executor.is_a? Proc
|
83
|
-
executor.call target
|
84
|
-
else
|
85
|
-
must_be.never_called
|
86
|
-
end
|
87
|
-
|
88
|
-
the_next.call unless terminate? target, result
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
class AroundCallback < AbstractCallback
|
94
|
-
def build_block target, &the_next
|
95
|
-
lambda do
|
96
|
-
if executor.string_or_symbol?
|
97
|
-
target.send executor, &the_next
|
98
|
-
elsif executor.is_a? Proc
|
99
|
-
executor.call target, the_next
|
100
|
-
else
|
101
|
-
must_be.never_called
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
class AfterCallback < AbstractCallback
|
108
|
-
def build_block target, &the_next
|
109
|
-
lambda do
|
110
|
-
result = if executor.string_or_symbol?
|
111
|
-
target.send executor
|
112
|
-
elsif executor.is_a? Proc
|
113
|
-
executor.call target
|
114
|
-
else
|
115
|
-
must_be.never_called
|
116
|
-
end
|
117
|
-
|
118
|
-
the_next.call unless terminate? target, result
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def run_callbacks callback_name, additional_information = {}, &block
|
124
|
-
callback_name = callback_name.to_s
|
125
|
-
block.must_be.defined
|
126
|
-
|
127
|
-
callbacks = self.class.callbacks[callback_name]
|
128
|
-
chain_head = block
|
129
|
-
if callbacks and !callbacks.empty?
|
130
|
-
callbacks.reverse_each do |callback|
|
131
|
-
block = callback.add_to_chain self, additional_information, &chain_head
|
132
|
-
chain_head = block if block
|
133
|
-
end
|
134
|
-
end
|
135
|
-
chain_head.call
|
136
|
-
end
|
137
|
-
|
138
|
-
module ClassMethods
|
139
|
-
inheritable_accessor :callbacks, {}
|
140
|
-
|
141
|
-
def set_callback callback_name, type, *executor_or_options, &block
|
142
|
-
# parsing arguments
|
143
|
-
type, callback_name = type.to_s, callback_name.to_s
|
144
|
-
opt = executor_or_options.extract_options!
|
145
|
-
"You can't provide both method name and block for filter!" if block and !executor_or_options.empty?
|
146
|
-
executor = block || executor_or_options.first
|
147
|
-
|
148
|
-
type.must_be.in %w{before around after}
|
149
|
-
executor.must_be.defined
|
150
|
-
|
151
|
-
# creating callback
|
152
|
-
callback = case type
|
153
|
-
when 'before' then BeforeCallback.new
|
154
|
-
when 'around' then AroundCallback.new
|
155
|
-
when 'after' then AfterCallback.new
|
156
|
-
end
|
157
|
-
|
158
|
-
callback.executor = executor
|
159
|
-
callback.terminator = opt.delete :terminator
|
160
|
-
callback.conditions = opt
|
161
|
-
|
162
|
-
callbacks[callback_name] ||= []
|
163
|
-
callbacks[callback_name] << callback
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
class Exception
|
2
|
-
class << self
|
3
|
-
attr_accessor :common_filters
|
4
|
-
end
|
5
|
-
end
|
6
|
-
Exception.common_filters = [
|
7
|
-
"/gems/haml",
|
8
|
-
"/gems/tilt",
|
9
|
-
"/gems/facets",
|
10
|
-
"/gems/rack",
|
11
|
-
"/gems/mongrel",
|
12
|
-
"/gems/rspec",
|
13
|
-
"/timeout.rb",
|
14
|
-
"/bin/spec",
|
15
|
-
|
16
|
-
"/rad/support/callbacks",
|
17
|
-
"/rad/template/template",
|
18
|
-
"/rad/template/support/tilt",
|
19
|
-
|
20
|
-
"/abstract_inteface/lib/abstract_interface/view_builder",
|
21
|
-
"/common_interface/lib/common_interface/view_helper",
|
22
|
-
|
23
|
-
# "/rad/template",
|
24
|
-
# "/rad/support",
|
25
|
-
|
26
|
-
"/monitor",
|
27
|
-
"/synchronize",
|
28
|
-
"/class_loader",
|
29
|
-
"/micon"
|
30
|
-
]
|
31
|
-
# Exception.common_filters = []
|
data/lib/rad/support/filters.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module Filters
|
3
|
-
inherit Callbacks
|
4
|
-
|
5
|
-
module ClassMethods
|
6
|
-
def before *args, &block
|
7
|
-
opt = args.extract_options!
|
8
|
-
if block
|
9
|
-
set_callback :action, :before, opt, &block
|
10
|
-
else
|
11
|
-
args.each{|executor| set_callback :action, :before, executor, opt}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def around *args, &block
|
16
|
-
opt = args.extract_options!
|
17
|
-
if block
|
18
|
-
set_callback :action, :around, opt, &block
|
19
|
-
else
|
20
|
-
args.each{|executor| set_callback :action, :around, executor, opt}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def after *args, &block
|
25
|
-
opt = args.extract_options!
|
26
|
-
if block
|
27
|
-
set_callback :action, :after, opt, &block
|
28
|
-
else
|
29
|
-
args.each{|executor| set_callback :action, :after, executor, opt}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/rad/support/format.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# module Rad
|
2
|
-
# class Format < String
|
3
|
-
# def == other
|
4
|
-
# self.to_sym == other
|
5
|
-
# end
|
6
|
-
#
|
7
|
-
# def method_missing m
|
8
|
-
# m = m.to_s
|
9
|
-
# super unless m[-1..-1] == '?'
|
10
|
-
# self == m[0..-2].to_sym
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# def inspect
|
14
|
-
# self.to_sym.inspect
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
# end
|
data/lib/rad/support/micon.rb
DELETED
data/lib/rad/support.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# ruby
|
3
|
-
#
|
4
|
-
raise 'ruby 1.9.2 or higher required!' unless RUBY_VERSION >= '1.9.2'
|
5
|
-
|
6
|
-
Encoding.default_external = Encoding::UTF_8
|
7
|
-
Encoding.default_internal = Encoding::UTF_8
|
8
|
-
warn " default source encoding is not UTF-8, something wroing is going on!" if __ENCODING__ != Encoding::UTF_8
|
9
|
-
|
10
|
-
# def ensure_utf8! string
|
11
|
-
# raise "invalid encoding (#{string})!" unless string.encoding == Encoding::UTF_8
|
12
|
-
# end
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
# gems
|
17
|
-
#
|
18
|
-
require 'rad_core/gems'
|
19
|
-
|
20
|
-
require 'rad/support/active_support'
|
21
|
-
|
22
|
-
require 'ruby_ext'
|
23
|
-
|
24
|
-
require 'vfs'
|
25
|
-
|
26
|
-
require 'ruby_ext/more/open_constructor'
|
27
|
-
require 'rad/support/ruby_ext_with_active_support'
|
28
|
-
|
29
|
-
require 'class_loader'
|
30
|
-
|
31
|
-
require 'micon'
|
32
|
-
require 'rad/support/micon'
|
33
|
-
|
34
|
-
require 'dictionary'
|
35
|
-
|
36
|
-
require 'thread'
|
37
|
-
require 'time'
|
38
|
-
require 'uri'
|
39
|
-
require 'json'
|
40
|
-
|
41
|
-
|
42
|
-
require 'addressable/uri'
|
43
|
-
require 'rad/support/addressable'
|
44
|
-
::Uri = Addressable::URI
|
45
|
-
|
46
|
-
#
|
47
|
-
# support
|
48
|
-
#
|
49
|
-
require 'rad/support/hacks_and_fixes'
|
50
|
-
|
51
|
-
|
52
|
-
autoload :Nokogiri, 'nokogiri'
|
53
|
-
|
54
|
-
[
|
55
|
-
'module',
|
56
|
-
'buffered_logger',
|
57
|
-
'callbacks',
|
58
|
-
'filters',
|
59
|
-
'mime',
|
60
|
-
'string',
|
61
|
-
'rson',
|
62
|
-
'exception',
|
63
|
-
].each{|f| require "rad/support/#{f}"}
|
@@ -1,250 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module Template
|
3
|
-
# DIRECTORY_NAME = "/views"
|
4
|
-
DIRECTORY_NAME = ""
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def paths; @paths ||= [] end
|
8
|
-
|
9
|
-
inject(
|
10
|
-
logger: :logger,
|
11
|
-
config: :config,
|
12
|
-
environment: :environment
|
13
|
-
)
|
14
|
-
|
15
|
-
def render *args, &block
|
16
|
-
result, context = basic_render(parse_arguments(*args), &block)
|
17
|
-
result
|
18
|
-
end
|
19
|
-
|
20
|
-
# def render_and_return_context *args, &block
|
21
|
-
# basic_render(*parse_arguments(*args), &block)
|
22
|
-
# end
|
23
|
-
|
24
|
-
def render_layout *args
|
25
|
-
options = parse_arguments(*args)
|
26
|
-
options.must.include :content
|
27
|
-
options.must.include :context
|
28
|
-
|
29
|
-
result, context = basic_render options do |*args|
|
30
|
-
if args.empty?
|
31
|
-
options.content
|
32
|
-
else
|
33
|
-
args.size.must_be == 1
|
34
|
-
variable_name = args.first.to_s
|
35
|
-
self.context.content_variables[variable_name]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
result
|
40
|
-
end
|
41
|
-
|
42
|
-
def exist? tname, options = {}
|
43
|
-
options = options.to_openobject
|
44
|
-
!!find_template(tname, calculate_prefixes(options), options.format, exact_format?(options), options.current_dir)
|
45
|
-
end
|
46
|
-
|
47
|
-
def read tname, options = {}
|
48
|
-
options = options.to_openobject
|
49
|
-
file = find_template tname, calculate_prefixes(options), options.format, exact_format?(options), options.current_dir
|
50
|
-
raise "No template '#{tname}'!" unless file
|
51
|
-
File.read file
|
52
|
-
end
|
53
|
-
|
54
|
-
def template_name_with_prefix tname, prefix
|
55
|
-
index = tname.rindex('/')
|
56
|
-
index = index ? index + 1 : 0
|
57
|
-
tname = tname.clone
|
58
|
-
tname.insert index, prefix
|
59
|
-
end
|
60
|
-
|
61
|
-
def parse_arguments *args
|
62
|
-
options = args.extract_options!.to_openobject
|
63
|
-
if args.size == 1
|
64
|
-
options.template = args.first
|
65
|
-
else
|
66
|
-
raise "Invalid input" if args.size != 0
|
67
|
-
end
|
68
|
-
|
69
|
-
options
|
70
|
-
end
|
71
|
-
|
72
|
-
def basic_render options, &block
|
73
|
-
options = options.clone.to_openobject
|
74
|
-
|
75
|
-
with_context options do |context|
|
76
|
-
context.content_block ||= block
|
77
|
-
|
78
|
-
with_scope options, context do |scope|
|
79
|
-
unless file = options.file
|
80
|
-
file = find_template options.template!, calculate_prefixes(options), scope.format, exact_format?(options), scope.current_dir
|
81
|
-
raise "No template '#{options.template!}'!" unless file
|
82
|
-
end
|
83
|
-
|
84
|
-
scope.current_dir = dirname(file)
|
85
|
-
|
86
|
-
template = create_tilt_template file
|
87
|
-
|
88
|
-
result = with_template context, template do
|
89
|
-
render_template template, options, &context.content_block
|
90
|
-
end
|
91
|
-
|
92
|
-
return result, context
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
protected
|
98
|
-
def context
|
99
|
-
Thread.current[:render_context]
|
100
|
-
end
|
101
|
-
|
102
|
-
def calculate_prefixes options
|
103
|
-
options.action ? [''] : options.prefixes
|
104
|
-
end
|
105
|
-
|
106
|
-
def exact_format? options
|
107
|
-
options.action? || options.exact_format?
|
108
|
-
end
|
109
|
-
|
110
|
-
def with_context options, &block
|
111
|
-
context = Thread.current[:render_context] || options.context || create_context(options)
|
112
|
-
|
113
|
-
old = Thread.current[:render_context]
|
114
|
-
begin
|
115
|
-
Thread.current[:render_context] = context
|
116
|
-
block.call context
|
117
|
-
ensure
|
118
|
-
Thread.current[:render_context] = old
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def with_scope options, context, &block
|
123
|
-
initial = context.scope_variables
|
124
|
-
|
125
|
-
old = context.scope_variables || OpenObject.new
|
126
|
-
begin
|
127
|
-
context.scope_variables = {
|
128
|
-
current_dir: (options.current_dir || old.current_dir),
|
129
|
-
format: (options.format || old.format)
|
130
|
-
# prefixes: options.prefixes || old.prefixes
|
131
|
-
}.to_openobject
|
132
|
-
|
133
|
-
block.call context.scope_variables
|
134
|
-
ensure
|
135
|
-
context.scope_variables = old if initial
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def with_template context, template, &block
|
140
|
-
old = context._tilt_template
|
141
|
-
begin
|
142
|
-
context._tilt_template = template
|
143
|
-
block.call context
|
144
|
-
ensure
|
145
|
-
context._tilt_template = old
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def create_context options
|
150
|
-
context_class = options.context_class || TemplateContext
|
151
|
-
raise "#{context_class} must inherit from TemplateContext!" unless context_class.is? TemplateContext
|
152
|
-
context = context_class.new
|
153
|
-
|
154
|
-
context.options = options
|
155
|
-
|
156
|
-
if ivs = options.instance_variables
|
157
|
-
(ivs.is_a?(Array) ? ivs : [ivs]).each do |container|
|
158
|
-
if container.is_a? Hash
|
159
|
-
container.each do |name, value|
|
160
|
-
context.instance_variable_set("@#{name}", value)
|
161
|
-
end
|
162
|
-
else
|
163
|
-
container.instance_variables.each do |ivname|
|
164
|
-
iv = container.instance_variable_get(ivname)
|
165
|
-
context.instance_variable_set(ivname, iv)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context
|
172
|
-
end
|
173
|
-
|
174
|
-
def dirname path;
|
175
|
-
File.dirname path
|
176
|
-
end
|
177
|
-
cache_method_with_params_in_production :dirname
|
178
|
-
|
179
|
-
def find_template tname, prefixes, format, exact_format, current_dir
|
180
|
-
tname.must_be.a String
|
181
|
-
# splitted into two to optimize cache
|
182
|
-
if tname =~ /^\//
|
183
|
-
find_absolute_template tname, prefixes, format, exact_format
|
184
|
-
else
|
185
|
-
find_relative_template tname, prefixes, format, exact_format, current_dir
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def find_absolute_template tname, prefixes, format, exact_format
|
190
|
-
prefixes = prefixes || config.default_template_prefixes!
|
191
|
-
prefixes.each do |prefix|
|
192
|
-
tname_with_prefix = template_name_with_prefix("#{DIRECTORY_NAME}#{tname}", prefix)
|
193
|
-
file = find_file(tname_with_prefix, format, exact_format, paths) #environment.directories)
|
194
|
-
return file if file
|
195
|
-
end
|
196
|
-
return nil
|
197
|
-
end
|
198
|
-
cache_method_with_params_in_production :find_absolute_template
|
199
|
-
|
200
|
-
def find_relative_template tname, prefixes, format, exact_format, current_dir
|
201
|
-
raise "You can't use relative template path '#{tname}' without :current_dir!" unless current_dir
|
202
|
-
prefixes = prefixes || config.default_template_prefixes!
|
203
|
-
prefixes.each do |prefix|
|
204
|
-
tname_with_prefix = template_name_with_prefix("/#{tname}", prefix)
|
205
|
-
file = find_file(tname_with_prefix, format, exact_format, [current_dir])
|
206
|
-
return file if file
|
207
|
-
end
|
208
|
-
return nil
|
209
|
-
end
|
210
|
-
cache_method_with_params_in_production :find_relative_template
|
211
|
-
|
212
|
-
def find_file tname, format, exact_format, directories
|
213
|
-
if tname.include? '.'
|
214
|
-
_find_file(tname, directories) || _find_file("#{tname}.*", directories)
|
215
|
-
else
|
216
|
-
if format
|
217
|
-
_find_file("#{tname}.#{format}.*", directories) or
|
218
|
-
_find_file("#{tname}.*", directories, exact_format)
|
219
|
-
else
|
220
|
-
_find_file("#{tname}.*", directories)
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
# with_one_extension - 'tname.*' matches not only 'tname.erb' but also 'tname.html.erb',
|
226
|
-
# with this option enabled it will not match 'tname.html.erb', only 'tname.erb'
|
227
|
-
def _find_file pattern, directories, with_one_extension = false
|
228
|
-
files = environment.find_files_by_pattern_without_cache pattern, directories
|
229
|
-
files = files.select{|f| f !~ /\.[^\.\/]+\.[^\.\/]+$/} if with_one_extension
|
230
|
-
raise "multiple templates for '#{pattern}'!" if files.size > 1
|
231
|
-
files.first
|
232
|
-
end
|
233
|
-
|
234
|
-
def create_tilt_template path
|
235
|
-
template_options = {
|
236
|
-
ugly: true,
|
237
|
-
outvar: "@output"
|
238
|
-
}
|
239
|
-
template = Tilt.new(path, nil, template_options){|t| File.read(t.file)}
|
240
|
-
end
|
241
|
-
|
242
|
-
def render_template template, options, &block
|
243
|
-
locals = options.locals || {}
|
244
|
-
locals[:object] = options.object if options.object?
|
245
|
-
|
246
|
-
template.render context, locals, &block
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
|
-
end
|