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/.gitignore
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
*.gem
|
2
1
|
.bundle
|
3
2
|
.DS_Store
|
4
3
|
.idea
|
5
4
|
.sass-cache
|
6
|
-
|
7
|
-
|
5
|
+
*.gem
|
6
|
+
*.log
|
7
|
+
*.pid
|
8
8
|
lib/ruby_app/elements/pages/authentication/open_id/associations
|
9
9
|
lib/ruby_app/elements/pages/authentication/open_id/nonces
|
10
10
|
lib/ruby_app/elements/pages/authentication/open_id/temp
|
data/Gemfile.lock
CHANGED
data/features/default.feature
CHANGED
@@ -3,21 +3,31 @@ Feature: Dialog Test Page
|
|
3
3
|
@broken
|
4
4
|
Scenario: Show a busy dialog
|
5
5
|
Given I go to the test pages
|
6
|
-
Then I should see "DialogTestPage"
|
7
6
|
When I click "DialogTestPage"
|
8
|
-
Then I should see "BusyDialog"
|
9
7
|
When I click "BusyDialog"
|
10
8
|
Then I should see "Busy dialog"
|
11
9
|
When I wait 30 seconds
|
12
10
|
Then I should not see "Busy dialog"
|
13
11
|
Then I quit
|
14
12
|
|
13
|
+
Scenario: Show a confirmation dialog
|
14
|
+
Given I go to the test pages
|
15
|
+
When I click "DialogTestPage"
|
16
|
+
And I click "ConfirmationDialog"
|
17
|
+
Then I should see "Confirmation Dialog"
|
18
|
+
And I should see "Are you sure?"
|
19
|
+
When I click "Yes"
|
20
|
+
Then I should not see "Confirmation Dialog"
|
21
|
+
And I should not see "Are you sure?"
|
22
|
+
And I should see "You clicked"
|
23
|
+
And I should see "true"
|
24
|
+
Then I click "Close"
|
25
|
+
Then I quit
|
26
|
+
|
15
27
|
Scenario: Show an exception dialog
|
16
28
|
Given I go to the test pages
|
17
|
-
Then I should see "DialogTestPage"
|
18
29
|
When I click "DialogTestPage"
|
19
|
-
|
20
|
-
When I click "ExceptionDialog"
|
30
|
+
And I click "ExceptionDialog"
|
21
31
|
Then I should see "RuntimeError"
|
22
32
|
And I should see "Exception dialog"
|
23
33
|
When I click "Close"
|
@@ -27,10 +37,8 @@ Feature: Dialog Test Page
|
|
27
37
|
|
28
38
|
Scenario: Show a message dialog
|
29
39
|
Given I go to the test pages
|
30
|
-
Then I should see "DialogTestPage"
|
31
40
|
When I click "DialogTestPage"
|
32
|
-
|
33
|
-
When I click "MessageDialog"
|
41
|
+
And I click "MessageDialog"
|
34
42
|
Then I should see "Message Dialog"
|
35
43
|
And I should see "This is a Message Dialog"
|
36
44
|
When I click "Close"
|
@@ -40,17 +48,15 @@ Feature: Dialog Test Page
|
|
40
48
|
|
41
49
|
Scenario: Show a calendar month dialog
|
42
50
|
Given I go to the test pages
|
43
|
-
Then I should see "DialogTestPage"
|
44
51
|
When I click "DialogTestPage"
|
45
|
-
|
46
|
-
When I click "MonthDialog"
|
52
|
+
And I click "MonthDialog"
|
47
53
|
Then I should see "Wed"
|
48
54
|
When I click "15"
|
49
55
|
Then I should not see "Wed"
|
50
|
-
And I should see "You
|
56
|
+
And I should see "You clicked"
|
51
57
|
And I should see "15/"
|
52
58
|
When I click "Close"
|
53
|
-
Then I should not see "You
|
59
|
+
Then I should not see "You clicked"
|
54
60
|
And I should not see "15/"
|
55
61
|
And I should see "-15"
|
56
62
|
Then I quit
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Feature: Input elements
|
2
|
+
|
3
|
+
Scenario: Render a simple input element and process its event
|
4
|
+
Given I go to the test pages
|
5
|
+
When I click "InputTestPage"
|
6
|
+
Then I should see "Input"
|
7
|
+
And I fill in the "Input" field with "value" and I press enter
|
8
|
+
Then I should see "You input 'value'."
|
9
|
+
Then I click "Close"
|
10
|
+
Then I quit
|
11
|
+
|
12
|
+
Scenario: Render a duration input element and process its event
|
13
|
+
Given I go to the test pages
|
14
|
+
When I click "InputTestPage"
|
15
|
+
Then I should see "DurationInput"
|
16
|
+
And I fill in the "DurationInput" field with "2h 3m" and I press enter
|
17
|
+
Then I should see "You input '7,380'."
|
18
|
+
When I click "Close"
|
19
|
+
Then the "DurationInput" field should contain "2 hrs 3 mins"
|
20
|
+
Then I quit
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: List element
|
2
|
+
|
3
|
+
Scenario: Render a list element and process its event
|
4
|
+
Given I go to the test pages
|
5
|
+
When I click "ListTestPage"
|
6
|
+
Then I should see "Item 03"
|
7
|
+
When I click "Item 03"
|
8
|
+
Then I should see "You clicked 'Item 03'."
|
9
|
+
Then I click "Close"
|
10
|
+
Then I quit
|
11
|
+
|
12
|
+
Scenario: Render a select list element and process its event
|
13
|
+
Given I go to the test pages
|
14
|
+
When I click "ListTestPage"
|
15
|
+
Then I should see "Item 13"
|
16
|
+
When I click "Item 13"
|
17
|
+
Then I should see "You clicked 'Item 13'."
|
18
|
+
Then I click "Close"
|
19
|
+
Then I quit
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: A block of markdown
|
2
|
+
|
3
|
+
Scenario: Rendering a block of markdown and process its events
|
4
|
+
Given I go to the test pages
|
5
|
+
When I click "MarkdownTestPage"
|
6
|
+
Then I should see "Click here"
|
7
|
+
When I click "here"
|
8
|
+
Then I should see "This is the other page"
|
9
|
+
Then I quit
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Exception page
|
2
|
+
|
3
|
+
Scenario: View the exception page
|
4
|
+
Given I go to the test pages
|
5
|
+
When I click "ExceptionTestPage"
|
6
|
+
Then I should see "RuntimeError"
|
7
|
+
And I should see "Exception page"
|
8
|
+
Given I am viewing "/quit"
|
9
|
+
Then I should see "Click here to go to the test pages"
|
10
|
+
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Given /^I am viewing "([^"]*)"$/ do |url|
|
2
2
|
visit(url)
|
3
3
|
end
|
4
|
-
|
4
|
+
|
5
5
|
When /^I refresh the page$/ do
|
6
6
|
visit(current_path)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
Then /^I should (not )?see "([^"]*)"$/ do |negative, text|
|
10
10
|
unless negative
|
11
11
|
page.should have_content(text)
|
@@ -19,7 +19,7 @@ When /^I click "([^"]*)"$/ do |text|
|
|
19
19
|
sleep 1
|
20
20
|
end
|
21
21
|
|
22
|
-
When /^I fill in "([^"]*)" with "([^"]*)"( and I press enter)?$/ do |field, value, enter|
|
22
|
+
When /^I fill in the "([^"]*)" field with "([^"]*)"( and I press enter)?$/ do |field, value, enter|
|
23
23
|
fill_in(field, :with => value)
|
24
24
|
if enter
|
25
25
|
find_field(field).native.send_key(:enter)
|
@@ -27,6 +27,10 @@ When /^I fill in "([^"]*)" with "([^"]*)"( and I press enter)?$/ do |field, valu
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
31
|
+
field_labeled(field).value.should =~ /#{value}/
|
32
|
+
end
|
33
|
+
|
30
34
|
Then /^show me the page$/ do
|
31
35
|
save_and_open_page
|
32
36
|
end
|
data/features/support/env.rb
CHANGED
data/lib/ruby_app/application.rb
CHANGED
@@ -1,69 +1,44 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
1
|
module RubyApp
|
7
2
|
require 'ruby_app/configuration'
|
8
|
-
require 'ruby_app/language'
|
9
3
|
require 'ruby_app/log'
|
10
|
-
require 'ruby_app/mixins/
|
11
|
-
require 'ruby_app/mixins/
|
12
|
-
require 'ruby_app/
|
4
|
+
require 'ruby_app/mixins/configure_mixin'
|
5
|
+
require 'ruby_app/mixins/delegate_mixin'
|
6
|
+
require 'ruby_app/mixins/hash_mixin'
|
13
7
|
require 'ruby_app/session'
|
14
8
|
require 'ruby_app/version'
|
15
9
|
|
16
10
|
class Application
|
17
|
-
extend RubyApp::Mixins::
|
18
|
-
|
19
|
-
include RubyApp::Mixins::Configuration
|
11
|
+
extend RubyApp::Mixins::DelegateMixin
|
12
|
+
include RubyApp::Mixins::ConfigureMixin
|
20
13
|
|
21
|
-
attr_reader :options
|
14
|
+
attr_reader :options, :environment
|
22
15
|
|
23
16
|
def initialize(options)
|
24
17
|
@options = options
|
25
18
|
@environment = {}
|
26
|
-
|
27
|
-
RubyApp::Log.open(@options[:log_path])
|
28
|
-
RubyApp::Configuration.load(@options[:configuration_paths])
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def execute(environment = nil)
|
33
|
-
_environment = environment || @environment
|
34
|
-
RubyApp::Request.create(_environment) do |request|
|
35
|
-
RubyApp::Language.load(RubyApp::Request.language || @options[:default_language], @options[:translations_paths]) do |language|
|
36
|
-
RubyApp::Session.create(@options[:session_class]) do |session|
|
37
|
-
Thread.current[:_rendered] = {}
|
38
|
-
begin
|
39
|
-
return yield
|
40
|
-
ensure
|
41
|
-
Thread.current[:_rendered] = nil
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
19
|
end
|
47
20
|
|
48
21
|
def self.get
|
49
|
-
@@_application
|
22
|
+
@@_application ||= nil
|
50
23
|
end
|
51
24
|
|
52
|
-
def self.create(options = {})
|
25
|
+
def self.create!(options = {})
|
53
26
|
_options = { :application_class => RubyApp::Application,
|
54
27
|
:session_class => RubyApp::Session,
|
55
28
|
:log_path => File.join(RubyApp::ROOT, %w[log application.log]),
|
56
29
|
:configuration_paths => [],
|
57
30
|
:default_language => :en,
|
58
31
|
:translations_paths => [] }.merge(options)
|
59
|
-
_options
|
60
|
-
_options
|
61
|
-
@@_application = _options
|
32
|
+
_options.configuration_paths = [File.join(RubyApp::ROOT, %w[config.yml])] + ( _options.configuration_paths.is_a?(Array) ? _options.configuration_paths : [_options.configuration_paths] )
|
33
|
+
_options.translations_paths = [File.join(RubyApp::ROOT, %w[translations])] + ( _options.translations_paths.is_a?(Array) ? _options.translations_paths : [_options.translations_paths] )
|
34
|
+
@@_application = _options.application_class.new(_options)
|
35
|
+
RubyApp::Log.open!
|
36
|
+
RubyApp::Configuration.load!
|
62
37
|
end
|
63
38
|
|
64
|
-
def self.destroy
|
65
|
-
RubyApp::Configuration.unload
|
66
|
-
RubyApp::Log.close
|
39
|
+
def self.destroy!
|
40
|
+
RubyApp::Configuration.unload!
|
41
|
+
RubyApp::Log.close!
|
67
42
|
@@_application = nil
|
68
43
|
end
|
69
44
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
module RubyApp
|
4
|
-
require 'ruby_app/
|
5
|
-
require 'ruby_app/mixins/
|
6
|
-
require 'ruby_app/mixins/
|
4
|
+
require 'ruby_app/application'
|
5
|
+
require 'ruby_app/mixins/delegate_mixin'
|
6
|
+
require 'ruby_app/mixins/hash_mixin'
|
7
7
|
|
8
8
|
class Configuration
|
9
|
-
extend RubyApp::Mixins::
|
9
|
+
extend RubyApp::Mixins::DelegateMixin
|
10
10
|
|
11
11
|
attr_reader :document
|
12
12
|
|
@@ -14,31 +14,23 @@ module RubyApp
|
|
14
14
|
@@_configuration
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.load
|
18
|
-
@@_configuration = RubyApp::Configuration.new(configuration_paths)
|
17
|
+
def self.load!
|
18
|
+
@@_configuration = RubyApp::Configuration.new(RubyApp::Application.options.configuration_paths)
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.unload
|
21
|
+
def self.unload!
|
22
22
|
@@_configuration = nil
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
def initialize(
|
28
|
-
|
27
|
+
def initialize(paths)
|
29
28
|
@document = {}
|
30
|
-
|
31
|
-
configuration_paths.each do |path|
|
32
|
-
RubyApp::Log.debug("#{self.class}##{__method__}(...) path=#{path.inspect}")
|
29
|
+
paths.each do |path|
|
33
30
|
@document.merge!(YAML::load(File.open(path)))
|
34
31
|
end
|
35
|
-
|
36
32
|
end
|
37
33
|
|
38
34
|
end
|
39
35
|
|
40
36
|
end
|
41
|
-
|
42
|
-
class Hash
|
43
|
-
include RubyApp::Mixins::Hash
|
44
|
-
end
|
data/lib/ruby_app/element.rb
CHANGED
@@ -6,31 +6,35 @@ require 'json'
|
|
6
6
|
require 'ruby-event'
|
7
7
|
|
8
8
|
module RubyApp
|
9
|
-
require 'ruby_app/mixins/
|
10
|
-
require 'ruby_app/mixins/
|
11
|
-
require 'ruby_app/mixins/
|
12
|
-
require 'ruby_app/mixins/
|
9
|
+
require 'ruby_app/mixins/configure_mixin'
|
10
|
+
require 'ruby_app/mixins/render_mixin'
|
11
|
+
require 'ruby_app/mixins/template_mixin'
|
12
|
+
require 'ruby_app/mixins/translate_mixin'
|
13
13
|
|
14
14
|
class Element
|
15
|
-
extend RubyApp::Mixins::
|
16
|
-
include RubyApp::Mixins::
|
17
|
-
extend RubyApp::Mixins::
|
18
|
-
include RubyApp::Mixins::
|
19
|
-
extend RubyApp::Mixins::
|
20
|
-
include Haml::Helpers
|
15
|
+
extend RubyApp::Mixins::ConfigureMixin
|
16
|
+
include RubyApp::Mixins::ConfigureMixin
|
17
|
+
extend RubyApp::Mixins::TranslateMixin
|
18
|
+
include RubyApp::Mixins::TranslateMixin
|
19
|
+
extend RubyApp::Mixins::TemplateMixin
|
21
20
|
extend Haml::Helpers
|
22
|
-
|
23
|
-
|
21
|
+
include Haml::Helpers
|
22
|
+
extend RubyApp::Mixins::RenderMixin
|
23
|
+
include RubyApp::Mixins::RenderMixin
|
24
24
|
|
25
25
|
class Event
|
26
26
|
|
27
27
|
attr_reader :source
|
28
28
|
|
29
|
-
def initialize(data
|
30
|
-
@source =
|
29
|
+
def initialize(data)
|
30
|
+
@source = RubyApp::Element.get_element(data['source_id'])
|
31
31
|
@statements = []
|
32
32
|
end
|
33
33
|
|
34
|
+
def process!
|
35
|
+
source.send(:on_event, self)
|
36
|
+
end
|
37
|
+
|
34
38
|
def alert(message)
|
35
39
|
execute("RubyApp.alert(#{message.to_json});")
|
36
40
|
end
|
@@ -60,31 +64,31 @@ module RubyApp
|
|
60
64
|
end
|
61
65
|
|
62
66
|
def go(url)
|
63
|
-
execute("RubyApp.go(
|
67
|
+
execute("RubyApp.go(#{url.to_json});")
|
64
68
|
end
|
65
69
|
|
66
70
|
def execute(statement)
|
67
71
|
@statements << statement
|
68
72
|
end
|
69
73
|
|
70
|
-
def self.from_hash(data)
|
71
|
-
eval(data['_class']).new(data)
|
72
|
-
end
|
73
|
-
|
74
74
|
def to_hash
|
75
75
|
{
|
76
76
|
'_class' => self.class.to_s,
|
77
|
-
'source_id' => @source
|
77
|
+
'source_id' => @source.element_id,
|
78
78
|
'statements' => @statements
|
79
79
|
}
|
80
80
|
end
|
81
81
|
|
82
|
+
def self.from_hash(data)
|
83
|
+
eval(data['_class']).new(data)
|
84
|
+
end
|
85
|
+
|
82
86
|
end
|
83
87
|
|
84
88
|
class ExceptionEvent < RubyApp::Element::Event
|
85
89
|
|
86
|
-
def initialize(exception)
|
87
|
-
super()
|
90
|
+
def initialize(data, exception)
|
91
|
+
super(data)
|
88
92
|
self.alert(exception.message)
|
89
93
|
end
|
90
94
|
|
@@ -97,7 +101,7 @@ module RubyApp
|
|
97
101
|
event :evented
|
98
102
|
|
99
103
|
def initialize
|
100
|
-
@attributes = {:id => element_id}
|
104
|
+
@attributes = {:id => self.element_id}
|
101
105
|
end
|
102
106
|
|
103
107
|
def element_id
|