rad_core 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/bin/rad +20 -25
- data/lib/components/config.rb +1 -1
- data/lib/components/configurators.rb +2 -2
- data/lib/components/controller.rb +2 -2
- data/lib/components/conveyors.rb +2 -2
- data/lib/components/environment.rb +1 -1
- data/lib/components/environment.yml +28 -28
- data/lib/components/flash.rb +1 -1
- data/lib/components/html.rb +1 -1
- data/lib/components/http.rb +1 -1
- data/lib/components/http.yml +1 -1
- data/lib/components/logger.rb +2 -2
- data/lib/components/mailer.rb +2 -2
- data/lib/components/remote.rb +1 -1
- data/lib/components/router.rb +3 -3
- data/lib/components/template.rb +2 -2
- data/lib/components/web.rb +3 -3
- data/lib/rad.rb +1 -1
- data/lib/rad/_support/active_support.rb +7 -7
- data/lib/rad/_support/active_support/locales/ru/actionview.yml +8 -8
- data/lib/rad/_support/active_support/locales/ru/activesupport.yml +4 -4
- data/lib/rad/_support/active_support/locales/ru/datetime.yml +5 -5
- data/lib/rad/_support/active_support/time.rb +2 -2
- data/lib/rad/_support/addressable.rb +6 -6
- data/lib/rad/_support/class_loader.rb +1 -1
- data/lib/rad/_support/extensions.rb +5 -5
- data/lib/rad/_support/filters.rb +13 -13
- data/lib/rad/_support/hacks_and_fixes.rb +5 -5
- data/lib/rad/_support/mime.rb +4 -4
- data/lib/rad/_support/module.rb +11 -11
- data/lib/rad/_support/require.rb +5 -5
- data/lib/rad/_support/rson.rb +4 -4
- data/lib/rad/_support/string.rb +9 -9
- data/lib/rad/cli/helper.rb +5 -5
- data/lib/rad/configurators/_require.rb +2 -2
- data/lib/rad/configurators/abstract.rb +5 -5
- data/lib/rad/configurators/web.rb +8 -8
- data/lib/rad/controller/_abstract.rb +15 -14
- data/lib/rad/controller/_abstract/miscellaneous.rb +5 -5
- data/lib/rad/controller/_abstract/render.rb +40 -40
- data/lib/rad/controller/_abstract/responder.rb +1 -1
- data/lib/rad/controller/_context.rb +1 -1
- data/lib/rad/controller/_http.rb +11 -11
- data/lib/rad/controller/_require.rb +6 -6
- data/lib/rad/controller/processors/controller_caller.rb +3 -3
- data/lib/rad/controller/processors/controller_error_handling.rb +14 -14
- data/lib/rad/controller/processors/controller_logger.rb +1 -1
- data/lib/rad/conveyors/_conveyor.rb +9 -9
- data/lib/rad/conveyors/_conveyors.rb +4 -4
- data/lib/rad/conveyors/_params.rb +5 -5
- data/lib/rad/conveyors/_processor.rb +2 -2
- data/lib/rad/conveyors/_workspace.rb +5 -5
- data/lib/rad/conveyors/processors/conveyor_logger.rb +3 -3
- data/lib/rad/environment/_config.rb +4 -4
- data/lib/rad/environment/_environment.rb +10 -10
- data/lib/rad/environment/_files_helper.rb +5 -5
- data/lib/rad/environment/_logger.rb +9 -9
- data/lib/rad/environment/_require.rb +4 -4
- data/lib/rad/gems.rb +14 -14
- data/lib/rad/html/_flash.rb +5 -5
- data/lib/rad/html/_helpers/basic_html_helper.rb +12 -12
- data/lib/rad/html/_helpers/form_helper.rb +19 -19
- data/lib/rad/html/_helpers/javascript_helper.rb +6 -6
- data/lib/rad/html/_helpers/model_helper.rb +17 -17
- data/lib/rad/html/_require.rb +1 -1
- data/lib/rad/html/processors/prepare_flash.rb +3 -3
- data/lib/rad/html/processors/scoped_params.rb +4 -4
- data/lib/rad/http/_http.rb +4 -4
- data/lib/rad/http/_http_adapter.rb +5 -5
- data/lib/rad/http/_request.rb +11 -11
- data/lib/rad/http/_require.rb +8 -8
- data/lib/rad/http/_response.rb +5 -5
- data/lib/rad/http/_support/rack/fixes.rb +3 -3
- data/lib/rad/http/_support/rack/rack_adapter.rb +5 -5
- data/lib/rad/http/processors/evaluate_format.rb +4 -4
- data/lib/rad/http/processors/http_logger.rb +3 -3
- data/lib/rad/http/processors/http_writer.rb +7 -7
- data/lib/rad/http/processors/prepare_params.rb +5 -5
- data/lib/rad/mailer/_letter.rb +1 -1
- data/lib/rad/mailer/_mailer.rb +1 -1
- data/lib/rad/mailer/_mailer_controller.rb +6 -6
- data/lib/rad/mailer/_require.rb +1 -1
- data/lib/rad/mailer/processors/letter_builder.rb +6 -6
- data/lib/rad/profiles/mailer.rb +2 -2
- data/lib/rad/profiles/web.rb +13 -13
- data/lib/rad/remote/processors/remote_caller.rb +10 -10
- data/lib/rad/remote/processors/remote_logger.rb +1 -1
- data/lib/rad/router/_abstract_router.rb +9 -9
- data/lib/rad/router/_alias_router.rb +34 -34
- data/lib/rad/router/_basic_router.rb +12 -12
- data/lib/rad/router/_configurator.rb +6 -6
- data/lib/rad/router/_core_routing_helper.rb +4 -4
- data/lib/rad/router/_object_router.rb +45 -45
- data/lib/rad/router/_require.rb +8 -8
- data/lib/rad/router/_restful_router.rb +25 -25
- data/lib/rad/router/_router.rb +78 -78
- data/lib/rad/router/_simple_router.rb +5 -5
- data/lib/rad/router/processors/router.rb +6 -6
- data/lib/rad/spec/controller.rb +9 -9
- data/lib/rad/spec/environment.rb +7 -7
- data/lib/rad/spec/http.rb +2 -2
- data/lib/rad/spec/http_controller.rb +22 -22
- data/lib/rad/spec/mailer.rb +4 -4
- data/lib/rad/spec/remote.rb +1 -1
- data/lib/rad/spec/router.rb +4 -4
- data/lib/rad/spec/template.rb +2 -2
- data/lib/rad/tasks.rb +2 -2
- data/lib/rad/template/_context.rb +15 -15
- data/lib/rad/template/_relative_path_resolver.rb +1 -1
- data/lib/rad/template/_support/tilt.rb +17 -17
- data/lib/rad/template/_support/tilt_fixes.rb +3 -3
- data/lib/rad/template/_template.rb +47 -47
- data/lib/rad/web/_ajax_helper.rb +4 -4
- data/lib/rad/web/_controller_miscellaneous_helper.rb +5 -5
- data/lib/rad/web/_ensure_no_www.rb +5 -5
- data/lib/rad/web/_protect_from_forgery.rb +18 -18
- data/lib/rad/web/_require.rb +7 -7
- data/lib/rad/web/_router/abstract_routing_helper.rb +4 -4
- data/lib/rad/web/_router/controller_routing_helper.rb +15 -15
- data/lib/rad/web/_router/view_routing_helper.rb +12 -12
- data/readme.md +5 -5
- data/spec/controller/abstract_spec.rb +29 -29
- data/spec/controller/context_spec.rb +32 -32
- data/spec/controller/error_handling_spec.rb +31 -31
- data/spec/controller/helper_spec.rb +13 -13
- data/spec/controller/http_spec.rb +32 -32
- data/spec/controller/render_spec.rb +59 -59
- data/spec/conveyors/conveyors_spec.rb +32 -32
- data/spec/environment/config_spec.rb +6 -6
- data/spec/environment/environment_spec.rb +7 -7
- data/spec/environment/minimal_app_spec.rb +4 -4
- data/spec/environment/standard_app_spec.rb +10 -10
- data/spec/html/basic_html_helper_spec.rb +6 -6
- data/spec/html/form_helper_spec.rb +5 -5
- data/spec/html/javascript_helper_spec.rb +4 -4
- data/spec/html/model_helper_spec.rb +12 -12
- data/spec/html/scoped_params_spec.rb +2 -2
- data/spec/html/spec_helper.rb +3 -3
- data/spec/http/http_spec.rb +9 -9
- data/spec/http/miscellaneous_spec.rb +2 -2
- data/spec/mailer/mail_controller_spec.rb +23 -23
- data/spec/remote/remote_spec.rb +26 -26
- data/spec/router/alias_router_spec.rb +22 -22
- data/spec/router/basic_router_spec.rb +8 -8
- data/spec/router/configurator_spec.rb +4 -4
- data/spec/router/integration_spec.rb +17 -17
- data/spec/router/object_router_spec.rb +47 -47
- data/spec/router/persistent_params_spec.rb +18 -18
- data/spec/router/restful_router_spec.rb +39 -39
- data/spec/router/router_spec.rb +37 -37
- data/spec/router/routing_helper_spec.rb +18 -18
- data/spec/support/filters_spec.rb +11 -13
- data/spec/template/template_spec.rb +43 -45
- data/spec/template/template_spec/views/layout/content_for/content.erb +3 -1
- data/spec/template/template_spec/views/layout/content_for/layout.erb +1 -1
- data/spec/template/tilt_spec.rb +24 -24
- data/spec/web/basic_spec.rb +25 -25
- data/spec/web/controller_routing_helper_spec.rb +26 -26
- data/spec/web/flash_spec.rb +31 -31
- data/spec/web/protect_from_forgery_spec.rb +44 -44
- data/spec/web/spec_helper_spec.rb +16 -16
- data/spec/web/view_routing_helper_spec.rb +31 -31
- metadata +46 -49
- data/lib/rad/_support/callbacks.rb +0 -166
- data/lib/rad/_support/ruby_ext_with_active_support.rb +0 -4
- data/spec/support/callbacks_spec.rb +0 -157
data/lib/rad/web/_ajax_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# Sets format for :js as :html and wraps body into <textarea>
|
2
|
-
# Forms with files can be submitted by ajax only via iframe, and it requires
|
2
|
+
# Forms with files can be submitted by ajax only via iframe, and it requires
|
3
3
|
# the response have 'html' encoding and be wrapped into <textarea>
|
4
4
|
class Rad::Web::Processors::AjaxHelper < Rad::Conveyors::Processor
|
5
5
|
def call
|
6
6
|
response = workspace.response.must_be.defined
|
7
7
|
request = workspace.request.must_be.defined
|
8
|
-
|
8
|
+
|
9
9
|
next_processor.call
|
10
|
-
|
10
|
+
|
11
11
|
if workspace.params? and workspace.params.format == 'js' and !request.xhr?
|
12
12
|
response.content_type = Mime['html']
|
13
13
|
workspace.content = "<textarea>#{workspace.content}</textarea>"
|
14
|
-
end
|
14
|
+
end
|
15
15
|
end
|
16
16
|
end
|
@@ -2,16 +2,16 @@ module Rad::ControllerMiscellaneousHelper
|
|
2
2
|
def reload_page
|
3
3
|
params = workspace.params
|
4
4
|
params.format.must_be.in 'html', 'js'
|
5
|
-
|
6
|
-
keep_flash!
|
5
|
+
|
6
|
+
keep_flash!
|
7
7
|
if params.format == 'js'
|
8
8
|
workspace.response.set!(
|
9
|
-
status: :ok,
|
9
|
+
status: :ok,
|
10
10
|
content_type: Mime[params.format]
|
11
11
|
)
|
12
12
|
throw :halt, "window.location.reload();"
|
13
13
|
else
|
14
14
|
redirect_to request.env["HTTP_REFERER"]
|
15
|
-
end
|
16
|
-
end
|
15
|
+
end
|
16
|
+
end
|
17
17
|
end
|
@@ -7,21 +7,21 @@ class Rad::Web::Processors::EnsureNoWww < Rad::Conveyors::Processor
|
|
7
7
|
else
|
8
8
|
next_processor.call
|
9
9
|
end
|
10
|
-
end
|
11
|
-
|
10
|
+
end
|
11
|
+
|
12
12
|
protected
|
13
13
|
def uri
|
14
14
|
@uri ||= Uri.parse workspace.request.url
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def url_with_www?
|
18
18
|
uri.host =~ /^www\./
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def redirect_without_www
|
22
22
|
uri.host = uri.host.sub(/^www\./, '')
|
23
23
|
url = uri.to_s
|
24
|
-
|
24
|
+
|
25
25
|
response = workspace.response
|
26
26
|
response.status = 301
|
27
27
|
response.headers['Location'] = url
|
@@ -1,40 +1,40 @@
|
|
1
|
-
#
|
1
|
+
#
|
2
2
|
# Processor
|
3
|
-
#
|
4
|
-
class Rad::Web::Processors::PrepareAutenticityToken < Rad::Conveyors::Processor
|
5
|
-
def call
|
3
|
+
#
|
4
|
+
class Rad::Web::Processors::PrepareAutenticityToken < Rad::Conveyors::Processor
|
5
|
+
def call
|
6
6
|
if rad.http.session
|
7
7
|
request = workspace.request.must_be.defined
|
8
8
|
params = workspace.params.must_be.defined
|
9
|
-
|
9
|
+
|
10
10
|
token = request.session['authenticity_token']
|
11
11
|
|
12
12
|
if token.blank? and request.get?
|
13
13
|
token = generate_authenticity_token
|
14
14
|
request.session['authenticity_token'] = token
|
15
|
-
end
|
15
|
+
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
next_processor.call
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
|
22
22
|
protected
|
23
23
|
def generate_authenticity_token
|
24
|
-
|
24
|
+
SecureRandom.base64(32)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
|
29
|
-
#
|
29
|
+
#
|
30
30
|
# Controller
|
31
|
-
#
|
31
|
+
#
|
32
32
|
module Rad::Controller::ForgeryProtector
|
33
|
-
attr_reader :authenticity_token
|
33
|
+
attr_reader :authenticity_token
|
34
34
|
protected
|
35
35
|
def protect_from_forgery
|
36
|
-
if request.session
|
37
|
-
sat = request.session['authenticity_token']
|
36
|
+
if request.session
|
37
|
+
sat = request.session['authenticity_token']
|
38
38
|
|
39
39
|
raise "invalid authenticity token!" unless \
|
40
40
|
request.get? or
|
@@ -48,21 +48,21 @@ end
|
|
48
48
|
|
49
49
|
Rad::Controller::Http.include Rad::Controller::ForgeryProtector
|
50
50
|
|
51
|
-
Rad::Controller::Http::ClassMethods.class_eval do
|
51
|
+
Rad::Controller::Http::ClassMethods.class_eval do
|
52
52
|
def protect_from_forgery options = {}
|
53
53
|
before :protect_from_forgery, options
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
|
58
|
-
#
|
58
|
+
#
|
59
59
|
# View
|
60
|
-
#
|
60
|
+
#
|
61
61
|
Rad::Html::FormHelper.class_eval do
|
62
62
|
attr_reader :authenticity_token
|
63
63
|
|
64
64
|
alias_method :form_tag_without_at, :form_tag
|
65
|
-
def form_tag *args, &b
|
65
|
+
def form_tag *args, &b
|
66
66
|
form_tag_without_at *args do
|
67
67
|
concat(hidden_field_tag('authenticity_token', authenticity_token) + "\n") if authenticity_token
|
68
68
|
b.call if b
|
data/lib/rad/web/_require.rb
CHANGED
@@ -5,11 +5,11 @@ end
|
|
5
5
|
|
6
6
|
%w(
|
7
7
|
_controller_miscellaneous_helper
|
8
|
-
|
8
|
+
|
9
9
|
_router/abstract_routing_helper
|
10
|
-
_router/view_routing_helper
|
10
|
+
_router/view_routing_helper
|
11
11
|
_router/controller_routing_helper
|
12
|
-
|
12
|
+
|
13
13
|
_ajax_helper
|
14
14
|
_ensure_no_www
|
15
15
|
_protect_from_forgery
|
@@ -23,12 +23,12 @@ end
|
|
23
23
|
].each do |helper|
|
24
24
|
Rad::Template::Context.inherit helper
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# Controller helpers
|
28
|
-
[
|
28
|
+
[
|
29
29
|
Rad::Html::FlashHelper,
|
30
|
-
Rad::Router::CoreRoutingHelper, Rad::ControllerRoutingHelper,
|
31
|
-
Rad::ControllerMiscellaneousHelper
|
30
|
+
Rad::Router::CoreRoutingHelper, Rad::ControllerRoutingHelper,
|
31
|
+
Rad::ControllerMiscellaneousHelper
|
32
32
|
].each do |helper|
|
33
33
|
Rad::Controller::Abstract.inherit helper
|
34
34
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Rad::AbstractRoutingHelper
|
2
|
-
protected
|
2
|
+
protected
|
3
3
|
def special_url key
|
4
4
|
return nil unless (key.is_a?(Symbol) or key.is_a?(String))
|
5
|
-
|
5
|
+
|
6
6
|
if key == :back
|
7
7
|
workspace.request.env["HTTP_REFERER"] || 'javascript:history.back()'
|
8
8
|
elsif key == '#'
|
@@ -12,8 +12,8 @@ module Rad::AbstractRoutingHelper
|
|
12
12
|
else
|
13
13
|
nil
|
14
14
|
end
|
15
|
-
end
|
16
|
-
|
15
|
+
end
|
16
|
+
|
17
17
|
def keep_flash!
|
18
18
|
rad[:flash].keep! if rad.include? :flash
|
19
19
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Rad::ControllerRoutingHelper
|
2
2
|
inherit Rad::AbstractRoutingHelper
|
3
|
-
|
3
|
+
|
4
4
|
module ClassMethods
|
5
|
-
|
6
|
-
#
|
5
|
+
|
6
|
+
#
|
7
7
|
# persist_params controller filters
|
8
|
-
#
|
8
|
+
#
|
9
9
|
def persist_params *args
|
10
10
|
if args.empty?
|
11
11
|
before :persist_params
|
@@ -16,10 +16,10 @@ module Rad::ControllerRoutingHelper
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
#
|
19
|
+
|
20
|
+
#
|
21
21
|
# redirect_to
|
22
|
-
#
|
22
|
+
#
|
23
23
|
def redirect_to *args
|
24
24
|
params, response = workspace.params, workspace.response
|
25
25
|
params.format.must_be.in 'html', 'js'
|
@@ -33,24 +33,24 @@ module Rad::ControllerRoutingHelper
|
|
33
33
|
|
34
34
|
content = if params.format == 'js'
|
35
35
|
response.set!(
|
36
|
-
status: :ok,
|
36
|
+
status: :ok,
|
37
37
|
content_type: content_type
|
38
38
|
)
|
39
|
-
|
39
|
+
|
40
40
|
"window.location = '#{url}';"
|
41
41
|
else
|
42
42
|
response.set!(
|
43
|
-
status: :redirect,
|
43
|
+
status: :redirect,
|
44
44
|
content_type: content_type
|
45
45
|
)
|
46
|
-
response.headers['Location'] = url
|
47
|
-
|
46
|
+
response.headers['Location'] = url
|
47
|
+
|
48
48
|
%(<html><body>You are being <a href="#{url.html_escape if url}">redirected</a>.</body></html>)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
# Flash need to know if we using redirect
|
52
52
|
keep_flash!
|
53
|
-
|
53
|
+
|
54
54
|
throw :halt, content
|
55
|
-
end
|
55
|
+
end
|
56
56
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Rad::ViewRoutingHelper
|
2
2
|
inherit Rad::AbstractRoutingHelper
|
3
|
-
|
4
|
-
def link_to *args, &block
|
3
|
+
|
4
|
+
def link_to *args, &block
|
5
5
|
# content
|
6
6
|
content = if block
|
7
7
|
capture(&block)
|
8
8
|
else
|
9
9
|
args.shift
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
# url, html_options
|
13
13
|
if args.first.is_a? String
|
14
14
|
args.size.must_be.in 1..2
|
@@ -18,38 +18,38 @@ module Rad::ViewRoutingHelper
|
|
18
18
|
if url = special_url(args.first)
|
19
19
|
args.size.must_be <= 2
|
20
20
|
html_options = args[1] || {}
|
21
|
-
else
|
21
|
+
else
|
22
22
|
html_options = if args[-1].is_a?(Hash) and args[-2].is_a?(Hash)
|
23
23
|
args.pop
|
24
24
|
else
|
25
25
|
{}
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
args << {} unless args[-1].is_a?(Hash)
|
29
29
|
url = url_for(*args)
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
# add javascript
|
34
34
|
html_options[:href] = url
|
35
|
-
add_js_link_options! url, html_options
|
35
|
+
add_js_link_options! url, html_options
|
36
36
|
tag :a, content, html_options
|
37
|
-
end
|
38
|
-
|
37
|
+
end
|
38
|
+
|
39
39
|
protected
|
40
40
|
def add_js_link_options! url, html_options
|
41
41
|
remote = html_options.delete(:remote) || rad.html.remote_link_formats.include?(url.marks.format)
|
42
42
|
method = html_options.delete(:method)
|
43
|
-
|
43
|
+
|
44
44
|
if remote or method
|
45
45
|
action = html_options.delete(:href).must_be.defined
|
46
46
|
html_options[:href] = '#'
|
47
|
-
|
47
|
+
|
48
48
|
html_options['data-action'] = action
|
49
49
|
html_options['data-remote'] = 'true' if remote
|
50
50
|
html_options['data-method'] = method || 'post'
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
if confirm = html_options.delete(:confirm)
|
54
54
|
html_options['data-confirm'] = confirm
|
55
55
|
end
|
data/readme.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Rad - Ruby Web Framework
|
2
2
|
|
3
|
-
Simple and highly customizable Web Framework encouraging to build an app as a set of cooperating components instead of monolith.
|
3
|
+
Simple and highly customizable Web Framework encouraging to build an app as a set of cooperating components instead of monolith.
|
4
4
|
With an architecture heavily inspired by Rails, Spring IoC, JBoss Seam and JEE (but without config burden).
|
5
5
|
|
6
6
|
You can start instantly using one of predefined profiles, or take a total control over all aspects of environment and completelly modify it according to Your goals (everything is a component, if You don't like the router, controller or views - throw it out and introduce Your own).
|
7
7
|
|
8
|
-
Usually, the first thing You want to now about some unknown framework: "where's the demo?" and "where's the sample?".
|
8
|
+
Usually, the first thing You want to now about some unknown framework: "where's the demo?" and "where's the sample?".
|
9
9
|
|
10
10
|
Here's some **sites built with Rad**:
|
11
11
|
|
@@ -32,10 +32,10 @@ Here's the classic **sample blog app** [rad-sample.heroku.com](http://rad-sample
|
|
32
32
|
|
33
33
|
## It's small
|
34
34
|
|
35
|
-
I would like to mention it one more time - Rad is not a super-specialized framework like Sinatra, it's the universal and full-featured Web Framework, but
|
36
|
-
Take a look at [code statistics](http://ruby-lang.info/blog/simple-approach-to-measure-the-agility-and-complexi-4mu), find there the 'rad_core' word and compare
|
35
|
+
I would like to mention it one more time - Rad is not a super-specialized framework like Sinatra, it's the universal and full-featured Web Framework, but its size is small, really small!
|
36
|
+
Take a look at [code statistics](http://ruby-lang.info/blog/simple-approach-to-measure-the-agility-and-complexi-4mu), find there the 'rad_core' word and compare its size with others, actually its even smaller, because the half of code belongs to specs.
|
37
37
|
|
38
|
-
I believe **small code size is very important**, it means that the project is easy to understand, easy to refactor and customize and
|
38
|
+
I believe **small code size is very important**, it means that the project is easy to understand, easy to refactor and customize and its agile (by agility I mean high speed of reaction and adoption to changing world environment and requirements).
|
39
39
|
|
40
40
|
## Why did I make another Rails?
|
41
41
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe "Abstract" do
|
4
4
|
with_view_path "#{spec_dir}/views"
|
5
5
|
with_abstract_controller
|
6
|
-
|
6
|
+
|
7
7
|
after :all do
|
8
8
|
remove_constants %w(
|
9
9
|
WorkspaceVariablesSpec
|
@@ -11,47 +11,47 @@ describe "Abstract" do
|
|
11
11
|
RespondToSpec
|
12
12
|
ViewVariablesSpec
|
13
13
|
OperationsOrderSpec
|
14
|
-
NoTemplateSpec
|
14
|
+
NoTemplateSpec
|
15
15
|
)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should set workspace variables" do
|
19
19
|
class ::WorkspaceVariablesSpec
|
20
20
|
inherit Rad::Controller::Abstract
|
21
|
-
|
21
|
+
|
22
22
|
def action; end
|
23
23
|
end
|
24
|
-
|
25
|
-
ccall WorkspaceVariablesSpec, :action
|
24
|
+
|
25
|
+
ccall WorkspaceVariablesSpec, :action
|
26
26
|
|
27
27
|
workspace.controller.should be_a(WorkspaceVariablesSpec)
|
28
28
|
response.should respond_to("body=")
|
29
29
|
|
30
|
-
expected_result = {
|
30
|
+
expected_result = {
|
31
31
|
params: {},
|
32
|
-
|
33
|
-
class: WorkspaceVariablesSpec,
|
34
|
-
method_name: :action,
|
32
|
+
|
33
|
+
class: WorkspaceVariablesSpec,
|
34
|
+
method_name: :action,
|
35
35
|
action_name: :action
|
36
36
|
}
|
37
37
|
workspace.to_h(true).subset(expected_result.keys).should == expected_result
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it "should be able to throw :halt in controller or view and that result must be assigned as result" do
|
41
41
|
class ::SpecialResultSpec
|
42
|
-
inherit Rad::Controller::Abstract
|
42
|
+
inherit Rad::Controller::Abstract
|
43
43
|
def action
|
44
44
|
throw :halt, 'some content'
|
45
|
-
end
|
45
|
+
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
ccall(SpecialResultSpec, :action).should == "some content"
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "respond_to" do
|
52
52
|
class ::RespondToSpec
|
53
53
|
inherit Rad::Controller::Abstract
|
54
|
-
|
54
|
+
|
55
55
|
def action
|
56
56
|
respond_to do |format|
|
57
57
|
format.html{render inline: 'html'}
|
@@ -59,21 +59,21 @@ describe "Abstract" do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
ccall(RespondToSpec, :action, format: 'html').should == 'html'
|
64
64
|
ccall(RespondToSpec, :action, format: 'json').should == %({"a":"b"})
|
65
65
|
lambda{ccall(RespondToSpec, :action, format: 'js')}.should raise_error(/can't respond to 'js' format/)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "controller's instance variables must be available in view, and also other variables" do
|
69
69
|
class ::ViewVariablesSpec
|
70
70
|
inherit Rad::Controller::Abstract
|
71
|
-
|
71
|
+
|
72
72
|
def action
|
73
73
|
@instance_variable = "iv value"
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
ccall(ViewVariablesSpec, :action, param: 'param value', format: 'html').should == %(\
|
78
78
|
controller: ViewVariablesSpec
|
79
79
|
controller_name: ViewVariablesSpec
|
@@ -87,15 +87,15 @@ instance_variable: iv value
|
|
87
87
|
params: param value
|
88
88
|
format: html)
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
it "operations order" do
|
92
92
|
class ::OperationsOrderSpec
|
93
93
|
inherit Rad::Controller::Abstract
|
94
|
-
|
94
|
+
|
95
95
|
def self.result
|
96
96
|
@result ||= []
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
around do |controller, block|
|
100
100
|
begin
|
101
101
|
OperationsOrderSpec.result << :before
|
@@ -104,23 +104,23 @@ format: html)
|
|
104
104
|
OperationsOrderSpec.result << :after
|
105
105
|
end
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def action
|
109
109
|
OperationsOrderSpec.result << :action
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
ccall(OperationsOrderSpec, :action)
|
114
|
-
OperationsOrderSpec.result.should == [:before, :action, :template, :after]
|
114
|
+
OperationsOrderSpec.result.should == [:before, :action, :template, :after]
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
it "should render :nothing" do
|
118
118
|
class NoTemplateSpec
|
119
119
|
inherit Rad::Controller::Abstract
|
120
|
-
|
120
|
+
|
121
121
|
def action; end
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
ccall(NoTemplateSpec, :action).should == ""
|
125
125
|
end
|
126
126
|
end
|