rad_core 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +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
|
@@ -6,11 +6,11 @@ Addressable::URI.class_eval do
|
|
|
6
6
|
(self.query ? "?#{self.query}" : "")
|
|
7
7
|
)
|
|
8
8
|
end
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
def self.normalize_host host
|
|
11
11
|
host.gsub(/^www\./, "")
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def normalized_host
|
|
15
15
|
host ? host : host.gsub(/^www\./, '')
|
|
16
16
|
end
|
|
@@ -19,13 +19,13 @@ Addressable::URI.class_eval do
|
|
|
19
19
|
def query_values_with_skip_nil= options
|
|
20
20
|
to_delete = []
|
|
21
21
|
options.each{|k, v| to_delete << k if v.nil?}
|
|
22
|
-
to_delete.each{|k| options.delete k}
|
|
23
|
-
|
|
22
|
+
to_delete.each{|k| options.delete k}
|
|
23
|
+
|
|
24
24
|
self.query_values_without_skip_nil = options
|
|
25
25
|
end
|
|
26
26
|
alias_method_chain :query_values=, :skip_nil
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
29
|
# Override original to fix:
|
|
30
30
|
# - extra '?' sign (/some_path?) if there's empty but not-nil query
|
|
31
31
|
def to_s
|
|
@@ -2,19 +2,19 @@ class Micon::Core
|
|
|
2
2
|
def register_extension name, &block
|
|
3
3
|
name.must_be.a Symbol
|
|
4
4
|
block.must_be.defined
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
raise "extension :#{name} already registered!" if extensions.include? name
|
|
7
7
|
|
|
8
8
|
extensions[name] = block
|
|
9
9
|
end
|
|
10
|
-
|
|
11
|
-
def extension name, target = nil, *args, &default_extension
|
|
10
|
+
|
|
11
|
+
def extension name, target = nil, *args, &default_extension
|
|
12
12
|
name.must_be.a Symbol
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
if block = extensions[name] || default_extension
|
|
15
15
|
target ? target.instance_exec(*args, &block) : block.call(*args)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
def extensions; @extensions ||= {} end
|
|
20
20
|
end
|
data/lib/rad/_support/filters.rb
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
module Rad::Filters
|
|
2
|
-
inherit
|
|
3
|
-
|
|
2
|
+
inherit RubyExt::Callbacks
|
|
3
|
+
|
|
4
4
|
module ClassMethods
|
|
5
5
|
def before *args, &block
|
|
6
6
|
opt = args.extract_options!
|
|
7
|
-
if block
|
|
7
|
+
if block
|
|
8
8
|
set_callback :action, :before, opt, &block
|
|
9
|
-
else
|
|
10
|
-
args.each{|executor| set_callback :action, :before, executor, opt}
|
|
9
|
+
else
|
|
10
|
+
args.each{|executor| set_callback :action, :before, executor, opt}
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def around *args, &block
|
|
15
15
|
opt = args.extract_options!
|
|
16
|
-
if block
|
|
16
|
+
if block
|
|
17
17
|
set_callback :action, :around, opt, &block
|
|
18
|
-
else
|
|
19
|
-
args.each{|executor| set_callback :action, :around, executor, opt}
|
|
18
|
+
else
|
|
19
|
+
args.each{|executor| set_callback :action, :around, executor, opt}
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def after *args, &block
|
|
24
24
|
opt = args.extract_options!
|
|
25
|
-
if block
|
|
25
|
+
if block
|
|
26
26
|
set_callback :action, :after, opt, &block
|
|
27
|
-
else
|
|
28
|
-
args.each{|executor| set_callback :action, :after, executor, opt}
|
|
27
|
+
else
|
|
28
|
+
args.each{|executor| set_callback :action, :after, executor, opt}
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Problem: the Hash::slice method in ActiveSupport works a little differently than in Facets.
|
|
1
|
+
#
|
|
2
|
+
# Problem: the Hash::slice method in ActiveSupport works a little differently than in Facets.
|
|
3
3
|
# And because Facets is overrides ActiveSupport version this causes problems (for example in to_json method)
|
|
4
4
|
# In ActiveSupport it returns :nil if there's no key in Facets it raises error.
|
|
5
|
-
#
|
|
5
|
+
#
|
|
6
6
|
# Use Case:
|
|
7
7
|
# hash = {:items=>[], "slug"=>"item-z8w", "name"=>"Item", "created_at"=>"2011-01-10T07:04:01Z", "dependent"=>"false", "viewers"=>["manager", "user:user1"], "updated_at"=>"2011-01-10T07:04:01Z", :icon_url=>"null", "text"=>"null", "tags"=>[], "owner_name"=>"user1", "_type"=>"Selector"}
|
|
8
8
|
# args = ["id", "_type", "slug", "name", "text", "tags", "dependent", "owner_name", "viewers", "created_at", "updated_at"]
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
#
|
|
11
11
|
# Solution:
|
|
12
12
|
# Redefining :slice the same way as in ActiveSupport.
|
|
13
|
-
#
|
|
13
|
+
#
|
|
14
14
|
|
|
15
15
|
# TODO1 remove it, we don't use facets anymore
|
|
16
16
|
|
|
17
17
|
class Hash
|
|
18
18
|
def slice(*keep_keys)
|
|
19
19
|
hash = {}
|
|
20
|
-
keep_keys.each do |key|
|
|
20
|
+
keep_keys.each do |key|
|
|
21
21
|
# hash[key] = fetch(key)
|
|
22
22
|
hash[key] = self[key]
|
|
23
23
|
end
|
data/lib/rad/_support/mime.rb
CHANGED
|
@@ -4,14 +4,14 @@ module Mime
|
|
|
4
4
|
raise "invalid usage of Mime!" unless args.empty?
|
|
5
5
|
self[m]
|
|
6
6
|
end
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
def [] type
|
|
9
9
|
type = ".#{type}" unless type =~ /^\./
|
|
10
10
|
Rack::Mime.mime_type(type) || raise("Unknown MIME type: #{type}")
|
|
11
11
|
end
|
|
12
|
-
|
|
13
|
-
def image? file_name
|
|
14
|
-
return false if file_name.blank?
|
|
12
|
+
|
|
13
|
+
def image? file_name
|
|
14
|
+
return false if file_name.blank?
|
|
15
15
|
extension = File.extname(file_name)
|
|
16
16
|
Rack::Mime.mime_type(extension) =~ /image/
|
|
17
17
|
end
|
data/lib/rad/_support/module.rb
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
class Module
|
|
2
|
-
|
|
3
|
-
#
|
|
2
|
+
|
|
3
|
+
#
|
|
4
4
|
# Dynamically enables cache in :production and disables in another environments.
|
|
5
5
|
# If no environment given uses non-cached version.
|
|
6
|
-
#
|
|
7
|
-
def cache_method_with_params_in_production method
|
|
6
|
+
#
|
|
7
|
+
def cache_method_with_params_in_production method
|
|
8
8
|
escaped_method = escape_method(method)
|
|
9
9
|
method_with_cache, method_without_cache = "#{escaped_method}_with_cache", "#{escaped_method}_without_cache"
|
|
10
10
|
iv = "@#{escaped_method}_cache"
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
# raise "Method '#{method}' already defined!" if instance_methods.include?(method)
|
|
13
13
|
if instance_methods.include?(method_with_cache) or instance_methods.include?(method_without_cache)
|
|
14
|
-
warn "can't cache the :#{method} twice!"
|
|
14
|
+
warn "can't cache the :#{method} twice!"
|
|
15
15
|
else
|
|
16
|
-
alias_method method_without_cache, method
|
|
16
|
+
alias_method method_without_cache, method
|
|
17
17
|
|
|
18
18
|
# create cached method
|
|
19
|
-
define_method method_with_cache do |*args|
|
|
19
|
+
define_method method_with_cache do |*args|
|
|
20
20
|
unless results = instance_variable_get(iv)
|
|
21
21
|
results = Hash.new(NotDefined)
|
|
22
22
|
instance_variable_set iv, results
|
|
@@ -24,7 +24,7 @@ class Module
|
|
|
24
24
|
|
|
25
25
|
result = results[args]
|
|
26
26
|
|
|
27
|
-
if result.equal? NotDefined
|
|
27
|
+
if result.equal? NotDefined
|
|
28
28
|
result = send method_without_cache, *args
|
|
29
29
|
results[args] = result
|
|
30
30
|
end
|
|
@@ -40,7 +40,7 @@ class Module
|
|
|
40
40
|
|
|
41
41
|
# by default uses non-cached version
|
|
42
42
|
# alias_method method, method_without_cache
|
|
43
|
-
end
|
|
43
|
+
end
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
end
|
data/lib/rad/_support/require.rb
CHANGED
|
@@ -20,11 +20,12 @@ require 'ruby_ext'
|
|
|
20
20
|
|
|
21
21
|
require 'vfs'
|
|
22
22
|
|
|
23
|
-
require 'ruby_ext/more/open_constructor'
|
|
24
|
-
require 'rad/_support/ruby_ext_with_active_support'
|
|
23
|
+
# require 'ruby_ext/more/open_constructor'
|
|
24
|
+
# require 'rad/_support/ruby_ext_with_active_support'
|
|
25
25
|
|
|
26
26
|
require 'class_loader'
|
|
27
27
|
|
|
28
|
+
$dont_create_micon_shortcut = true
|
|
28
29
|
require 'micon'
|
|
29
30
|
# require 'micon/rad'
|
|
30
31
|
require 'rad/_support/micon'
|
|
@@ -46,11 +47,10 @@ require 'rad/_support/addressable'
|
|
|
46
47
|
#
|
|
47
48
|
require 'rad/_support/hacks_and_fixes'
|
|
48
49
|
|
|
49
|
-
[
|
|
50
|
+
[
|
|
50
51
|
'module',
|
|
51
|
-
'callbacks',
|
|
52
52
|
'filters',
|
|
53
|
-
'mime',
|
|
53
|
+
'mime',
|
|
54
54
|
'string',
|
|
55
55
|
'rson',
|
|
56
56
|
'exception',
|
data/lib/rad/_support/rson.rb
CHANGED
|
@@ -16,7 +16,7 @@ end
|
|
|
16
16
|
def to_rson options = {}
|
|
17
17
|
self
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def rson?
|
|
21
21
|
true
|
|
22
22
|
end
|
|
@@ -27,12 +27,12 @@ Array.class_eval do
|
|
|
27
27
|
def to_rson options = {}
|
|
28
28
|
collect{|v| v.to_rson(options)}
|
|
29
29
|
end
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
def rson?
|
|
32
32
|
all?{|v| v.rson?}
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
[Hash, OpenObject].each do |klass|
|
|
37
37
|
klass.class_eval do
|
|
38
38
|
def to_rson options = {}
|
|
@@ -42,7 +42,7 @@ end
|
|
|
42
42
|
end
|
|
43
43
|
r
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
def rson?
|
|
47
47
|
each do |k, v|
|
|
48
48
|
return false unless k.rson? and v.rson?
|
data/lib/rad/_support/string.rb
CHANGED
|
@@ -2,26 +2,26 @@ class String
|
|
|
2
2
|
def json_escape
|
|
3
3
|
ERB::Util.json_escape self
|
|
4
4
|
end
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
HTML_ESCAPE_MAP = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' }
|
|
7
7
|
def html_escape
|
|
8
8
|
# ERB and Rack both are replacing '/' character, and it's wrong because it destroys links (like '/default/my_item')
|
|
9
9
|
# ERB::Util.html_escape self
|
|
10
10
|
# Rack::Utils.escape_html self
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
gsub(/[&"><]/){|special| HTML_ESCAPE_MAP[special]}
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
def url_escape
|
|
16
16
|
# TODO2 change to Rack::Utils.escape
|
|
17
17
|
CGI.escape self
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def url_unescape
|
|
21
21
|
# TODO2 change to Rack::Utils.unescape
|
|
22
22
|
CGI.unescape self
|
|
23
23
|
end
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
JS_ESCAPE_MAP = {
|
|
26
26
|
'\\' => '\\\\',
|
|
27
27
|
'</' => '<\/',
|
|
@@ -29,12 +29,12 @@ class String
|
|
|
29
29
|
"\n" => '\n',
|
|
30
30
|
"\r" => '\n',
|
|
31
31
|
'"' => '\\"',
|
|
32
|
-
"'" => "\\'"
|
|
33
|
-
}
|
|
32
|
+
"'" => "\\'"
|
|
33
|
+
}
|
|
34
34
|
def js_escape
|
|
35
35
|
gsub(/(\\|<\/|\r\n|[\n\r"'])/){JS_ESCAPE_MAP[$1]}
|
|
36
36
|
end
|
|
37
|
-
|
|
38
|
-
# String marks, like :format, :safe
|
|
37
|
+
|
|
38
|
+
# String marks, like :format, :safe
|
|
39
39
|
def marks; @marks ||= OpenObject.new end
|
|
40
40
|
end
|
data/lib/rad/cli/helper.rb
CHANGED
|
@@ -3,20 +3,20 @@ module Helper
|
|
|
3
3
|
|
|
4
4
|
class << self
|
|
5
5
|
inject logger: :logger
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
def run_console
|
|
8
8
|
prepare_running_environment
|
|
9
9
|
|
|
10
10
|
require 'irb'
|
|
11
|
-
IRB.start
|
|
11
|
+
IRB.start
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def run_server
|
|
15
15
|
app = prepare_running_environment
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
rad.http.run app, rad.http.host, rad.http.port
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def use_runtime_path!
|
|
21
21
|
runtime_path = "./#{RUNTIME_DIR}"
|
|
22
22
|
Dir.chdir runtime_path if Dir.exist? runtime_path
|
|
@@ -25,7 +25,7 @@ module Helper
|
|
|
25
25
|
protected
|
|
26
26
|
def prepare_running_environment
|
|
27
27
|
use_runtime_path!
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
require 'rack'
|
|
30
30
|
app, options = Rack::Builder.parse_file 'config.ru'
|
|
31
31
|
app
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
# ).each{|f| require "rad/configurators/#{f}"}
|
|
6
6
|
|
|
7
7
|
class Micon::Core
|
|
8
|
-
def configure configurator_name, dir, &block
|
|
9
|
-
configurator_class = "Rad::Configurators::#{configurator_name.to_s.classify}".constantize
|
|
8
|
+
def configure configurator_name, dir, &block
|
|
9
|
+
configurator_class = "Rad::Configurators::#{configurator_name.to_s.classify}".constantize
|
|
10
10
|
configurator = configurator_class.new dir
|
|
11
11
|
block.call configurator if block
|
|
12
12
|
end
|
|
@@ -4,21 +4,21 @@ class Abstract
|
|
|
4
4
|
def initialize dir
|
|
5
5
|
@dir = File.expand_path(dir)
|
|
6
6
|
end
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
# def config options = {}
|
|
9
9
|
# rad.config.merge_config! "#{dir}/config/config.yml", options
|
|
10
10
|
# end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
def routes
|
|
13
13
|
routes_file = "#{dir}/config/routes.rb"
|
|
14
14
|
load routes_file if File.exist? routes_file
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
def locales
|
|
18
18
|
I18n.load_path += Dir["#{dir}/config/locales/**/*.{rb,yml}"]
|
|
19
19
|
I18n.load_path += Dir["#{dir}/config/locales/*.{rb,yml}"]
|
|
20
20
|
end
|
|
21
|
-
|
|
22
|
-
protected
|
|
21
|
+
|
|
22
|
+
protected
|
|
23
23
|
attr_reader :dir #, :after_config, :after_environment
|
|
24
24
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
rad.configurators
|
|
2
2
|
|
|
3
|
-
class Web < Abstract
|
|
3
|
+
class Web < Abstract
|
|
4
4
|
def asset_paths *relative_paths
|
|
5
5
|
relative_paths = relative_paths.first if relative_paths.first.is_a? Array
|
|
6
6
|
relative_paths.each do |relative_path|
|
|
@@ -8,7 +8,7 @@ class Web < Abstract
|
|
|
8
8
|
rad.assets.paths << path unless rad.assets.paths.include? path
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
def load_paths *relative_paths
|
|
13
13
|
relative_paths = relative_paths.first if relative_paths.first.is_a? Array
|
|
14
14
|
relative_paths.each do |relative_path|
|
|
@@ -16,19 +16,19 @@ class Web < Abstract
|
|
|
16
16
|
$LOAD_PATH << path unless $LOAD_PATH.include? path
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def template_paths *relative_paths
|
|
21
21
|
rad.template
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
relative_paths = relative_paths.first if relative_paths.first.is_a? Array
|
|
24
24
|
relative_paths.each do |relative_path|
|
|
25
25
|
path = "#{dir}/#{relative_path}"
|
|
26
26
|
rad.template.paths << path unless rad.template.paths.include? path
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
def autoload_paths *relative_paths
|
|
31
|
-
relative_paths = relative_paths.first if relative_paths.first.is_a? Array
|
|
32
|
-
relative_paths.each{|d|
|
|
33
|
-
end
|
|
31
|
+
relative_paths = relative_paths.first if relative_paths.first.is_a? Array
|
|
32
|
+
relative_paths.each{|d| autoload_path "#{dir}/#{d}", true}
|
|
33
|
+
end
|
|
34
34
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Rad::Controller::Abstract
|
|
2
|
-
inherit OpenConstructor
|
|
2
|
+
inherit RubyExt::OpenConstructor
|
|
3
3
|
inherit Rad::Filters
|
|
4
4
|
inherit Rad::Controller::Abstract::Render, Rad::Controller::Abstract::Miscellaneous
|
|
5
5
|
|
|
@@ -7,13 +7,14 @@ module Rad::Controller::Abstract
|
|
|
7
7
|
|
|
8
8
|
attr_accessor :action_name
|
|
9
9
|
attr_required :action_name
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
attr_writer :params
|
|
12
12
|
def params; @params ||= Rad::Conveyors::Params.new end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def call action, *args
|
|
15
|
+
action.must_be.a Symbol
|
|
15
16
|
catch :halt do
|
|
16
|
-
run_callbacks :action, method: action do
|
|
17
|
+
run_callbacks :action, method: action do
|
|
17
18
|
send action, *args
|
|
18
19
|
render action: action
|
|
19
20
|
end
|
|
@@ -22,24 +23,24 @@ module Rad::Controller::Abstract
|
|
|
22
23
|
|
|
23
24
|
module ClassMethods
|
|
24
25
|
inject workspace: :workspace, logger: :logger
|
|
25
|
-
|
|
26
|
-
def controller_name
|
|
27
|
-
self.namespace ? "#{self.namespace.name}::#{self.alias}" : self.alias
|
|
28
|
-
end
|
|
26
|
+
|
|
27
|
+
def controller_name
|
|
28
|
+
self.namespace ? "#{self.namespace.name}::#{self.alias}" : self.alias
|
|
29
|
+
end
|
|
29
30
|
|
|
30
31
|
def helper *args
|
|
31
|
-
args.to_a.each do |mod|
|
|
32
|
+
args.to_a.each do |mod|
|
|
32
33
|
mod.must_be.a Module
|
|
33
34
|
context_class.inherit mod
|
|
34
|
-
end
|
|
35
|
+
end
|
|
35
36
|
end
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
def helper_method *args
|
|
38
39
|
args = args.first if args.size == 1 and args.first.is_a?(Array)
|
|
39
40
|
# args.each{|m| m.to_s.must_be.in self.instance_methods}
|
|
40
|
-
args.each do |m|
|
|
41
|
+
args.each do |m|
|
|
41
42
|
context_class.delegate m, to: :controller
|
|
42
|
-
end
|
|
43
|
+
end
|
|
43
44
|
end
|
|
44
|
-
end
|
|
45
|
+
end
|
|
45
46
|
end
|