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.
Files changed (123) hide show
  1. data/.gitignore +3 -3
  2. data/Gemfile.lock +1 -1
  3. data/features/default.feature +2 -2
  4. data/features/elements/button.feature +9 -0
  5. data/features/{dialog.feature → elements/dialog.feature} +19 -13
  6. data/features/elements/input.feature +20 -0
  7. data/features/elements/link.feature +9 -0
  8. data/features/elements/list.feature +19 -0
  9. data/features/elements/markdown.feature +9 -0
  10. data/features/elements/page.feature +10 -0
  11. data/features/elements/pages/exception_page.feature +10 -0
  12. data/features/step_definitions/default_macros.rb +1 -1
  13. data/features/step_definitions/default_steps.rb +7 -3
  14. data/features/support/env.rb +1 -1
  15. data/lib/ruby_app/application.rb +16 -41
  16. data/lib/ruby_app/configuration.rb +9 -17
  17. data/lib/ruby_app/element.rb +27 -23
  18. data/lib/ruby_app/elements/base/base_page.js.haml +1 -1
  19. data/lib/ruby_app/elements/base/base_page.rb +5 -5
  20. data/lib/ruby_app/elements/list.js.haml +1 -1
  21. data/lib/ruby_app/elements/list.rb +5 -5
  22. data/lib/ruby_app/elements/lists/select.js.haml +1 -1
  23. data/lib/ruby_app/elements/lists/select.rb +1 -3
  24. data/lib/ruby_app/elements/markdown.js.haml +1 -1
  25. data/lib/ruby_app/elements/markdown.rb +5 -5
  26. data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.js.haml +1 -1
  27. data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.rb +3 -3
  28. data/lib/ruby_app/elements/navigation/page_link.js.haml +1 -1
  29. data/lib/ruby_app/elements/navigation/page_link.rb +3 -3
  30. data/lib/ruby_app/elements/navigation/page_menu.js.haml +1 -1
  31. data/lib/ruby_app/elements/navigation/page_menu.rb +3 -3
  32. data/lib/ruby_app/elements/pages/authentication/open_id/authentication_page.rb +2 -2
  33. data/lib/ruby_app/elements/pages/authentication/open_id/ax_authentication_page.rb +2 -2
  34. data/lib/ruby_app/elements/pages/authentication/open_id/google_authentication_page.rb +1 -1
  35. data/lib/ruby_app/elements/pages/authentication/open_id/my_open_id_authentication_page.rb +1 -1
  36. data/lib/ruby_app/elements/pages/authentication/open_id/yahoo_authentication_page.rb +1 -1
  37. data/lib/ruby_app/elements/pages/default_page.rb +1 -1
  38. data/lib/ruby_app/elements/pages/exception_page.html.haml +0 -2
  39. data/lib/ruby_app/elements/pages/settings_page.rb +2 -2
  40. data/lib/ruby_app/elements/pages/test_pages/button_test_page.css.haml +3 -0
  41. data/lib/ruby_app/elements/pages/test_pages/button_test_page.html.haml +7 -0
  42. data/lib/ruby_app/elements/pages/test_pages/button_test_page.js.haml +3 -0
  43. data/lib/ruby_app/elements/pages/test_pages/button_test_page.rb +39 -0
  44. data/lib/ruby_app/elements/pages/test_pages/default_test_page.rb +8 -15
  45. data/lib/ruby_app/elements/pages/test_pages/dialog_test_page.rb +1 -1
  46. data/lib/ruby_app/elements/pages/test_pages/exception_test_page.html.haml +5 -0
  47. data/lib/ruby_app/elements/pages/test_pages/exception_test_page.rb +33 -0
  48. data/lib/ruby_app/elements/pages/test_pages/input_test_page.css.haml +1 -0
  49. data/lib/ruby_app/elements/pages/test_pages/input_test_page.html.haml +3 -0
  50. data/lib/ruby_app/elements/pages/test_pages/input_test_page.js.haml +1 -0
  51. data/lib/ruby_app/elements/pages/test_pages/input_test_page.rb +2 -0
  52. data/lib/ruby_app/elements/pages/test_pages/link_test_page.css.haml +3 -0
  53. data/lib/ruby_app/elements/pages/test_pages/link_test_page.html.haml +7 -0
  54. data/lib/ruby_app/elements/pages/test_pages/link_test_page.js.haml +3 -0
  55. data/lib/ruby_app/elements/pages/test_pages/link_test_page.rb +39 -0
  56. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.css.haml +2 -0
  57. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.html.haml +5 -0
  58. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.js.haml +2 -0
  59. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.rb +30 -0
  60. data/lib/ruby_app/elements/pages/test_pages/list_test_page.css.haml +1 -0
  61. data/lib/ruby_app/elements/pages/test_pages/list_test_page.html.haml +2 -1
  62. data/lib/ruby_app/elements/pages/test_pages/list_test_page.js.haml +1 -0
  63. data/lib/ruby_app/elements/pages/test_pages/list_test_page.rb +16 -11
  64. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.css.haml +2 -0
  65. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.html.haml +5 -0
  66. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.js.haml +2 -0
  67. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.rb +38 -0
  68. data/lib/ruby_app/elements/pages/test_pages/select_test_page.rb +44 -0
  69. data/lib/ruby_app/elements/pages/test_pages/test_page.html.haml +14 -0
  70. data/lib/ruby_app/elements/pages/test_pages/test_page.rb +42 -0
  71. data/lib/ruby_app/language.rb +9 -12
  72. data/lib/ruby_app/log.rb +19 -9
  73. data/lib/ruby_app/mixins/{configuration.rb → configure_mixin.rb} +2 -2
  74. data/lib/ruby_app/mixins/{delegate.rb → delegate_mixin.rb} +1 -1
  75. data/lib/ruby_app/mixins/{hash.rb → hash_mixin.rb} +5 -1
  76. data/lib/ruby_app/mixins/{render.rb → render_mixin.rb} +2 -2
  77. data/lib/ruby_app/mixins/{route.rb → route_mixin.rb} +5 -5
  78. data/lib/ruby_app/mixins/{template.rb → template_mixin.rb} +11 -11
  79. data/lib/ruby_app/mixins/{translate.rb → translate_mixin.rb} +1 -1
  80. data/lib/ruby_app/rack/application.rb +3 -3
  81. data/lib/ruby_app/rack/route.rb +14 -30
  82. data/lib/ruby_app/request.rb +36 -13
  83. data/lib/ruby_app/session.rb +17 -23
  84. data/lib/ruby_app/translations/en.yml +77 -15
  85. data/lib/ruby_app/version.rb +1 -1
  86. data/rakefile +1 -12
  87. data/spec/application_spec.rb +25 -0
  88. data/spec/configuration_spec.rb +25 -0
  89. data/spec/element_spec.rb +54 -5
  90. data/spec/elements/navigation/breadcrumbs_spec.rb +17 -25
  91. data/spec/elements/page_spec.rb +2 -13
  92. data/spec/language_spec.rb +25 -0
  93. data/spec/log_spec.rb +25 -0
  94. data/spec/mixins/configure_mixin_spec.rb +24 -0
  95. data/spec/mixins/delegate_mixin_spec.rb +28 -0
  96. data/spec/mixins/hash_mixin_spec.rb +39 -0
  97. data/spec/mixins/render_mixin_spec.rb +127 -0
  98. data/spec/mixins/route_mixin_spec.rb +60 -0
  99. data/spec/mixins/{template_spec.rb → template_mixin_spec.rb} +3 -3
  100. data/spec/mixins/test_a.css.haml +4 -3
  101. data/spec/mixins/test_a.html.haml +0 -1
  102. data/spec/mixins/test_a.js.haml +4 -3
  103. data/spec/mixins/test_b.css.haml +4 -4
  104. data/spec/mixins/test_b.js.haml +2 -2
  105. data/spec/mixins/test_c.css.haml +4 -4
  106. data/spec/mixins/test_c.js.haml +2 -2
  107. data/spec/mixins/translate_mixin_spec.rb +25 -0
  108. data/spec/request_spec.rb +25 -0
  109. data/spec/session_spec.rb +39 -0
  110. data/spec/spec_helper.rb +7 -0
  111. data/spec/support/shared.rb +19 -5
  112. metadata +75 -38
  113. data/features/breadcrumbs.feature +0 -11
  114. data/features/content.feature +0 -16
  115. data/features/exception.feature +0 -53
  116. data/features/input.feature +0 -13
  117. data/features/list.feature +0 -12
  118. data/features/month.feature +0 -14
  119. data/spec/mixins/render_spec.rb +0 -191
  120. data/spec/mixins/route_spec.rb +0 -60
  121. data/spec/mixins/test_e.html.haml +0 -2
  122. data/spec/mixins/test_f.html.haml +0 -2
  123. 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
