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,21 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
class StaticFiles
|
3
|
-
|
4
|
-
def initialize(app, dir, filter = nil)
|
5
|
-
@app = app
|
6
|
-
@dir = File.expand_path(dir)
|
7
|
-
@file_server = Rack::File.new(@dir)
|
8
|
-
@filter = filter
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
path = env["PATH_INFO"]
|
13
|
-
|
14
|
-
if (!@filter or (@filter and @filter =~ path)) and File.exist?("#{@dir}#{path}")
|
15
|
-
@file_server.call(env)
|
16
|
-
else
|
17
|
-
@app.call(env)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
class RackAdapter
|
3
|
-
SERVERS = %w{thin mongrel webrick}
|
4
|
-
|
5
|
-
# class Callback
|
6
|
-
# def initialize app; end
|
7
|
-
# def self.call env; Rad::Adapter.call env end
|
8
|
-
# end
|
9
|
-
|
10
|
-
class << self
|
11
|
-
inject(
|
12
|
-
logger: :logger,
|
13
|
-
config: :config
|
14
|
-
)
|
15
|
-
|
16
|
-
def initialize_rack builder = nil, &block
|
17
|
-
@rack_configurations ||= []
|
18
|
-
if block
|
19
|
-
raise "provide configuration block!" unless block
|
20
|
-
@rack_configurations << block
|
21
|
-
else
|
22
|
-
if @rack_configurations.empty?
|
23
|
-
raise "Common App not defined! Use profiles (like rad/profiles/web), define it by yourself or use your own configuration!"
|
24
|
-
end
|
25
|
-
@rack_configurations.each{|conf| conf.call builder}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def parse_config
|
30
|
-
app, options = Rack::Builder.parse_file 'config.ru'
|
31
|
-
app
|
32
|
-
end
|
33
|
-
|
34
|
-
def run app, host, port
|
35
|
-
handler = detect_rack_handler
|
36
|
-
handler_name = handler.name.gsub(/.*::/, '')
|
37
|
-
logger.info " HTTP server started on #{host}:#{port}" unless config.test?
|
38
|
-
# unless handler_name =~/cgi/i
|
39
|
-
handler.run app, Host: host, Port: port do |server|
|
40
|
-
[:INT, :TERM].each {|sig| trap(sig){quit!(server, handler_name)}}
|
41
|
-
end
|
42
|
-
rescue Errno::EADDRINUSE => e
|
43
|
-
logger.error "Port #{port} taken!"
|
44
|
-
end
|
45
|
-
|
46
|
-
def quit!(server, handler_name)
|
47
|
-
## Use thins' hard #stop! if available, otherwise just #stop
|
48
|
-
server.respond_to?(:stop!) ? server.stop! : server.stop
|
49
|
-
puts "\nRad stopped" unless handler_name =~/cgi/i
|
50
|
-
end
|
51
|
-
|
52
|
-
protected
|
53
|
-
def detect_rack_handler
|
54
|
-
return Rack::Handler.get('thin')
|
55
|
-
SERVERS.each do |server_name|
|
56
|
-
begin
|
57
|
-
return Rack::Handler.get(server_name.downcase)
|
58
|
-
rescue LoadError
|
59
|
-
rescue NameError
|
60
|
-
end
|
61
|
-
end
|
62
|
-
fail " Server handler (#{SERVERS.join(', ')}) not found."
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
class Request < Rack::Request
|
3
|
-
# Returns an array of acceptable media types for the response
|
4
|
-
# def accept
|
5
|
-
# @env['HTTP_ACCEPT'].to_s.split(',').map { |a| a.split(';')[0].strip }
|
6
|
-
# end
|
7
|
-
#
|
8
|
-
# def secure?
|
9
|
-
# (@env['HTTP_X_FORWARDED_PROTO'] || @env['rack.url_scheme']) == 'https'
|
10
|
-
# end
|
11
|
-
|
12
|
-
|
13
|
-
# Returns all the \subdomains as an array, so <tt>["dev", "www"]</tt> would be
|
14
|
-
# returned for "dev.www.rubyonrails.org". You can specify a different <tt>tld_length</tt>,
|
15
|
-
# such as 2 to catch <tt>["www"]</tt> instead of <tt>["www", "rubyonrails"]</tt>
|
16
|
-
# in "www.rubyonrails.co.uk".
|
17
|
-
def subdomains(tld_length = 1)
|
18
|
-
return [] unless named_host?(host)
|
19
|
-
parts = host.split('.')
|
20
|
-
parts[0..-(tld_length+2)]
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
# Returns the \domain part of a \host, such as "rubyonrails.org" in "www.rubyonrails.org". You can specify
|
25
|
-
# a different <tt>tld_length</tt>, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk".
|
26
|
-
def domain(tld_length = 1)
|
27
|
-
return nil unless named_host?(host)
|
28
|
-
|
29
|
-
host.split('.').last(1 + tld_length).join('.')
|
30
|
-
end
|
31
|
-
|
32
|
-
def cookies_with_memory
|
33
|
-
@cookies_with_memory ||= cookies_without_memory
|
34
|
-
end
|
35
|
-
alias_method_chain :cookies, :memory
|
36
|
-
|
37
|
-
protected
|
38
|
-
def named_host?(host)
|
39
|
-
!(host.nil? || /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host))
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
class Response < Rack::Response
|
3
|
-
include ::OpenConstructor
|
4
|
-
|
5
|
-
STATUS_MESSAGES = {
|
6
|
-
ok: 200,
|
7
|
-
not_found: 404,
|
8
|
-
failed: 500,
|
9
|
-
error: 500,
|
10
|
-
redirect: 301
|
11
|
-
}
|
12
|
-
|
13
|
-
def initialize *args
|
14
|
-
super
|
15
|
-
clear
|
16
|
-
end
|
17
|
-
|
18
|
-
def content_type= type; self["Content-Type"] = type end
|
19
|
-
def content_type; self["Content-Type"] end
|
20
|
-
def content_type?; !!content_type end
|
21
|
-
|
22
|
-
def location; self['Location'] end
|
23
|
-
def location= location; self['Location'] = location end
|
24
|
-
|
25
|
-
# def to_a
|
26
|
-
# [status, headers, body]
|
27
|
-
# end
|
28
|
-
|
29
|
-
def body_as_string
|
30
|
-
if @body.is_a? String
|
31
|
-
@body
|
32
|
-
else
|
33
|
-
@body ? @body.join : ""
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def inspect
|
38
|
-
to_a2.inspect
|
39
|
-
end
|
40
|
-
|
41
|
-
def == other
|
42
|
-
to_a2 == other
|
43
|
-
end
|
44
|
-
|
45
|
-
def cookies
|
46
|
-
self['Set-Cookie']
|
47
|
-
end
|
48
|
-
|
49
|
-
def clear
|
50
|
-
@status = 200
|
51
|
-
@header = Rack::Utils::HeaderHash.new("Content-Type" => nil)
|
52
|
-
@length = 0
|
53
|
-
@body = []
|
54
|
-
end
|
55
|
-
|
56
|
-
def status= code_or_message
|
57
|
-
@status = if code_or_message.is_a? Numeric
|
58
|
-
code_or_message
|
59
|
-
else
|
60
|
-
self.class.decode_status_message(code_or_message) || raise("unknown http status message '#{code_or_message}'!")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.decode_status_message message
|
65
|
-
STATUS_MESSAGES[message]
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
#
|
70
|
-
# Status helpers
|
71
|
-
#
|
72
|
-
STATUS_MESSAGES.each do |message, status_code|
|
73
|
-
define_method("#{message}?"){self.status == status_code}
|
74
|
-
end
|
75
|
-
alias_method :success?, :ok?
|
76
|
-
|
77
|
-
def redirect?
|
78
|
-
super or (body and body.include?('window.location'))
|
79
|
-
end
|
80
|
-
|
81
|
-
protected
|
82
|
-
def to_a2
|
83
|
-
[status, header, body_as_string]
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module ControllerMicelaneousHelper
|
3
|
-
def reload_page
|
4
|
-
params = workspace.params
|
5
|
-
params.format.must_be.in 'html', 'js'
|
6
|
-
|
7
|
-
keep_flash!
|
8
|
-
if params.format == 'js'
|
9
|
-
workspace.response.set!(
|
10
|
-
status: :ok,
|
11
|
-
content_type: Mime[params.format]
|
12
|
-
)
|
13
|
-
throw :halt_render, "window.location.reload();"
|
14
|
-
else
|
15
|
-
redirect_to workspace.request.env["HTTP_REFERER"]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module AbstractRoutingHelper
|
3
|
-
protected
|
4
|
-
def special_url key
|
5
|
-
return nil unless (key.is_a?(Symbol) or key.is_a?(String))
|
6
|
-
|
7
|
-
if key == :back
|
8
|
-
workspace.request.env["HTTP_REFERER"] || 'javascript:history.back()'
|
9
|
-
elsif key == '#'
|
10
|
-
'#'
|
11
|
-
elsif key !~ /^[\/0-9_a-z]+$/i
|
12
|
-
key
|
13
|
-
else
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def keep_flash!
|
19
|
-
rad[:flash].keep! if rad.include? :flash
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module ControllerRoutingHelper
|
3
|
-
inherit AbstractRoutingHelper
|
4
|
-
|
5
|
-
module ClassMethods
|
6
|
-
|
7
|
-
#
|
8
|
-
# persist_params controller filters
|
9
|
-
#
|
10
|
-
def persist_params *args
|
11
|
-
if args.empty?
|
12
|
-
before :persist_params
|
13
|
-
elsif args.first.is_a? Hash
|
14
|
-
before :persist_params, args.first
|
15
|
-
else
|
16
|
-
before :persist_params, only: args.first
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# redirect_to
|
23
|
-
#
|
24
|
-
def redirect_to *args
|
25
|
-
params, response = workspace.params, workspace.response
|
26
|
-
params.format.must_be.in 'html', 'js'
|
27
|
-
|
28
|
-
if url = special_url(args.first)
|
29
|
-
args.size.must_be <= 1
|
30
|
-
else
|
31
|
-
url = url_for(*args)
|
32
|
-
end
|
33
|
-
content_type = Mime[params.format]
|
34
|
-
|
35
|
-
content = if params.format == 'js'
|
36
|
-
response.set!(
|
37
|
-
status: :ok,
|
38
|
-
content_type: content_type
|
39
|
-
)
|
40
|
-
|
41
|
-
"window.location = '#{url}';"
|
42
|
-
else
|
43
|
-
response.set!(
|
44
|
-
status: :redirect,
|
45
|
-
content_type: content_type
|
46
|
-
)
|
47
|
-
response.headers['Location'] = url
|
48
|
-
|
49
|
-
%(<html><body>You are being <a href="#{url.html_escape if url}">redirected</a>.</body></html>)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Flash need to know if we using redirect
|
53
|
-
keep_flash!
|
54
|
-
|
55
|
-
throw :halt_render, content
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module ViewRoutingHelper
|
3
|
-
inherit AbstractRoutingHelper
|
4
|
-
|
5
|
-
#
|
6
|
-
# links
|
7
|
-
#
|
8
|
-
# def link_to *args, &block
|
9
|
-
# # parse args
|
10
|
-
# content = if block
|
11
|
-
# capture(&block)
|
12
|
-
# else
|
13
|
-
# args.shift
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# special = nil
|
17
|
-
# html_options = if args.last.is_a?(Hash)
|
18
|
-
# if args[-2].is_a?(Hash)
|
19
|
-
# args.pop
|
20
|
-
# else
|
21
|
-
# {}
|
22
|
-
# end
|
23
|
-
# else
|
24
|
-
# args << {}
|
25
|
-
# {}
|
26
|
-
# end
|
27
|
-
#
|
28
|
-
# # build url
|
29
|
-
# url = special_url(*args) || url_for(*args)
|
30
|
-
#
|
31
|
-
# # add javascript
|
32
|
-
# add_js_link_options! url, html_options
|
33
|
-
#
|
34
|
-
# tag :a, content, html_options.merge(href: url)
|
35
|
-
# end
|
36
|
-
|
37
|
-
def link_to *args, &block
|
38
|
-
# content
|
39
|
-
content = if block
|
40
|
-
capture(&block)
|
41
|
-
else
|
42
|
-
args.shift
|
43
|
-
end
|
44
|
-
|
45
|
-
# url, html_options
|
46
|
-
if args.first.is_a? String
|
47
|
-
args.size.must_be.in 1..2
|
48
|
-
url, html_options = args
|
49
|
-
html_options ||= {}
|
50
|
-
else
|
51
|
-
if url = special_url(args.first)
|
52
|
-
args.size.must_be <= 2
|
53
|
-
html_options = args[1] || {}
|
54
|
-
else
|
55
|
-
html_options = if args[-1].is_a?(Hash) and args[-1].is_a?(Hash)
|
56
|
-
args.pop
|
57
|
-
else
|
58
|
-
{}
|
59
|
-
end
|
60
|
-
|
61
|
-
args << {} unless args[-1].is_a?(Hash)
|
62
|
-
url = url_for(*args)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# add javascript
|
67
|
-
add_js_link_options! url, html_options
|
68
|
-
|
69
|
-
tag :a, content, html_options.merge(href: url)
|
70
|
-
end
|
71
|
-
|
72
|
-
protected
|
73
|
-
# TODO3 refactor to use data-remote, data-method, data-confirm
|
74
|
-
def add_js_link_options! url, html_options
|
75
|
-
confirm, remote, method = html_options.delete(:confirm), html_options.delete(:remote),
|
76
|
-
html_options.delete(:method)
|
77
|
-
|
78
|
-
remote ||= config.remote_link_formats!.include? url.marks.format
|
79
|
-
|
80
|
-
onclick = if remote
|
81
|
-
method ||= :get
|
82
|
-
%{$(this).link_to({method: '#{method}', ajax: true}); return false;}
|
83
|
-
elsif method
|
84
|
-
%{$(this).link_to({method: '#{method}'}); return false;}
|
85
|
-
else
|
86
|
-
nil
|
87
|
-
end
|
88
|
-
|
89
|
-
# if onclick and ActionController::Base.defer_static_scripts?
|
90
|
-
# html_options['class'] ||= ""
|
91
|
-
# end
|
92
|
-
|
93
|
-
if confirm
|
94
|
-
onclick = if onclick
|
95
|
-
%(if(confirm('#{confirm.js_escape}')){#{onclick}}; return false;)
|
96
|
-
else
|
97
|
-
%(return confirm('#{confirm.js_escape}');)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
html_options[:onclick] = onclick if onclick
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
data/lib/rad/integration.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rad/html'
|
2
|
-
require 'rad/router'
|
3
|
-
|
4
|
-
%w(
|
5
|
-
controller_micelaneous_helper
|
6
|
-
|
7
|
-
router/abstract_routing_helper
|
8
|
-
router/view_routing_helper
|
9
|
-
router/controller_routing_helper
|
10
|
-
).each{|f| require "rad/integration/#{f}"}
|
11
|
-
|
12
|
-
|
13
|
-
module Rad
|
14
|
-
# View helpers
|
15
|
-
[
|
16
|
-
HtmlHelper,
|
17
|
-
CoreRoutingHelper, ViewRoutingHelper
|
18
|
-
].each do |helper|
|
19
|
-
ControllerContext.inherit helper
|
20
|
-
end
|
21
|
-
|
22
|
-
# Controller helpers
|
23
|
-
[
|
24
|
-
FlashHelper,
|
25
|
-
CoreRoutingHelper, ControllerRoutingHelper,
|
26
|
-
ControllerMicelaneousHelper
|
27
|
-
].each do |helper|
|
28
|
-
AbstractController.inherit helper
|
29
|
-
end
|
30
|
-
end
|
data/lib/rad/mail/letter.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
class Letter
|
3
|
-
inject mailer: :mailer
|
4
|
-
|
5
|
-
attr_accessor :from, :to, :subject, :body
|
6
|
-
|
7
|
-
def initialize properties
|
8
|
-
properties.each do |k, v|
|
9
|
-
send "#{k}=", v
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def validate!
|
14
|
-
from || raise("letter :from not specified!")
|
15
|
-
to || raise("letter :to not specified!")
|
16
|
-
subject || raise("letter :subject not specified!")
|
17
|
-
body || raise("letter :body not specified!")
|
18
|
-
end
|
19
|
-
|
20
|
-
def deliver
|
21
|
-
validate!
|
22
|
-
mailer.deliver self
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_hash
|
26
|
-
{from: from, to: to, subject: subject, body: body}
|
27
|
-
end
|
28
|
-
alias_method :to_h, :to_hash
|
29
|
-
end
|
30
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module MailController
|
3
|
-
inherit AbstractController
|
4
|
-
|
5
|
-
attr_accessor :from, :to, :subject, :body
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
protected
|
9
|
-
inject conveyors: :conveyors
|
10
|
-
|
11
|
-
def method_missing m, *args, &block
|
12
|
-
mail_controller = self.new
|
13
|
-
if mail_controller.respond_to? m
|
14
|
-
build_letter mail_controller, m, *args
|
15
|
-
else
|
16
|
-
super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def build_letter mail_controller, m, *args
|
21
|
-
conveyors.mail.must_be.present
|
22
|
-
workspace = conveyors.mail.call(
|
23
|
-
controller: mail_controller,
|
24
|
-
method_name: m,
|
25
|
-
arguments: args
|
26
|
-
)
|
27
|
-
workspace.letter.must_be.present
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/rad/mail/mailer.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
class Mailer
|
3
|
-
inject logger: :logger, config: :config
|
4
|
-
|
5
|
-
def deliver letter
|
6
|
-
mail = Mail.new letter.to_h
|
7
|
-
if config.development?
|
8
|
-
logger.info " Delivering mail #{letter.to_h.inspect}"
|
9
|
-
else
|
10
|
-
logger.info " Delivering mail '#{letter.subject}'"
|
11
|
-
end
|
12
|
-
mail.deliver!
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
rad.after :environment do
|
18
|
-
if rad.config.development?
|
19
|
-
Mail.defaults do
|
20
|
-
delivery_method :test
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module Processors
|
3
|
-
class LetterBuilder < Processor
|
4
|
-
def call
|
5
|
-
# prepare
|
6
|
-
controller = workspace.controller.must_be.present
|
7
|
-
raise "The controller #{controller} must be a Rad::MailController!" unless controller.is_a? Rad::MailController
|
8
|
-
action = workspace.action = workspace.method_name
|
9
|
-
|
10
|
-
# call
|
11
|
-
content = catch :halt_render do
|
12
|
-
controller.run_callbacks :action, method: action do
|
13
|
-
# call controller
|
14
|
-
controller.send action, *workspace.arguments
|
15
|
-
# render view
|
16
|
-
controller.render action: action
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
controller.body = content unless content.blank?
|
21
|
-
|
22
|
-
# letter
|
23
|
-
workspace.letter = ::Rad::Letter.new(
|
24
|
-
from: controller.from,
|
25
|
-
to: controller.to,
|
26
|
-
subject: controller.subject,
|
27
|
-
body: controller.body
|
28
|
-
)
|
29
|
-
workspace.letter.validate!
|
30
|
-
|
31
|
-
next_processor.call if next_processor
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/rad/mail.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'mail'
|
2
|
-
|
3
|
-
require 'rad/controller'
|
4
|
-
require 'rad/template'
|
5
|
-
|
6
|
-
%w(
|
7
|
-
mailer
|
8
|
-
letter
|
9
|
-
mail_controller
|
10
|
-
processors/letter_builder
|
11
|
-
).each{|f| require "rad/mail/#{f}"}
|
12
|
-
|
13
|
-
rad.register :mailer, depends_on: :environment do
|
14
|
-
Rad::Mailer.new
|
15
|
-
end
|
data/lib/rad/profiles/mail.rb
DELETED
data/lib/rad/remote/remote.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Rad
|
2
|
-
module Routes
|
3
|
-
class Configurator
|
4
|
-
inject router: :router
|
5
|
-
|
6
|
-
def initialize router
|
7
|
-
@router = router
|
8
|
-
end
|
9
|
-
|
10
|
-
def persistent_params *args
|
11
|
-
args.each{|v| router.persistent_params << v}
|
12
|
-
end
|
13
|
-
|
14
|
-
delegate :skip, to: :router
|
15
|
-
|
16
|
-
class << self
|
17
|
-
inject router: :router
|
18
|
-
|
19
|
-
def routes &block
|
20
|
-
block.call Configurator.new(router)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|