RubyApp 0.0.91 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/.rvmrc +56 -1
- data/Gemfile.lock +22 -22
- data/bin/console.rb +9 -1
- data/bin/ruby_app +2 -24
- data/features/default.feature +1 -0
- data/features/elements/input.feature +2 -0
- data/features/elements/page.feature +0 -9
- data/features/step_definitions/default_macros.rb +1 -4
- data/features/step_definitions/default_steps.rb +1 -1
- data/lib/ruby_app.rb +8 -1
- data/lib/ruby_app/application.rb +5 -67
- data/lib/ruby_app/configuration.rb +2 -3
- data/lib/ruby_app/configuration.ru +32 -0
- data/lib/ruby_app/configuration.yml +28 -0
- data/lib/ruby_app/element.rb +12 -6
- data/lib/ruby_app/elements.rb +50 -0
- data/lib/ruby_app/elements/base/base_mail.rb +2 -2
- data/lib/ruby_app/elements/base/base_page.html.haml +1 -1
- data/lib/ruby_app/elements/base/base_page.js.haml +3 -3
- data/lib/ruby_app/elements/base/base_page.rb +2 -2
- data/lib/ruby_app/elements/dialogs/base/base_ok_dialog.rb +0 -1
- data/lib/ruby_app/elements/dialogs/blank_dialog.rb +1 -1
- data/lib/ruby_app/elements/dialogs/exception_dialog.rb +1 -2
- data/lib/ruby_app/elements/navigation/back_button.rb +1 -1
- data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.rb +1 -0
- data/lib/ruby_app/elements/navigation/page_link.rb +1 -0
- data/lib/ruby_app/elements/pages/authentication/open_id/ax_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/authentication/open_id/base/base_authentication_page.rb +1 -3
- data/lib/ruby_app/elements/pages/authentication/open_id/email_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/authentication/open_id/sreg_authentication_page.rb +1 -1
- data/lib/ruby_app/elements/pages/base/base_blank_page.rb +0 -1
- data/lib/ruby_app/elements/pages/default_page.rb +2 -1
- data/lib/ruby_app/elements/pages/quit_page.html.haml +0 -3
- data/lib/ruby_app/elements/pages/quit_page.rb +0 -2
- data/lib/ruby_app/elements/pages/settings_page.rb +2 -1
- data/lib/ruby_app/elements/pages/test_pages.rb +9 -0
- data/lib/ruby_app/elements/pages/test_pages/button_test_page.rb +3 -5
- data/lib/ruby_app/elements/pages/test_pages/default_test_page.rb +10 -15
- data/lib/ruby_app/elements/pages/test_pages/dialog_test_page.rb +2 -8
- data/lib/ruby_app/elements/pages/test_pages/input_test_page.rb +2 -9
- data/lib/ruby_app/elements/pages/test_pages/link_test_page.rb +3 -5
- data/lib/ruby_app/elements/pages/test_pages/linked_test_page.rb +1 -2
- data/lib/ruby_app/elements/pages/test_pages/list_test_page.rb +4 -8
- data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.rb +3 -4
- data/lib/ruby_app/elements/pages/test_pages/test_page.rb +3 -8
- data/lib/ruby_app/exceptions.rb +2 -0
- data/lib/ruby_app/exceptions/base/base_exception.rb +1 -1
- data/lib/ruby_app/language.rb +9 -15
- data/lib/ruby_app/log.rb +32 -28
- data/lib/ruby_app/mixins.rb +7 -0
- data/lib/ruby_app/mixins/configuration_mixin.rb +1 -1
- data/lib/ruby_app/mixins/delegate_mixin.rb +1 -1
- data/lib/ruby_app/mixins/hash_mixin.rb +1 -1
- data/lib/ruby_app/mixins/render_mixin.rb +37 -39
- data/lib/ruby_app/mixins/route_mixin.rb +1 -5
- data/lib/ruby_app/mixins/template_mixin.rb +4 -12
- data/lib/ruby_app/mixins/translate_mixin.rb +2 -2
- data/lib/ruby_app/rack.rb +8 -0
- data/lib/ruby_app/rack/application.rb +9 -5
- data/lib/ruby_app/rack/duration.rb +22 -0
- data/lib/ruby_app/rack/language.rb +26 -0
- data/lib/ruby_app/rack/memory.rb +22 -0
- data/lib/ruby_app/rack/request.rb +27 -0
- data/lib/ruby_app/rack/response.rb +26 -0
- data/lib/ruby_app/rack/route.rb +24 -87
- data/lib/ruby_app/rack/session.rb +31 -0
- data/lib/ruby_app/request.rb +4 -55
- data/lib/ruby_app/response.rb +58 -0
- data/lib/ruby_app/session.rb +102 -35
- data/lib/ruby_app/templates/application/Rakefile +1 -1
- data/lib/ruby_app/templates/application/configuration.ru +41 -0
- data/lib/ruby_app/templates/application/configuration.yml +16 -0
- data/lib/ruby_app/templates/application/console.rb +15 -10
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_.rb +3 -0
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_/application.rb +3 -3
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_/elements/pages/default_page.rb +1 -1
- data/lib/ruby_app/templates/application/lib/_APPLICATION_DOWNCODE_/session.rb +3 -3
- data/lib/ruby_app/templates/application/spec/application_spec.rb +17 -0
- data/lib/ruby_app/templates/application/spec/request_spec.rb +18 -0
- data/lib/ruby_app/templates/application/spec/support/shared.rb +34 -9
- data/lib/ruby_app/themes/mobile.rb +1 -17
- data/lib/ruby_app/themes/mobile/base/base_page.html.haml +1 -1
- data/lib/ruby_app/translations/en.yml +133 -144
- data/lib/ruby_app/version.rb +1 -1
- data/rakefile +1 -16
- data/spec/application_spec.rb +5 -13
- data/spec/elements/base_element.html.haml +5 -0
- data/spec/elements/container_element.html.haml +6 -0
- data/spec/elements/derived_element.html.haml +5 -0
- data/spec/elements/element_spec.rb +101 -0
- data/spec/request_spec.rb +6 -13
- data/spec/support/shared.rb +14 -6
- metadata +95 -125
- data/features/elements/pages/quit_page.feature +0 -8
- data/lib/ruby_app/config.ru +0 -25
- data/lib/ruby_app/config.yml +0 -16
- data/lib/ruby_app/elements/pages/test_pages/select_test_page.rb +0 -44
- data/lib/ruby_app/templates/application/config.ru +0 -40
- data/lib/ruby_app/templates/application/config.yml +0 -1
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.css.haml +0 -3
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.html.haml +0 -4
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.js.haml +0 -3
- data/lib/ruby_app/templates/page/_PAGE_DOWNCODE_.rb +0 -14
- data/spec/configuration_spec.rb +0 -25
- data/spec/element_spec.rb +0 -72
- data/spec/elements/navigation/breadcrumbs_spec.rb +0 -62
- data/spec/elements/page_spec.rb +0 -20
- data/spec/language_spec.rb +0 -25
- data/spec/log_spec.rb +0 -25
- data/spec/mixins/configuration_mixin_spec.rb +0 -24
- data/spec/mixins/delegate_mixin_spec.rb +0 -28
- data/spec/mixins/hash_mixin_spec.rb +0 -39
- data/spec/mixins/render_mixin_spec.rb +0 -127
- data/spec/mixins/route_mixin_spec.rb +0 -60
- data/spec/mixins/template_mixin_spec.rb +0 -78
- data/spec/mixins/test_a.css.haml +0 -4
- data/spec/mixins/test_a.html.haml +0 -2
- data/spec/mixins/test_a.js.haml +0 -4
- data/spec/mixins/test_b.css.haml +0 -4
- data/spec/mixins/test_b.html.haml +0 -3
- data/spec/mixins/test_b.js.haml +0 -4
- data/spec/mixins/test_c.css.haml +0 -4
- data/spec/mixins/test_c.html.haml +0 -2
- data/spec/mixins/test_c.js.haml +0 -4
- data/spec/mixins/translate_mixin_spec.rb +0 -25
- data/spec/session_spec.rb +0 -39
@@ -3,7 +3,7 @@ module RubyApp
|
|
3
3
|
module Mixins
|
4
4
|
|
5
5
|
module TranslateMixin
|
6
|
-
require 'ruby_app
|
6
|
+
require 'ruby_app'
|
7
7
|
|
8
8
|
def translate
|
9
9
|
|
@@ -25,7 +25,7 @@ module RubyApp
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def localize(*parameters)
|
28
|
-
RubyApp::Language.l(*parameters)
|
28
|
+
return RubyApp::Language.l(*parameters)
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'ruby_app/rack/application'
|
2
|
+
require 'ruby_app/rack/duration'
|
3
|
+
require 'ruby_app/rack/language'
|
4
|
+
require 'ruby_app/rack/memory'
|
5
|
+
require 'ruby_app/rack/request'
|
6
|
+
require 'ruby_app/rack/response'
|
7
|
+
require 'ruby_app/rack/session'
|
8
|
+
require 'ruby_app/rack/route'
|
@@ -1,20 +1,24 @@
|
|
1
1
|
module RubyApp
|
2
2
|
|
3
3
|
module Rack
|
4
|
-
require 'ruby_app
|
5
|
-
require 'ruby_app/log'
|
6
|
-
require 'ruby_app/request'
|
4
|
+
require 'ruby_app'
|
7
5
|
|
8
6
|
class Application
|
9
7
|
|
10
8
|
def initialize(application, options = {})
|
11
9
|
@application = application
|
12
|
-
RubyApp::
|
10
|
+
RubyApp::Configuration.load!(options[:configuration_paths])
|
11
|
+
RubyApp::Log.open!
|
12
|
+
RubyApp::Application.create!
|
13
|
+
RubyApp::Session.start_thread!
|
13
14
|
end
|
14
15
|
|
15
16
|
def call(environment)
|
16
|
-
|
17
|
+
begin
|
17
18
|
return @application.call(environment)
|
19
|
+
rescue Exception => exception
|
20
|
+
RubyApp::Log.exception(exception)
|
21
|
+
raise exception
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RubyApp
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
require 'ruby_app'
|
5
|
+
|
6
|
+
class Duration
|
7
|
+
|
8
|
+
def initialize(application)
|
9
|
+
@application = application
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(environment)
|
13
|
+
RubyApp::Log.duration(RubyApp::Log.prefix(self, __method__)) do
|
14
|
+
return @application.call(environment)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RubyApp
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
require 'ruby_app'
|
5
|
+
|
6
|
+
class Language
|
7
|
+
|
8
|
+
def initialize(application)
|
9
|
+
@application = application
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(environment)
|
13
|
+
RubyApp::Language.load!(RubyApp::Request.language)
|
14
|
+
begin
|
15
|
+
#RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} RubyApp::Language.locale.code=#{RubyApp::Language.locale.code.inspect}")
|
16
|
+
return @application.call(environment)
|
17
|
+
ensure
|
18
|
+
RubyApp::Language.unload!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RubyApp
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
require 'ruby_app'
|
5
|
+
|
6
|
+
class Memory
|
7
|
+
|
8
|
+
def initialize(application)
|
9
|
+
@application = application
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(environment)
|
13
|
+
RubyApp::Log.memory(RubyApp::Log.prefix(self, __method__)) do
|
14
|
+
return @application.call(environment)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RubyApp
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
|
5
|
+
class Request
|
6
|
+
require 'ruby_app'
|
7
|
+
|
8
|
+
def initialize(application)
|
9
|
+
@application = application
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(environment)
|
13
|
+
RubyApp::Request.create!(environment)
|
14
|
+
begin
|
15
|
+
#RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} RubyApp::Request.request_method=#{RubyApp::Request.request_method.inspect}")
|
16
|
+
#RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} RubyApp::Request.path=#{RubyApp::Request.path.inspect}")
|
17
|
+
return @application.call(environment)
|
18
|
+
ensure
|
19
|
+
RubyApp::Request.destroy!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RubyApp
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
|
5
|
+
class Response
|
6
|
+
require 'ruby_app'
|
7
|
+
|
8
|
+
def initialize(application)
|
9
|
+
@application = application
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(environment)
|
13
|
+
RubyApp::Response.create!
|
14
|
+
begin
|
15
|
+
@application.call(environment)
|
16
|
+
return RubyApp::Response.finish
|
17
|
+
ensure
|
18
|
+
RubyApp::Response.destroy!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/ruby_app/rack/route.rb
CHANGED
@@ -1,129 +1,66 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
-
require 'mime/types'
|
5
4
|
require 'yajl'
|
6
5
|
|
7
6
|
module RubyApp
|
8
7
|
|
9
8
|
module Rack
|
10
|
-
require 'ruby_app
|
11
|
-
require 'ruby_app/elements
|
12
|
-
require 'ruby_app/
|
13
|
-
require 'ruby_app/exceptions/session_invalid_exception'
|
14
|
-
require 'ruby_app/log'
|
15
|
-
require 'ruby_app/mixins/route_mixin'
|
16
|
-
require 'ruby_app/request'
|
17
|
-
require 'ruby_app/session'
|
9
|
+
require 'ruby_app'
|
10
|
+
require 'ruby_app/elements'
|
11
|
+
require 'ruby_app/mixins'
|
18
12
|
|
19
13
|
class Route
|
20
14
|
extend RubyApp::Mixins::RouteMixin
|
21
15
|
|
22
16
|
def call(environment)
|
23
|
-
|
17
|
+
RubyApp::Rack::Route.do_route(RubyApp::Request.request_method, RubyApp::Request.path)
|
24
18
|
end
|
25
19
|
|
26
20
|
route(RubyApp::Mixins::RouteMixin::GET, /\/quit/) do |method, path|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
'Cache-Control' => 'no-cache',
|
32
|
-
'Content-Type' => 'text/html'
|
33
|
-
},
|
34
|
-
[ RubyApp::Elements::Pages::QuitPage.new.render(:html) ]
|
35
|
-
]
|
36
|
-
rescue Exception => exception
|
37
|
-
RubyApp::Log.exception(exception)
|
38
|
-
raise exception
|
39
|
-
end
|
21
|
+
RubyApp::Log.debug("#{RubyApp::Session.session_id} GET /quit")
|
22
|
+
RubyApp::Session.quit!
|
23
|
+
RubyApp::Response['Content-Type'] = 'text/html'
|
24
|
+
RubyApp::Response.write(RubyApp::Elements::Pages::QuitPage.new.render(:html))
|
40
25
|
end
|
41
26
|
|
42
27
|
route(RubyApp::Mixins::RouteMixin::GET, /\/elements\/([^\.]+)\.([^\.\?]+)/) do |method, path, element_id, format|
|
28
|
+
RubyApp::Response['Content-Type'] = RubyApp::Element.get_content_type(format)
|
43
29
|
begin
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
'Content-Type' => RubyApp::Rack::Route.get_content_type(format)
|
49
|
-
},
|
50
|
-
[ RubyApp::Element.get_element(element_id).render(format.to_sym) ]
|
51
|
-
]
|
30
|
+
element = RubyApp::Element.get_element(element_id)
|
31
|
+
RubyApp::Log.duration("#{RubyApp::Session.session_id} GET #{element.class} #{format}") do
|
32
|
+
RubyApp::Response.write(element.render(format.to_sym))
|
33
|
+
end
|
52
34
|
rescue Exception => exception
|
53
|
-
RubyApp::
|
54
|
-
[
|
55
|
-
200,
|
56
|
-
{
|
57
|
-
'Cache-Control' => 'no-cache',
|
58
|
-
'Content-Type' => RubyApp::Rack::Route.get_content_type(format)
|
59
|
-
},
|
60
|
-
[ RubyApp::Elements::ExceptionElement.new(exception).render(format.to_sym) ]
|
61
|
-
]
|
35
|
+
RubyApp::Response.write(RubyApp::Elements::ExceptionElement.new(exception).render(format.to_sym))
|
62
36
|
end
|
63
37
|
end
|
64
38
|
|
65
39
|
route(RubyApp::Mixins::RouteMixin::GET, /\.([^\.\?]+)/) do |method, path, format|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
'Cache-Control' => 'no-cache',
|
71
|
-
'Content-Type' => RubyApp::Rack::Route.get_content_type(format)
|
72
|
-
},
|
73
|
-
[
|
74
|
-
RubyApp::Log.duration("#{self}.route method=#{method.inspect} path=#{path.inspect} format=#{format.to_sym.inspect} RubyApp::Session.pages.last=#{RubyApp::Session.pages.last.class}") do
|
75
|
-
RubyApp::Session.pages.last.render(format.to_sym)
|
76
|
-
end
|
77
|
-
]
|
78
|
-
]
|
79
|
-
rescue Exception => exception
|
80
|
-
RubyApp::Log.exception(exception)
|
81
|
-
raise exception
|
40
|
+
RubyApp::Response['Content-Type'] = RubyApp::Element.get_content_type(format)
|
41
|
+
page = RubyApp::Session.pages.last
|
42
|
+
RubyApp::Log.duration("#{RubyApp::Session.session_id} GET #{page.class} #{format}") do
|
43
|
+
RubyApp::Response.write(page.render(format.to_sym))
|
82
44
|
end
|
83
45
|
end
|
84
46
|
|
85
47
|
route(RubyApp::Mixins::RouteMixin::GET, /.*/) do |method, path|
|
86
|
-
RubyApp::
|
87
|
-
do_route(RubyApp::Mixins::RouteMixin::GET, '/.html')
|
48
|
+
RubyApp::Rack::Route.do_route(RubyApp::Mixins::RouteMixin::GET, '/.html')
|
88
49
|
end
|
89
50
|
|
90
51
|
route(RubyApp::Mixins::RouteMixin::POST, /.*/) do |method, path|
|
52
|
+
RubyApp::Response['Content-Type'] = 'application/json'
|
91
53
|
begin
|
92
|
-
|
93
|
-
|
54
|
+
event = RubyApp::Element::Event.from_hash(RubyApp::Request.POST)
|
55
|
+
RubyApp::Log.duration("#{RubyApp::Session.session_id} POST #{event.class}") do
|
94
56
|
event.process!
|
95
|
-
|
96
|
-
200,
|
97
|
-
{
|
98
|
-
'Cache-Control' => 'no-cache',
|
99
|
-
'Content-Type' => 'application/json'
|
100
|
-
},
|
101
|
-
[
|
102
|
-
RubyApp::Log.duration("#{self}.route method=#{method.inspect} path=#{path.inspect} POST['_class']=#{RubyApp::Request.POST['_class']}") do
|
103
|
-
Yajl::Encoder.new.encode(event.to_hash)
|
104
|
-
end
|
105
|
-
]
|
106
|
-
]
|
107
|
-
else
|
108
|
-
raise RubyApp::Exceptions::SessionInvalidException.new(RubyApp::Request.POST['session_id'])
|
57
|
+
RubyApp::Response.write(Yajl::Encoder.new.encode(event.to_hash))
|
109
58
|
end
|
110
59
|
rescue Exception => exception
|
111
|
-
RubyApp::
|
112
|
-
[
|
113
|
-
200,
|
114
|
-
{
|
115
|
-
'Cache-Control' => 'no-cache',
|
116
|
-
'Content-Type' => 'application/json'
|
117
|
-
},
|
118
|
-
[ Yajl::Encoder.new.encode(RubyApp::Element::ExceptionEvent.new(exception).to_hash) ]
|
119
|
-
]
|
60
|
+
RubyApp::Response.write(Yajl::Encoder.new.encode(RubyApp::Element::ExceptionEvent.new(exception).to_hash))
|
120
61
|
end
|
121
62
|
end
|
122
63
|
|
123
|
-
def self.get_content_type(format)
|
124
|
-
( mime_type = MIME::Types.type_for(format)[0] ) ? mime_type.content_type : 'text/plain'
|
125
|
-
end
|
126
|
-
|
127
64
|
end
|
128
65
|
|
129
66
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RubyApp
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
|
5
|
+
class Session
|
6
|
+
require 'ruby_app'
|
7
|
+
|
8
|
+
def initialize(application)
|
9
|
+
@application = application
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(environment)
|
13
|
+
RubyApp::Session.load!(RubyApp::Request.cookies['_session'])
|
14
|
+
begin
|
15
|
+
#RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} RubyApp::Session.session_id=#{RubyApp::Session.session_id.inspect}")
|
16
|
+
#RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} RubyApp::Session.expires=#{RubyApp::Session.expires.inspect}")
|
17
|
+
#RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} (now)=#{Time.now.inspect}")
|
18
|
+
RubyApp::Response.set_cookie('_session', { :value => RubyApp::Session.session_id,
|
19
|
+
:expires => RubyApp::Session.expires,
|
20
|
+
:path => '/'})
|
21
|
+
return @application.call(environment)
|
22
|
+
ensure
|
23
|
+
RubyApp::Session.unload!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/ruby_app/request.rb
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
-
require 'facets/string/interpolate'
|
5
4
|
require 'rack'
|
6
5
|
|
7
6
|
module RubyApp
|
8
|
-
require 'ruby_app/
|
9
|
-
require 'ruby_app/language'
|
10
|
-
require 'ruby_app/mixins/delegate_mixin'
|
11
|
-
require 'ruby_app/mixins/render_mixin'
|
12
|
-
require 'ruby_app/session'
|
7
|
+
require 'ruby_app/mixins'
|
13
8
|
|
14
9
|
class Request < ::Rack::Request
|
15
10
|
extend RubyApp::Mixins::DelegateMixin
|
16
11
|
|
17
12
|
def language
|
18
13
|
self.fullpath =~ /^\/([^\/\?]+)/
|
19
|
-
$1
|
14
|
+
return $1
|
20
15
|
end
|
21
16
|
|
22
17
|
def query
|
@@ -27,26 +22,8 @@ module RubyApp
|
|
27
22
|
self.params
|
28
23
|
end
|
29
24
|
|
30
|
-
def
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def rendered(template)
|
35
|
-
@rendered[template] = true
|
36
|
-
end
|
37
|
-
|
38
|
-
def content_for(element, name, value = nil, &block)
|
39
|
-
@content[element] ||= {}
|
40
|
-
@content[element][name] = block_given? ? block : String.interpolate { value }
|
41
|
-
end
|
42
|
-
|
43
|
-
def get_content(element, name)
|
44
|
-
@content[element] ||= {}
|
45
|
-
return @content[element][name]
|
46
|
-
end
|
47
|
-
|
48
|
-
def clear_content(element)
|
49
|
-
@content[element] ||= {}
|
25
|
+
def quit?
|
26
|
+
self.path =~ /\/quit/
|
50
27
|
end
|
51
28
|
|
52
29
|
def self.get
|
@@ -55,32 +32,6 @@ module RubyApp
|
|
55
32
|
|
56
33
|
def self.create!(environment = RubyApp::Application.environment)
|
57
34
|
Thread.current[:_request] = RubyApp::Request.new(environment)
|
58
|
-
|
59
|
-
if block_given?
|
60
|
-
begin
|
61
|
-
RubyApp::Language.load! do
|
62
|
-
RubyApp::Session.create! do
|
63
|
-
return yield
|
64
|
-
end
|
65
|
-
end
|
66
|
-
ensure
|
67
|
-
self.destroy!
|
68
|
-
end
|
69
|
-
else
|
70
|
-
begin
|
71
|
-
RubyApp::Language.load!
|
72
|
-
begin
|
73
|
-
RubyApp::Session.create!
|
74
|
-
rescue
|
75
|
-
RubyApp::Language.unload!
|
76
|
-
raise
|
77
|
-
end
|
78
|
-
rescue
|
79
|
-
self.destroy!
|
80
|
-
raise
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
35
|
end
|
85
36
|
|
86
37
|
def self.destroy!
|
@@ -91,8 +42,6 @@ module RubyApp
|
|
91
42
|
|
92
43
|
def initialize(environment)
|
93
44
|
super(environment)
|
94
|
-
@rendered = {}
|
95
|
-
@content = {}
|
96
45
|
end
|
97
46
|
|
98
47
|
end
|