- chromedriver.log
7
- rack.pid
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RubyApp (0.0.8)
4
+ RubyApp (0.0.9)
5
5
  BlueCloth
6
6
  chronic_duration
7
7
  facets
@@ -1,5 +1,5 @@
1
1
  Feature: Default Page
2
2
 
3
3
  Scenario: View the default page
4
- Given I am viewing "/en"
5
- Then I should see "This is the default start page"
4
+ Given I am viewing "/"
5
+ Then I should see "Click here to go to the test pages"
@@ -0,0 +1,9 @@
1
+ Feature: A button
2
+
3
+ Scenario: Rendering a button and process its event
4
+ Given I go to the test pages
5
+ When I click "ButtonTestPage"
6
+ Then I should see "Click"
7
+ When I click "Click"
8
+ Then I should see "This is the other page"
9
+ Then I quit
@@ -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
- Then I should see "ExceptionDialog"
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
- Then I should see "MessageDialog"
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
- Then I should see "MonthDialog"
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 selected"
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 selected"
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,9 @@
1
+ Feature: A link
2
+
3
+ Scenario: Rendering a link and process its event
4
+ Given I go to the test pages
5
+ When I click "LinkTestPage"
6
+ Then I should see "Click"
7
+ When I click "Click"
8
+ Then I should see "This is the other page"
9
+ 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: A page
2
+
3
+ Scenario: Rendering a page
4
+ Given I go to the test pages
5
+ When I click "TestPage"
6
+ Then I should see "Rendered"
7
+ And I should see "Loaded"
8
+ When I wait 4 seconds
9
+ Then I should see "Triggered"
10
+ 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,6 +1,6 @@
1
1
  Given /^I go to the test pages$/ do
