RubyApp 0.0.8 → 0.0.9
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/.gitignore +3 -3
- data/Gemfile.lock +1 -1
- data/features/default.feature +2 -2
- data/features/elements/button.feature +9 -0
- data/features/{dialog.feature → elements/dialog.feature} +19 -13
- data/features/elements/input.feature +20 -0
- data/features/elements/link.feature +9 -0
- data/features/elements/list.feature +19 -0
- data/features/elements/markdown.feature +9 -0
- data/features/elements/page.feature +10 -0
- data/features/elements/pages/exception_page.feature +10 -0
- data/features/step_definitions/default_macros.rb +1 -1
- data/features/step_definitions/default_steps.rb +7 -3
- data/features/support/env.rb +1 -1
- data/lib/ruby_app/application.rb +16 -41
- data/lib/ruby_app/configuration.rb +9 -17
- data/lib/ruby_app/element.rb +27 -23
- data/lib/ruby_app/elements/base/base_page.js.haml +1 -1
- data/lib/ruby_app/elements/base/base_page.rb +5 -5
- data/lib/ruby_app/elements/list.js.haml +1 -1
- data/lib/ruby_app/elements/list.rb +5 -5
- data/lib/ruby_app/elements/lists/select.js.haml +1 -1
- data/lib/ruby_app/elements/lists/select.rb +1 -3
- data/lib/ruby_app/elements/markdown.js.haml +1 -1
- data/lib/ruby_app/elements/markdown.rb +5 -5
- data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.js.haml +1 -1
- data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.rb +3 -3
- data/lib/ruby_app/elements/navigation/page_link.js.haml +1 -1
- data/lib/ruby_app/elements/navigation/page_link.rb +3 -3
- data/lib/ruby_app/elements/navigation/page_menu.js.haml +1 -1
- data/lib/ruby_app/elements/navigation/page_menu.rb +3 -3
- data/lib/ruby_app/elements/pages/authentication/open_id/authentication_page.rb +2 -2
- data/lib/ruby_app/elements/pages/authentication/open_id/ax_authentication_page.rb +2 -2
- data/lib/ruby_app/elements/pages/authentication/open_id/google_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/authentication/open_id/my_open_id_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/authentication/open_id/yahoo_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/default_page.rb +1 -1
- data/lib/ruby_app/elements/pages/exception_page.html.haml +0 -2
- data/lib/ruby_app/elements/pages/settings_page.rb +2 -2
- data/lib/ruby_app/elements/pages/test_pages/button_test_page.css.haml +3 -0
- data/lib/ruby_app/elements/pages/test_pages/button_test_page.html.haml +7 -0
- data/lib/ruby_app/elements/pages/test_pages/button_test_page.js.haml +3 -0
- data/lib/ruby_app/elements/pages/test_pages/button_test_page.rb +39 -0
- data/lib/ruby_app/elements/pages/test_pages/default_test_page.rb +8 -15
- data/lib/ruby_app/elements/pages/test_pages/dialog_test_page.rb +1 -1
- data/lib/ruby_app/elements/pages/test_pages/exception_test_page.html.haml +5 -0
- data/lib/ruby_app/elements/pages/test_pages/exception_test_page.rb +33 -0
- data/lib/ruby_app/elements/pages/test_pages/input_test_page.css.haml +1 -0
- data/lib/ruby_app/elements/pages/test_pages/input_test_page.html.haml +3 -0
- data/lib/ruby_app/elements/pages/test_pages/input_test_page.js.haml +1 -0
- data/lib/ruby_app/elements/pages/test_pages/input_test_page.rb +2 -0
- data/lib/ruby_app/elements/pages/test_pages/link_test_page.css.haml +3 -0
- data/lib/ruby_app/elements/pages/test_pages/link_test_page.html.haml +7 -0
- data/lib/ruby_app/elements/pages/test_pages/link_test_page.js.haml +3 -0
- data/lib/ruby_app/elements/pages/test_pages/link_test_page.rb +39 -0
- data/lib/ruby_app/elements/pages/test_pages/linked_test_page.css.haml +2 -0
- data/lib/ruby_app/elements/pages/test_pages/linked_test_page.html.haml +5 -0
- data/lib/ruby_app/elements/pages/test_pages/linked_test_page.js.haml +2 -0
- data/lib/ruby_app/elements/pages/test_pages/linked_test_page.rb +30 -0
- data/lib/ruby_app/elements/pages/test_pages/list_test_page.css.haml +1 -0
- data/lib/ruby_app/elements/pages/test_pages/list_test_page.html.haml +2 -1
- data/lib/ruby_app/elements/pages/test_pages/list_test_page.js.haml +1 -0
- data/lib/ruby_app/elements/pages/test_pages/list_test_page.rb +16 -11
- data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.css.haml +2 -0
- data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.html.haml +5 -0
- data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.js.haml +2 -0
- data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.rb +38 -0
- data/lib/ruby_app/elements/pages/test_pages/select_test_page.rb +44 -0
- data/lib/ruby_app/elements/pages/test_pages/test_page.html.haml +14 -0
- data/lib/ruby_app/elements/pages/test_pages/test_page.rb +42 -0
- data/lib/ruby_app/language.rb +9 -12
- data/lib/ruby_app/log.rb +19 -9
- data/lib/ruby_app/mixins/{configuration.rb → configure_mixin.rb} +2 -2
- data/lib/ruby_app/mixins/{delegate.rb → delegate_mixin.rb} +1 -1
- data/lib/ruby_app/mixins/{hash.rb → hash_mixin.rb} +5 -1
- data/lib/ruby_app/mixins/{render.rb → render_mixin.rb} +2 -2
- data/lib/ruby_app/mixins/{route.rb → route_mixin.rb} +5 -5
- data/lib/ruby_app/mixins/{template.rb → template_mixin.rb} +11 -11
- data/lib/ruby_app/mixins/{translate.rb → translate_mixin.rb} +1 -1
- data/lib/ruby_app/rack/application.rb +3 -3
- data/lib/ruby_app/rack/route.rb +14 -30
- data/lib/ruby_app/request.rb +36 -13
- data/lib/ruby_app/session.rb +17 -23
- data/lib/ruby_app/translations/en.yml +77 -15
- data/lib/ruby_app/version.rb +1 -1
- data/rakefile +1 -12
- data/spec/application_spec.rb +25 -0
- data/spec/configuration_spec.rb +25 -0
- data/spec/element_spec.rb +54 -5
- data/spec/elements/navigation/breadcrumbs_spec.rb +17 -25
- data/spec/elements/page_spec.rb +2 -13
- data/spec/language_spec.rb +25 -0
- data/spec/log_spec.rb +25 -0
- data/spec/mixins/configure_mixin_spec.rb +24 -0
- data/spec/mixins/delegate_mixin_spec.rb +28 -0
- data/spec/mixins/hash_mixin_spec.rb +39 -0
- data/spec/mixins/render_mixin_spec.rb +127 -0
- data/spec/mixins/route_mixin_spec.rb +60 -0
- data/spec/mixins/{template_spec.rb → template_mixin_spec.rb} +3 -3
- data/spec/mixins/test_a.css.haml +4 -3
- data/spec/mixins/test_a.html.haml +0 -1
- data/spec/mixins/test_a.js.haml +4 -3
- data/spec/mixins/test_b.css.haml +4 -4
- data/spec/mixins/test_b.js.haml +2 -2
- data/spec/mixins/test_c.css.haml +4 -4
- data/spec/mixins/test_c.js.haml +2 -2
- data/spec/mixins/translate_mixin_spec.rb +25 -0
- data/spec/request_spec.rb +25 -0
- data/spec/session_spec.rb +39 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/shared.rb +19 -5
- metadata +75 -38
- data/features/breadcrumbs.feature +0 -11
- data/features/content.feature +0 -16
- data/features/exception.feature +0 -53
- data/features/input.feature +0 -13
- data/features/list.feature +0 -12
- data/features/month.feature +0 -14
- data/spec/mixins/render_spec.rb +0 -191
- data/spec/mixins/route_spec.rb +0 -60
- data/spec/mixins/test_e.html.haml +0 -2
- data/spec/mixins/test_f.html.haml +0 -2
- data/spec/mixins/test_g.css.haml +0 -4
data/lib/ruby_app/log.rb
CHANGED
@@ -1,25 +1,35 @@
|
|
1
1
|
require 'logger'
|
2
2
|
|
3
3
|
module RubyApp
|
4
|
-
require 'ruby_app/
|
4
|
+
require 'ruby_app/application'
|
5
|
+
require 'ruby_app/mixins/delegate_mixin'
|
5
6
|
|
6
7
|
class Log < ::Logger
|
7
|
-
extend RubyApp::Mixins::
|
8
|
+
extend RubyApp::Mixins::DelegateMixin
|
9
|
+
|
10
|
+
def exception(exception)
|
11
|
+
self.error('-' * 80)
|
12
|
+
self.error("exception=#{exception.class.inspect} #{exception.message}")
|
13
|
+
self.error('-' * 80)
|
14
|
+
self.error(exception.backtrace.join("\n"))
|
15
|
+
self.error('-' * 80)
|
16
|
+
end
|
8
17
|
|
9
18
|
def self.get
|
10
|
-
@@
|
19
|
+
@@_log
|
11
20
|
end
|
12
21
|
|
13
|
-
def self.open
|
22
|
+
def self.open!
|
23
|
+
path = RubyApp::Application.options.log_path
|
14
24
|
directory = File.dirname(path)
|
15
25
|
Dir.mkdir(directory) unless File.exists?(directory)
|
16
|
-
@@
|
17
|
-
@@
|
26
|
+
@@_log = RubyApp::Log.new(path)
|
27
|
+
@@_log.debug("#{self}##{__method__} path=#{path.inspect}")
|
18
28
|
end
|
19
29
|
|
20
|
-
def self.close
|
21
|
-
@@
|
22
|
-
@@
|
30
|
+
def self.close!
|
31
|
+
@@_log.close if @@_log
|
32
|
+
@@_log = nil
|
23
33
|
end
|
24
34
|
|
25
35
|
private
|
@@ -2,10 +2,10 @@ module RubyApp
|
|
2
2
|
|
3
3
|
module Mixins
|
4
4
|
|
5
|
-
module
|
5
|
+
module ConfigureMixin
|
6
6
|
require 'ruby_app/configuration'
|
7
7
|
|
8
|
-
def
|
8
|
+
def configure
|
9
9
|
|
10
10
|
name = self.is_a?(Class) ? self.to_s : self.class.to_s
|
11
11
|
name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
@@ -8,11 +8,11 @@ module RubyApp
|
|
8
8
|
|
9
9
|
module Mixins
|
10
10
|
|
11
|
-
module
|
11
|
+
module RenderMixin
|
12
12
|
require 'ruby_app/log'
|
13
13
|
|
14
14
|
def rendered?(template)
|
15
|
-
unless Thread.current[:_rendered].key?(template)
|
15
|
+
unless ( Thread.current[:_rendered] ||= {} ).key?(template)
|
16
16
|
yield
|
17
17
|
Thread.current[:_rendered][template] = ( Thread.current[:_rendered][template] || 0 ) + 1
|
18
18
|
end
|
@@ -4,10 +4,10 @@ require 'bundler/setup'
|
|
4
4
|
require 'mime/types'
|
5
5
|
|
6
6
|
module RubyApp
|
7
|
-
|
7
|
+
|
8
8
|
module Mixins
|
9
|
-
|
10
|
-
module
|
9
|
+
|
10
|
+
module RouteMixin
|
11
11
|
|
12
12
|
GET = 'GET'
|
13
13
|
POST = 'POST'
|
@@ -15,7 +15,7 @@ module RubyApp
|
|
15
15
|
def route(method, pattern, &block)
|
16
16
|
self.routes << { :method => method, :pattern => pattern, :block => block }
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def do_route(method, path)
|
20
20
|
self.routes.each do |route|
|
21
21
|
if method == route[:method] and path =~ route[:pattern]
|
@@ -23,7 +23,7 @@ module RubyApp
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def routes
|
28
28
|
@_routes ||= []
|
29
29
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module RubyApp
|
2
|
-
|
2
|
+
|
3
3
|
module Mixins
|
4
|
-
|
5
|
-
module
|
6
|
-
|
4
|
+
|
5
|
+
module TemplateMixin
|
6
|
+
|
7
7
|
def template_name
|
8
8
|
|
9
9
|
name = self.to_s.split('::').last
|
@@ -13,26 +13,26 @@ module RubyApp
|
|
13
13
|
name.downcase
|
14
14
|
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def template_path(format, path)
|
18
18
|
(@_template_path ||= {})[format] = File.directory?(path) ? "#{File.join(path, self.template_name)}.*.haml" : path
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def exclude_parent_template?(format)
|
22
22
|
( @_exclude_parent_template_formats ||= [] ).include?(:all) || @_exclude_parent_template_formats.include?(format)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def exclude_parent_template(*formats)
|
26
26
|
@_exclude_parent_template_formats = formats
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def get_templates(format)
|
30
30
|
templates = Dir.glob((@_template_path[format] || @_template_path[:all] || "#{File.join(File.dirname(__FILE__), self.template_name)}.*.haml").gsub(/\*/,format.to_s))
|
31
31
|
( templates.length > 0 ? [templates.first] : [] ).concat( ( !self.exclude_parent_template?(format) and self.superclass.respond_to?(:get_templates) ) ? self.superclass.get_templates(format) : [] )
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
end
|
@@ -2,17 +2,17 @@ module RubyApp
|
|
2
2
|
|
3
3
|
module Rack
|
4
4
|
require 'ruby_app/application'
|
5
|
-
require 'ruby_app/
|
5
|
+
require 'ruby_app/request'
|
6
6
|
|
7
7
|
class Application
|
8
8
|
|
9
9
|
def initialize(application, options = {})
|
10
10
|
@application = application
|
11
|
-
RubyApp::Application.create(options)
|
11
|
+
RubyApp::Application.create!(options)
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(environment)
|
15
|
-
RubyApp::
|
15
|
+
RubyApp::Request.create!(environment) do
|
16
16
|
return @application.call(environment)
|
17
17
|
end
|
18
18
|
end
|
data/lib/ruby_app/rack/route.rb
CHANGED
@@ -12,17 +12,17 @@ module RubyApp
|
|
12
12
|
require 'ruby_app/elements/pages/exception_page'
|
13
13
|
require 'ruby_app/elements/pages/quit_page'
|
14
14
|
require 'ruby_app/log'
|
15
|
-
require 'ruby_app/mixins/
|
15
|
+
require 'ruby_app/mixins/route_mixin'
|
16
16
|
require 'ruby_app/request'
|
17
17
|
|
18
18
|
class Route
|
19
|
-
extend RubyApp::Mixins::
|
19
|
+
extend RubyApp::Mixins::RouteMixin
|
20
20
|
|
21
21
|
def call(environment)
|
22
22
|
self.class.do_route(RubyApp::Request.request_method, RubyApp::Request.path)
|
23
23
|
end
|
24
24
|
|
25
|
-
route(RubyApp::Mixins::
|
25
|
+
route(RubyApp::Mixins::RouteMixin::GET, /\/quit/) do |method, path|
|
26
26
|
RubyApp::Log.debug("#{self}.route method=#{method.inspect} path=#{path.inspect}")
|
27
27
|
begin
|
28
28
|
[
|
@@ -31,11 +31,7 @@ module RubyApp
|
|
31
31
|
[ RubyApp::Elements::Pages::QuitPage.new.render(:html) ]
|
32
32
|
]
|
33
33
|
rescue Exception => exception
|
34
|
-
RubyApp::Log.
|
35
|
-
RubyApp::Log.error("exception=#{exception.class.inspect} #{exception.message}")
|
36
|
-
RubyApp::Log.error('-' * 80)
|
37
|
-
RubyApp::Log.error(exception.backtrace.join("\n"))
|
38
|
-
RubyApp::Log.error('-' * 80)
|
34
|
+
RubyApp::Log.exception(exception)
|
39
35
|
[
|
40
36
|
200,
|
41
37
|
{ 'content-type' => 'text/html' },
|
@@ -44,7 +40,7 @@ module RubyApp
|
|
44
40
|
end
|
45
41
|
end
|
46
42
|
|
47
|
-
route(RubyApp::Mixins::
|
43
|
+
route(RubyApp::Mixins::RouteMixin::GET, /\/elements\/([^\.]+)\.([^\.\?]+)/) do |method, path, element_id, format|
|
48
44
|
RubyApp::Log.debug("#{self}.route method=#{method.inspect} path=#{path.inspect} element_id=#{element_id.inspect} format=#{format.to_sym.inspect}")
|
49
45
|
begin
|
50
46
|
[
|
@@ -53,11 +49,7 @@ module RubyApp
|
|
53
49
|
[ RubyApp::Element.get_element(element_id).render(format.to_sym) ]
|
54
50
|
]
|
55
51
|
rescue Exception => exception
|
56
|
-
RubyApp::Log.
|
57
|
-
RubyApp::Log.error("exception=#{exception.class.inspect} #{exception.message}")
|
58
|
-
RubyApp::Log.error('-' * 80)
|
59
|
-
RubyApp::Log.error(exception.backtrace.join("\n"))
|
60
|
-
RubyApp::Log.error('-' * 80)
|
52
|
+
RubyApp::Log.exception(exception)
|
61
53
|
[
|
62
54
|
200,
|
63
55
|
{ 'content-type' => RubyApp::Rack::Route.get_content_type(format) },
|
@@ -66,7 +58,7 @@ module RubyApp
|
|
66
58
|
end
|
67
59
|
end
|
68
60
|
|
69
|
-
route(RubyApp::Mixins::
|
61
|
+
route(RubyApp::Mixins::RouteMixin::GET, /\.([^\.\?]+)/) do |method, path, format|
|
70
62
|
RubyApp::Log.debug("#{self}.route method=#{method.inspect} path=#{path.inspect} format=#{format.to_sym.inspect}")
|
71
63
|
begin
|
72
64
|
[
|
@@ -75,11 +67,7 @@ module RubyApp
|
|
75
67
|
[ RubyApp::Session.pages.last.render(format.to_sym) ]
|
76
68
|
]
|
77
69
|
rescue Exception => exception
|
78
|
-
RubyApp::Log.
|
79
|
-
RubyApp::Log.error("exception=#{exception.class.inspect} #{exception.message}")
|
80
|
-
RubyApp::Log.error('-' * 80)
|
81
|
-
RubyApp::Log.error(exception.backtrace.join("\n"))
|
82
|
-
RubyApp::Log.error('-' * 80)
|
70
|
+
RubyApp::Log.exception(exception)
|
83
71
|
[
|
84
72
|
200,
|
85
73
|
{ 'content-type' => RubyApp::Rack::Route.get_content_type(format) },
|
@@ -88,31 +76,27 @@ module RubyApp
|
|
88
76
|
end
|
89
77
|
end
|
90
78
|
|
91
|
-
route(RubyApp::Mixins::
|
79
|
+
route(RubyApp::Mixins::RouteMixin::GET, /.*/) do |method, path|
|
92
80
|
RubyApp::Log.debug("#{self}.route method=#{method.inspect} path=#{path.inspect}")
|
93
|
-
do_route(RubyApp::Mixins::
|
81
|
+
do_route(RubyApp::Mixins::RouteMixin::GET, '/.html')
|
94
82
|
end
|
95
83
|
|
96
|
-
route(RubyApp::Mixins::
|
84
|
+
route(RubyApp::Mixins::RouteMixin::POST, /.*/) do |method, path|
|
97
85
|
RubyApp::Log.debug("#{self}.post(...) method=#{method.inspect} path=#{path.inspect} POST=#{RubyApp::Request.POST.inspect}")
|
98
86
|
begin
|
99
87
|
event = RubyApp::Element::Event.from_hash(RubyApp::Request.POST)
|
100
|
-
|
88
|
+
event.process!
|
101
89
|
[
|
102
90
|
200,
|
103
91
|
{ 'content-type' => 'application/json' },
|
104
92
|
[ Yajl::Encoder.new.encode(event.to_hash) ]
|
105
93
|
]
|
106
94
|
rescue Exception => exception
|
107
|
-
RubyApp::Log.
|
108
|
-
RubyApp::Log.error("exception=#{exception.class.inspect} #{exception.message}")
|
109
|
-
RubyApp::Log.error('-' * 80)
|
110
|
-
RubyApp::Log.error(exception.backtrace.join("\n"))
|
111
|
-
RubyApp::Log.error('-' * 80)
|
95
|
+
RubyApp::Log.exception(exception)
|
112
96
|
[
|
113
97
|
200,
|
114
98
|
{ 'content-type' => 'application/json' },
|
115
|
-
[ Yajl::Encoder.new.encode(RubyApp::Element::ExceptionEvent.new(exception).to_hash) ]
|
99
|
+
[ Yajl::Encoder.new.encode(RubyApp::Element::ExceptionEvent.new(RubyApp::Request.POST, exception).to_hash) ]
|
116
100
|
]
|
117
101
|
end
|
118
102
|
end
|
data/lib/ruby_app/request.rb
CHANGED
@@ -5,41 +5,64 @@ require 'rack'
|
|
5
5
|
|
6
6
|
module RubyApp
|
7
7
|
require 'ruby_app/application'
|
8
|
-
require 'ruby_app/
|
8
|
+
require 'ruby_app/language'
|
9
|
+
require 'ruby_app/mixins/delegate_mixin'
|
10
|
+
require 'ruby_app/mixins/render_mixin'
|
11
|
+
require 'ruby_app/session'
|
9
12
|
|
10
13
|
class Request < ::Rack::Request
|
11
|
-
extend RubyApp::Mixins::
|
14
|
+
extend RubyApp::Mixins::DelegateMixin
|
12
15
|
|
13
|
-
def
|
14
|
-
self.
|
16
|
+
def language
|
17
|
+
self.fullpath =~ /^\/([^\/\?]+)/
|
18
|
+
$1 || RubyApp::Application.options.default_language
|
15
19
|
end
|
16
20
|
|
17
21
|
def query
|
18
22
|
::Rack::Utils.parse_query(self.query_string)
|
19
23
|
end
|
20
24
|
|
21
|
-
def
|
22
|
-
self.
|
23
|
-
$1
|
25
|
+
def parameters
|
26
|
+
self.params
|
24
27
|
end
|
25
28
|
|
26
29
|
def self.get
|
27
30
|
Thread.current[:_request]
|
28
31
|
end
|
29
32
|
|
30
|
-
def self.create(environment)
|
31
|
-
|
32
|
-
Thread.current[:
|
33
|
+
def self.create!(environment = RubyApp::Application.environment)
|
34
|
+
Thread.current[:_request] = RubyApp::Request.new(environment)
|
35
|
+
Thread.current[:_rendered] = {}
|
36
|
+
|
33
37
|
if block_given?
|
34
38
|
begin
|
35
|
-
|
39
|
+
RubyApp::Language.load! do
|
40
|
+
RubyApp::Session.create! do
|
41
|
+
return yield
|
42
|
+
end
|
43
|
+
end
|
36
44
|
ensure
|
37
|
-
|
45
|
+
self.destroy!
|
46
|
+
end
|
47
|
+
else
|
48
|
+
begin
|
49
|
+
RubyApp::Language.load!
|
50
|
+
begin
|
51
|
+
RubyApp::Session.create!
|
52
|
+
rescue
|
53
|
+
RubyApp::Language.unload!
|
54
|
+
raise
|
55
|
+
end
|
56
|
+
rescue
|
57
|
+
self.destroy!
|
58
|
+
raise
|
38
59
|
end
|
39
60
|
end
|
61
|
+
|
40
62
|
end
|
41
63
|
|
42
|
-
def self.destroy
|
64
|
+
def self.destroy!
|
65
|
+
Thread.current[:_rendered] = nil
|
43
66
|
Thread.current[:_request] = nil
|
44
67
|
end
|
45
68
|
|
data/lib/ruby_app/session.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
module RubyApp
|
2
|
-
require 'ruby_app/
|
3
|
-
require 'ruby_app/mixins/
|
4
|
-
require 'ruby_app/mixins/
|
2
|
+
require 'ruby_app/application'
|
3
|
+
require 'ruby_app/mixins/configure_mixin'
|
4
|
+
require 'ruby_app/mixins/delegate_mixin'
|
5
|
+
require 'ruby_app/mixins/translate_mixin'
|
5
6
|
require 'ruby_app/request'
|
6
7
|
|
7
8
|
class Session
|
8
|
-
extend RubyApp::Mixins::
|
9
|
-
include RubyApp::Mixins::
|
10
|
-
|
11
|
-
|
12
|
-
extend RubyApp::Mixins::Translate
|
9
|
+
extend RubyApp::Mixins::DelegateMixin
|
10
|
+
include RubyApp::Mixins::HashMixin
|
11
|
+
include RubyApp::Mixins::ConfigureMixin
|
12
|
+
extend RubyApp::Mixins::TranslateMixin
|
13
13
|
|
14
14
|
class Identity
|
15
|
-
include RubyApp::Mixins::
|
15
|
+
include RubyApp::Mixins::HashMixin
|
16
16
|
|
17
17
|
attr_reader :url
|
18
18
|
|
@@ -27,12 +27,12 @@ module RubyApp
|
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
|
-
attr_reader :pages
|
31
|
-
attr_accessor :identity
|
30
|
+
attr_reader :pages
|
31
|
+
attr_accessor :identity, :data
|
32
32
|
|
33
33
|
def initialize(page = nil)
|
34
34
|
require 'ruby_app/elements/pages/default_page'
|
35
|
-
@pages = [page || RubyApp::Elements::Pages::DefaultPage.new]
|
35
|
+
@pages = [ page || RubyApp::Elements::Pages::DefaultPage.new ]
|
36
36
|
@dialogs = []
|
37
37
|
@identity = nil
|
38
38
|
@data = {}
|
@@ -67,10 +67,6 @@ module RubyApp
|
|
67
67
|
|
68
68
|
end
|
69
69
|
|
70
|
-
def process(event)
|
71
|
-
event.source.send(:on_event, event)
|
72
|
-
end
|
73
|
-
|
74
70
|
def quit
|
75
71
|
RubyApp::Request.env['rack.session.options'][:drop] = true
|
76
72
|
end
|
@@ -79,20 +75,18 @@ module RubyApp
|
|
79
75
|
Thread.current[:_session]
|
80
76
|
end
|
81
77
|
|
82
|
-
def self.create
|
83
|
-
|
84
|
-
RubyApp::Request.session[:_session] = session
|
85
|
-
Thread.current[:_session] = session
|
78
|
+
def self.create!
|
79
|
+
Thread.current[:_session] = RubyApp::Request.session[:_session] ||= RubyApp::Application.options.session_class.new
|
86
80
|
if block_given?
|
87
81
|
begin
|
88
|
-
yield
|
82
|
+
yield
|
89
83
|
ensure
|
90
|
-
|
84
|
+
self.destroy!
|
91
85
|
end
|
92
86
|
end
|
93
87
|
end
|
94
88
|
|
95
|
-
def self.destroy
|
89
|
+
def self.destroy!
|
96
90
|
Thread.current[:_session] = nil
|
97
91
|
end
|
98
92
|
|