2
2
  steps %Q{
3
- Given I am viewing "/en"
3
+ Given I am viewing "/"
4
4
  Then I should see "Click here to go to the test pages"
5
5
  Then I click "here"
6
6
  }
@@ -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
@@ -3,7 +3,7 @@ require 'capybara/cucumber'
3
3
  require 'capybara/dsl'
4
4
 
5
5
  Capybara.register_driver :chrome do |app|
6
- Capybara::Selenium::Driver.new(app, :browser => :chrome)
6
+ Capybara::Selenium::Driver.new(app, :browser => :firefox)
7
7
  end
8
8
 
9
9
  Capybara.default_driver = :chrome
@@ -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/configuration'
11
- require 'ruby_app/mixins/delegate'
12
- require 'ruby_app/request'
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::Delegate
18
- extend RubyApp::Mixins::Configuration
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[:configuration_paths] = [File.join(RubyApp::ROOT, %w[config.yml])] + ( _options[:configuration_paths].is_a?(Array) ? _options[:configuration_paths] : [_options[:configuration_paths]] )
60
- _options[:translations_paths] = [File.join(RubyApp::ROOT, %w[translations])] + ( _options[:translations_paths].is_a?(Array) ? _options[:translations_paths] : [_options[:translations_paths]] )
61
- @@_application = _options[:application_class].new(_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/log'
5
- require 'ruby_app/mixins/delegate'
6
- require 'ruby_app/mixins/hash'
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::Delegate
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(configuration_paths)
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(configuration_paths)
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
@@ -6,31 +6,35 @@ require 'json'
6
6
  require 'ruby-event'
7
7
 
8
8
  module RubyApp
9
- require 'ruby_app/mixins/configuration'
10
- require 'ruby_app/mixins/render'
11
- require 'ruby_app/mixins/template'
12
- require 'ruby_app/mixins/translate'
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::Configuration
16
- include RubyApp::Mixins::Configuration
17
- extend RubyApp::Mixins::Translate
18
- include RubyApp::Mixins::Translate
19
- extend RubyApp::Mixins::Template
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
- extend RubyApp::Mixins::Render
23
- include RubyApp::Mixins::Render
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 = nil)
30
- @source = data ? RubyApp::Element.get_element(data['source_id']) : nil
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('#{url}');")
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 ? @source.element_id : nil,
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