netzke-core 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.travis.yml +1 -2
  2. data/CHANGELOG.md +572 -0
  3. data/LICENSE +7 -1
  4. data/README.md +345 -29
  5. data/Rakefile +3 -3
  6. data/app/controllers/netzke_controller.rb +37 -48
  7. data/config/ci/before-travis.sh +3 -4
  8. data/javascripts/base.js +86 -150
  9. data/javascripts/ext.js +180 -210
  10. data/javascripts/{core_extensions.js → js_extensions.js} +0 -0
  11. data/lib/netzke-core.rb +16 -6
  12. data/lib/netzke/base.rb +84 -107
  13. data/lib/netzke/core.rb +7 -41
  14. data/lib/netzke/core/action_config.rb +37 -0
  15. data/lib/netzke/core/actions.rb +123 -0
  16. data/lib/netzke/core/client_class.rb +252 -0
  17. data/lib/netzke/core/component_config.rb +12 -0
  18. data/lib/netzke/core/composition.rb +274 -0
  19. data/lib/netzke/core/config_to_dsl_delegator.rb +69 -0
  20. data/lib/netzke/core/configuration.rb +63 -0
  21. data/lib/netzke/core/css_config.rb +51 -0
  22. data/lib/netzke/core/dynamic_assets.rb +19 -49
  23. data/lib/netzke/{embedding.rb → core/embedding.rb} +4 -6
  24. data/lib/netzke/core/endpoint_response.rb +15 -0
  25. data/lib/netzke/core/javascript.rb +111 -0
  26. data/lib/netzke/core/panel.rb +11 -0
  27. data/lib/netzke/{plugins.rb → core/plugins.rb} +10 -5
  28. data/lib/netzke/core/railz.rb +4 -0
  29. data/lib/netzke/{railz → core/railz}/action_view_ext.rb +22 -18
  30. data/lib/netzke/core/railz/action_view_ext/ext.rb +49 -0
  31. data/lib/netzke/core/railz/controller_extensions.rb +17 -0
  32. data/lib/netzke/core/railz/engine.rb +16 -0
  33. data/lib/netzke/core/railz/routes.rb +10 -0
  34. data/lib/netzke/core/ruby_ext.rb +5 -0
  35. data/lib/netzke/core/ruby_ext/array.rb +23 -0
  36. data/lib/netzke/core/ruby_ext/hash.rb +47 -0
  37. data/lib/netzke/{core_ext → core/ruby_ext}/string.rb +2 -7
  38. data/lib/netzke/core/ruby_ext/symbol.rb +13 -0
  39. data/lib/netzke/{core_ext → core/ruby_ext}/time_with_zone.rb +0 -0
  40. data/lib/netzke/core/services.rb +130 -0
  41. data/lib/netzke/core/session.rb +15 -19
  42. data/lib/netzke/core/state.rb +40 -0
  43. data/lib/netzke/core/stylesheets.rb +48 -0
  44. data/lib/netzke/core/version.rb +2 -2
  45. data/lib/netzke/plugin.rb +8 -11
  46. data/netzke-core.gemspec +69 -59
  47. data/test/core_test_app/Gemfile +2 -20
  48. data/test/core_test_app/Gemfile.lock +65 -74
  49. data/test/core_test_app/app/components/card_component_loader.rb +4 -4
  50. data/test/core_test_app/app/components/component_loader.rb +40 -120
  51. data/test/core_test_app/app/components/component_loader/javascripts/component_loader.js +49 -0
  52. data/test/core_test_app/app/components/component_with_actions.rb +61 -47
  53. data/test/core_test_app/app/components/component_with_custom_css.rb +8 -5
  54. data/test/core_test_app/app/components/component_with_js_mixin.rb +11 -5
  55. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_one.js +1 -1
  56. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_two.js +1 -1
  57. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/method_set_one.js +1 -1
  58. data/test/core_test_app/app/components/component_with_nested_through.rb +2 -2
  59. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control.rb +12 -0
  60. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control/javascripts/component_with_prebuilt_toolbar_control.js +12 -0
  61. data/test/core_test_app/app/components/component_with_required_js.rb +24 -0
  62. data/test/core_test_app/app/components/configurable_on_class_level.rb +8 -0
  63. data/test/core_test_app/app/components/dsl_delegated_properties.rb +4 -0
  64. data/test/core_test_app/app/components/dsl_delegated_properties_base.rb +5 -0
  65. data/test/core_test_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js +2 -2
  66. data/test/core_test_app/app/components/ext_direct/composite.rb +32 -33
  67. data/test/core_test_app/app/components/ext_direct/details.rb +2 -4
  68. data/test/core_test_app/app/components/ext_direct/selector.rb +20 -22
  69. data/test/core_test_app/app/components/ext_direct/statistics.rb +2 -4
  70. data/test/core_test_app/app/components/extended_component_with_actions.rb +7 -3
  71. data/test/core_test_app/app/components/extended_component_with_js_mixin.rb +7 -4
  72. data/test/core_test_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js +1 -1
  73. data/test/core_test_app/app/components/extended_server_caller.rb +20 -14
  74. data/test/core_test_app/app/components/hello_world.rb +23 -0
  75. data/test/core_test_app/app/components/hello_world/javascripts/hello_world.js +12 -0
  76. data/test/core_test_app/app/components/included.js +2 -2
  77. data/test/core_test_app/app/components/kinda_complex_component.rb +1 -3
  78. data/test/core_test_app/app/components/kinda_complex_component/basic_stuff.rb +15 -17
  79. data/test/core_test_app/app/components/kinda_complex_component/extra_stuff.rb +4 -5
  80. data/test/core_test_app/app/components/loader_of_component_with_custom_css.rb +14 -5
  81. data/test/core_test_app/app/components/localized_panel.rb +23 -25
  82. data/test/core_test_app/app/components/multipane_component_loader.rb +19 -20
  83. data/test/core_test_app/app/components/nested_component.rb +4 -5
  84. data/test/core_test_app/app/components/panel_with_plugin.rb +8 -3
  85. data/test/core_test_app/app/components/panel_with_tools.rb +15 -14
  86. data/test/core_test_app/app/components/plugin_with_components.rb +20 -12
  87. data/test/core_test_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +5 -2
  88. data/test/core_test_app/app/components/scoped_components/extended_scoped_component.rb +5 -2
  89. data/test/core_test_app/app/components/scoped_components/some_scoped_component.rb +5 -2
  90. data/test/core_test_app/app/components/server_caller.rb +39 -17
  91. data/test/core_test_app/app/components/server_caller/javascripts/server_caller.js +42 -0
  92. data/test/core_test_app/app/components/server_counter.rb +18 -82
  93. data/test/core_test_app/app/components/server_counter/javascripts/server_counter.js +53 -0
  94. data/test/core_test_app/app/components/simple_authentication_component.rb +46 -0
  95. data/test/core_test_app/app/components/simple_component.rb +8 -3
  96. data/test/core_test_app/app/components/simple_composite.rb +12 -0
  97. data/test/core_test_app/app/components/simple_form_with_file_upload.rb +49 -0
  98. data/test/core_test_app/app/components/simple_panel.rb +2 -2
  99. data/test/core_test_app/app/components/simple_tab_panel.rb +24 -3
  100. data/test/core_test_app/app/components/simple_window.rb +4 -2
  101. data/test/core_test_app/app/components/some_composite.rb +77 -48
  102. data/test/core_test_app/app/components/some_plugin.rb +31 -30
  103. data/test/core_test_app/app/components/stateful_component.rb +46 -0
  104. data/test/core_test_app/app/components/stateful_component_with_shared_state.rb +11 -0
  105. data/test/core_test_app/app/components/window_with_simple_component.rb +14 -0
  106. data/test/core_test_app/app/views/layouts/application.html.erb +1 -1
  107. data/test/core_test_app/app/views/simple_rails/multiple_nested.html.erb +7 -19
  108. data/test/core_test_app/app/views/simple_rails/panel.html.erb +1 -0
  109. data/test/core_test_app/config/database.yml.travis +3 -5
  110. data/test/core_test_app/config/environments/production.rb +1 -1
  111. data/test/core_test_app/config/initializers/netzke.rb +3 -1
  112. data/test/core_test_app/config/locales/en.yml +9 -4
  113. data/test/core_test_app/config/locales/es.yml +4 -2
  114. data/test/core_test_app/config/routes.rb +2 -8
  115. data/test/core_test_app/db/schema.rb +3 -11
  116. data/test/core_test_app/features/actions_and_tools.feature +1 -0
  117. data/test/core_test_app/features/client-server.feature +7 -0
  118. data/test/core_test_app/features/component_loader.feature +13 -13
  119. data/test/core_test_app/features/composition.feature +14 -0
  120. data/test/core_test_app/features/config_to_dsl_delegation.feature +10 -0
  121. data/test/core_test_app/features/file_inclusion.feature +1 -1
  122. data/test/core_test_app/features/i18n.feature +4 -4
  123. data/test/core_test_app/features/js_include.feature +1 -1
  124. data/test/core_test_app/features/persistence.feature +21 -5
  125. data/test/core_test_app/features/step_definitions/generic_steps.rb +14 -0
  126. data/test/core_test_app/features/support/paths.rb +0 -3
  127. data/test/core_test_app/public/images/icons/accept.png +0 -0
  128. data/test/core_test_app/public/images/icons/anchor.png +0 -0
  129. data/test/core_test_app/public/images/icons/tick.png +0 -0
  130. data/test/core_test_app/spec/action_config_spec.rb +15 -0
  131. data/test/core_test_app/spec/{component/actions_spec.rb → actions_spec.rb} +38 -36
  132. data/test/core_test_app/spec/base_spec.rb +35 -0
  133. data/test/core_test_app/spec/client_class_spec.rb +17 -0
  134. data/test/core_test_app/spec/component +0 -0
  135. data/test/core_test_app/spec/composition_spec.rb +118 -0
  136. data/test/core_test_app/spec/core_ext_spec.rb +3 -14
  137. data/test/core_test_app/spec/endpoint_response_spec.rb +17 -0
  138. data/test/core_test_app/spec/javascript_spec.rb +33 -0
  139. data/test/core_test_app/spec/js_class_config_scope.rb +37 -0
  140. data/test/core_test_app/spec/panel_spec.rb +11 -0
  141. data/test/core_test_app/spec/services_spec.rb +16 -0
  142. data/test/core_test_app/spec/state_spec.rb +20 -0
  143. data/test/unit/core_ext_test.rb +0 -53
  144. data/test/unit/netzke_core_test.rb +11 -11
  145. metadata +76 -62
  146. data/CHANGELOG.rdoc +0 -325
  147. data/javascripts/touch.js +0 -58
  148. data/lib/netzke/actions.rb +0 -107
  149. data/lib/netzke/composition.rb +0 -224
  150. data/lib/netzke/config_to_dsl_delegator.rb +0 -43
  151. data/lib/netzke/configuration.rb +0 -195
  152. data/lib/netzke/core/masquerading.rb +0 -34
  153. data/lib/netzke/core_ext.rb +0 -6
  154. data/lib/netzke/core_ext/array.rb +0 -30
  155. data/lib/netzke/core_ext/hash.rb +0 -86
  156. data/lib/netzke/core_ext/symbol.rb +0 -21
  157. data/lib/netzke/ext_component.rb +0 -25
  158. data/lib/netzke/inheritance.rb +0 -31
  159. data/lib/netzke/javascript.rb +0 -382
  160. data/lib/netzke/javascript/scopes.rb +0 -39
  161. data/lib/netzke/railz.rb +0 -4
  162. data/lib/netzke/railz/action_view_ext/ext.rb +0 -64
  163. data/lib/netzke/railz/action_view_ext/touch.rb +0 -52
  164. data/lib/netzke/railz/controller_extensions.rb +0 -33
  165. data/lib/netzke/railz/engine.rb +0 -48
  166. data/lib/netzke/railz/routes.rb +0 -7
  167. data/lib/netzke/services.rb +0 -101
  168. data/lib/netzke/session.rb +0 -54
  169. data/lib/netzke/state.rb +0 -91
  170. data/lib/netzke/stylesheets.rb +0 -65
  171. data/test/core_test_app/app/components/component_with_included_js.rb +0 -16
  172. data/test/core_test_app/app/components/component_with_session_persistence.rb +0 -35
  173. data/test/core_test_app/app/components/deprecated/server_caller.rb +0 -20
  174. data/test/core_test_app/app/components/dynamic_tab_panel.rb +0 -19
  175. data/test/core_test_app/app/components/hello_world_component.rb +0 -31
  176. data/test/core_test_app/app/components/touch/hello_world_component.rb +0 -25
  177. data/test/core_test_app/app/components/touch/server_caller.rb +0 -28
  178. data/test/core_test_app/app/components/touch/simple_carousel.rb +0 -17
  179. data/test/core_test_app/app/controllers/touch_controller.rb +0 -6
  180. data/test/core_test_app/app/helpers/touch_helper.rb +0 -2
  181. data/test/core_test_app/app/views/layouts/touch.html.erb +0 -13
  182. data/test/core_test_app/db/migrate/20110110132720_create_netzke_component_states.rb +0 -20
  183. data/test/core_test_app/features/step_definitions/touch_steps.rb +0 -3
  184. data/test/core_test_app/features/touch.feature +0 -10
  185. data/test/core_test_app/gemfiles/rails3_1.gemfile +0 -16
  186. data/test/core_test_app/gemfiles/rails3_2.gemfile +0 -16
  187. data/test/core_test_app/spec/component/base_spec.rb +0 -36
  188. data/test/core_test_app/spec/component/component_spec.rb +0 -20
  189. data/test/core_test_app/spec/component/composition_spec.rb +0 -132
  190. data/test/core_test_app/spec/component/configuration_spec.rb +0 -61
  191. data/test/core_test_app/spec/component/javascript_spec.rb +0 -16
  192. data/test/core_test_app/spec/component/state_spec.rb +0 -18
@@ -1,65 +0,0 @@
1
- module Netzke
2
- module Stylesheets
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- class_attribute :css_included_files
7
- self.css_included_files = []
8
- end
9
-
10
- module ClassMethods
11
- # Returns all extra CSS code (as string) required by this component's class
12
- def css_included
13
- # Prevent re-including code that was already included by the parent
14
- # (thus, only include those JS files when include_js was defined in the current class, not in its ancestors)
15
- ((singleton_methods(false).map(&:to_sym).include?(:include_css) ? include_css : [] ) + css_included_files).inject(""){ |r, path| r + File.new(path).read + "\n"}
16
- end
17
-
18
- # All CSS code needed for this class including the one from the ancestor component
19
- def css_code(cached = [])
20
- res = ""
21
-
22
- # include the base-class javascript if doing JS inheritance
23
- res << superclass.css_code << "\n" if extends_netzke_component? && !cached.include?(superclass.short_component_class_name)
24
-
25
- res << css_included << "\n"
26
-
27
- res
28
- end
29
-
30
- # Use it to specify stylesheet files to be loaded along with this component.
31
- # It may accept one or more symbols or strings. Strings will be interpreted as full paths to included files:
32
- #
33
- # css_include "#{File.dirname(__FILE__)}/my_component/one.css", "#{File.dirname(__FILE__)}/my_component/two.css"
34
- #
35
- # Symbols will be expanded following a convention, e.g.:
36
- #
37
- # class MyComponent < Netzke::Base
38
- # css_include :some_library
39
- # # ...
40
- # end
41
- #
42
- # This will "include" a stylesheet file +{component_location}/my_component/stylesheets/some_library.js+
43
- def css_include(*args)
44
- callr = caller.first
45
-
46
- self.css_included_files += args.map{ |a| a.is_a?(Symbol) ? expand_css_include_path(a, callr) : a }
47
- end
48
-
49
- protected
50
-
51
- def expand_css_include_path(sym, callr) # :nodoc:
52
- %Q(#{callr.split(".rb:").first}/stylesheets/#{sym}.css)
53
- end
54
-
55
- end
56
-
57
- def css_missing_code(cached = [])
58
- code = dependency_classes.inject("") do |r,k|
59
- cached.include?(k.js_xtype) ? r : r + k.css_code(cached)
60
- end
61
- code.blank? ? nil : code
62
- end
63
-
64
- end
65
- end
@@ -1,16 +0,0 @@
1
- class ComponentWithIncludedJs < Netzke::Base
2
- js_include "#{File.dirname(__FILE__)}/included.js"
3
-
4
- js_base_class "Netzke.ComponentWithIncludedJs"
5
-
6
- action :print_message
7
-
8
- js_property :bbar, [:print_message.action]
9
-
10
- js_method :on_print_message, <<-JS
11
- function(){
12
- this.updateBodyWithMessage("Some message " + "shown in the body");
13
- }
14
- JS
15
-
16
- end
@@ -1,35 +0,0 @@
1
- class ComponentWithSessionPersistence < Netzke::Base
2
- title "Default Title"
3
-
4
- js_property :bbar, [:bug_server.action]
5
-
6
- action :bug_server, :text => "Tell server to store new title"
7
-
8
- def default_config
9
- super.merge(:session_persistence => true)
10
- end
11
-
12
- def configuration
13
- super.merge(:html => component_session[:html_content] || "Default HTML")
14
- end
15
-
16
- js_method :bug_server, <<-JS
17
- function(){
18
- this.whatsUp();
19
- }
20
- JS
21
-
22
- js_method :on_bug_server, <<-JS
23
- function(){
24
- this.bugServer();
25
- }
26
- JS
27
-
28
-
29
- endpoint :whats_up do |params|
30
- update_session_options(:title => "Title From Session") # setting a value in session_options, which will get auto-merged into +config+
31
- component_session[:html_content] = "HTML from session" # setting some custom session key/value, which we use manually in +configuration+
32
- {}
33
- end
34
-
35
- end
@@ -1,20 +0,0 @@
1
- module Deprecated
2
- class ServerCaller < Netzke::Base
3
- js_properties :title => "Server caller",
4
- :bbar => [:call_server.action]
5
-
6
- js_method :on_call_server, <<-JS
7
- function(){
8
- this.whatsUp();
9
- }
10
- JS
11
-
12
- ActiveSupport::Deprecation.silence do
13
- api :whats_up
14
- end
15
-
16
- def whats_up(params)
17
- {:set_title => "Hello from the server!"}
18
- end
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- class DynamicTabPanel < Netzke::Base
2
- js_base_class "Ext.TabPanel"
3
- js_mixin
4
-
5
- action :add_tab
6
-
7
- def default_config
8
- super.tap do |c|
9
- c[:items] = [{
10
- :title => "Tab One"
11
- }]
12
-
13
- c[:bbar] = [:add_tab.action]
14
- end
15
- end
16
-
17
- component :tab_two, :class_name => "SimplePanel", :title => "Tab Two (dynamic)", :lazy_loading => true
18
-
19
- end
@@ -1,31 +0,0 @@
1
- class HelloWorldComponent < Netzke::Base
2
- # Ext.Panel's config option "title"
3
- title "My Hello World Component"
4
-
5
- # Bottom bar with an automatically created action
6
- js_property :bbar, [:bug_server.action]
7
-
8
- # Action to be placed on the bottom bar
9
- action :bug_server, :text => 'Greet the World', :icon => :accept
10
-
11
- # Method in the JS class that (by default) processes the action's "click" event
12
- js_method :on_bug_server, <<-JS
13
- function(){
14
- // Remotely calling the server's method greet_the_world (defined below)
15
- this.greetTheWorld();
16
- }
17
- JS
18
-
19
- # Server's method that gets called from the JS
20
- endpoint :greet_the_world do |params|
21
- # Tell the client side to call its method showGreeting with "Hello World!" as parameter
22
- {:show_greeting => "Hello World!"}
23
- end
24
-
25
- # Another method in the JS class that gets remotely called by the server side
26
- js_method :show_greeting, <<-JS
27
- function(greeting){
28
- this.body.update("Server says: " + greeting);
29
- }
30
- JS
31
- end
@@ -1,25 +0,0 @@
1
- module Touch
2
- class HelloWorldComponent < Netzke::Base
3
- js_base_class "Ext.Panel"
4
-
5
- def configuration
6
- super.merge({
7
- :docked_items => [{:dock => :top, :xtype => :toolbar, :title => 'Hello World Component',
8
- :items => [
9
- {:text => "Greet the World", :handler => :on_bug_server}
10
- ]
11
- }]
12
- })
13
- end
14
-
15
- js_method :on_bug_server, <<-JS
16
- function(){
17
- this.greetTheWorld();
18
- }
19
- JS
20
-
21
- endpoint :greet_the_world do |params|
22
- {:update => "Hello from the server!"}
23
- end
24
- end
25
- end
@@ -1,28 +0,0 @@
1
- module Touch
2
- class ServerCaller < Netzke::Base
3
- js_base_class "Ext.Panel"
4
-
5
- def configuration
6
- super.merge({
7
- :docked_items => [{:dock => :top, :xtype => :toolbar, :title => 'Server Caller', :items => [
8
- {:text => "Bug server", :handler => :on_bug_server}
9
- ]}]
10
- })
11
- end
12
-
13
- js_method :on_bug_server, <<-JS
14
- function(){
15
- if (!this.maskCmp) this.maskCmp = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
16
- this.maskCmp.show();
17
- this.whatsUp({}, function(){
18
- this.maskCmp.hide();
19
- }, this);
20
- }
21
- JS
22
-
23
- endpoint :whats_up do |params|
24
- sleep 1 # for visual testing
25
- {:update => "Hello from the server!"}
26
- end
27
- end
28
- end
@@ -1,17 +0,0 @@
1
- module Touch
2
- class SimpleCarousel < Netzke::Base
3
- js_base_class "Ext.Carousel"
4
-
5
- js_properties(
6
- :fullscreen => true,
7
- :docked_items => [{:dock => :top, :xtype => :toolbar, :title => 'Carousel Toolbar'}]
8
- )
9
-
10
- def configuration
11
- super.merge({:items => [:panel_one.component, :panel_two.component]})
12
- end
13
-
14
- component :panel_one, :class_name => "Touch::ServerCaller", :html => "ServerCaller One"
15
- component :panel_two, :class_name => "Touch::ServerCaller", :html => "ServerCaller Two"
16
- end
17
- end
@@ -1,6 +0,0 @@
1
- class TouchController < ApplicationController
2
- def index
3
- component_name = params[:component].gsub("::", "_").underscore
4
- render :inline => "<%= netzke :#{component_name}, :class_name => 'Touch::#{params[:component]}' %>", :layout => true
5
- end
6
- end
@@ -1,2 +0,0 @@
1
- module TouchHelper
2
- end
@@ -1,13 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Netzke Touch</title>
5
- <%= csrf_meta_tag %>
6
- <%= netzke_init :platform => :touch %>
7
- </head>
8
- <body>
9
-
10
- <%= yield %>
11
-
12
- </body>
13
- </html>
@@ -1,20 +0,0 @@
1
- class CreateNetzkeComponentStates < ActiveRecord::Migration
2
- def self.up
3
- create_table :netzke_component_states do |t|
4
- t.string :component
5
- t.integer :user_id
6
- t.integer :role_id
7
- t.text :value
8
-
9
- t.timestamps
10
- end
11
-
12
- add_index :netzke_component_states, :component
13
- add_index :netzke_component_states, :user_id
14
- add_index :netzke_component_states, :role_id
15
- end
16
-
17
- def self.down
18
- drop_table :netzke_component_states
19
- end
20
- end
@@ -1,3 +0,0 @@
1
- When /^I press button "([^"]*)"$/ do |action|
2
- pending
3
- end
@@ -1,10 +0,0 @@
1
- # Feature: Touch - to be run in Chrome only
2
- # In order to value
3
- # As a role
4
- # I want feature
5
- #
6
- # @javascript
7
- # Scenario: Client-server communication
8
- # Given I am on the ServerCaller page for touch
9
- # When I press button "Bug server"
10
- # Then I should see "Hello from the server!"
@@ -1,16 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'rails', '3.1.4'
4
- gem 'netzke-persistence'
5
-
6
- gem 'mysql2'
7
-
8
- group :test do
9
- gem 'capybara'
10
- gem 'database_cleaner'
11
- gem 'cucumber-rails', :require => false
12
- gem 'cucumber'
13
- gem 'rspec-rails'
14
- gem 'spork'
15
- gem 'launchy' # So you can do Then show me the page
16
- end
@@ -1,16 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'rails', '3.2.3'
4
- gem 'netzke-persistence'
5
-
6
- gem 'mysql2'
7
-
8
- group :test do
9
- gem 'capybara'
10
- gem 'database_cleaner'
11
- gem 'cucumber-rails', :require => false
12
- gem 'cucumber'
13
- gem 'rspec-rails'
14
- gem 'spork'
15
- gem 'launchy' # So you can do Then show me the page
16
- end
@@ -1,36 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'netzke-core'
3
-
4
- describe Netzke::Base do
5
- it "should keep config independent inside class hierarchy" do
6
- class Parent < Netzke::Base
7
- class_attribute :with_feature
8
- self.with_feature = "yes"
9
- end
10
-
11
- class Child < Parent; end
12
-
13
- Parent.with_feature.should == "yes"
14
- Child.with_feature.should == "yes"
15
-
16
- Child.with_feature = "no"
17
-
18
- Parent.with_feature.should == "yes"
19
- Child.with_feature.should == "no"
20
-
21
- Parent.with_feature = "maybe"
22
- Parent.with_feature.should == "maybe"
23
- Child.with_feature.should == "no"
24
- end
25
-
26
- it "should return correct i18n_id" do
27
- module Netzke
28
- module MyComponents
29
- class CoolComponent < Netzke::Base
30
- end
31
- end
32
- end
33
-
34
- Netzke::MyComponents::CoolComponent.new.i18n_id.should == "netzke.my_components.cool_component"
35
- end
36
- end
@@ -1,20 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require "netzke-core"
3
-
4
- describe "Any component" do
5
-
6
- class TestComponent < Netzke::Base
7
-
8
- endpoint :some_action do
9
- {}
10
- end
11
- end
12
-
13
- it "should be able to register endpoints" do
14
- TestComponent.endpoints.should include :some_action
15
- end
16
-
17
- it "should have deliver_component endpoint by default" do
18
- TestComponent.endpoints.should include :deliver_component
19
- end
20
- end
@@ -1,132 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'netzke-core'
3
-
4
- module Netzke
5
- describe Composition do
6
- class SomeComponent < Base
7
- endpoint :method_one
8
- endpoint :method_two
9
-
10
- def self.config
11
- super.merge({
12
- :pref_one => 1,
13
- :pref_two => 2
14
- })
15
- end
16
-
17
- def components
18
- {
19
- :nested_one => {:class_name => 'Netzke::NestedComponentOne'},
20
- :nested_two => {:class_name => 'Netzke::NestedComponentTwo'}
21
- }
22
- end
23
-
24
- def available_permissions
25
- %w(read update)
26
- end
27
-
28
- def default_config
29
- {
30
- :config_uno => true,
31
- :config_dos => false
32
- }
33
- end
34
- end
35
-
36
- class NestedComponentOne < Base
37
- end
38
-
39
- class NestedComponentTwo < Base
40
- def components
41
- {
42
- :nested => {:class_name => 'Netzke::DeepNestedComponent'}
43
- }
44
- end
45
- end
46
-
47
- class DeepNestedComponent < Base
48
- def components
49
- {
50
- :nested => {:class_name => "Netzke::VeryDeepNestedComponent"}
51
- }
52
- end
53
- end
54
-
55
- class VeryDeepNestedComponent < Base
56
- end
57
-
58
- class ComponentOne < Base
59
- end
60
-
61
- class ComponentTwo < Base
62
- end
63
-
64
- class SomeComposite < Base
65
- component :component_one do
66
- {
67
- :class_name => "Netzke::ComponentOne",
68
- :title => "My Cool Component"
69
- }
70
- end
71
-
72
- def config
73
- {
74
- :items => [
75
- {:class_name => "Netzke::ComponentTwo", :name => "my_component_two"},
76
- {:class_name => "Netzke::ComponentTwo"} # name omitted, will be "netzke_1"
77
- ]
78
- }.deep_merge super
79
- end
80
- end
81
-
82
- it "should be possible to create (nested) component instances" do
83
- component = SomeComponent.new(:name => 'some_component')
84
-
85
- # instantiate components
86
- nested_component_one = component.component_instance(:nested_one)
87
- nested_component_two = component.component_instance(:nested_two)
88
- deep_nested_component = component.component_instance(:nested_two__nested)
89
-
90
- nested_component_one.class.should == NestedComponentOne
91
- nested_component_two.class.should == NestedComponentTwo
92
- deep_nested_component.class.should == DeepNestedComponent
93
-
94
- component.global_id.should == 'some_component'
95
- nested_component_one.global_id.should == 'some_component__nested_one'
96
- nested_component_two.global_id.should == 'some_component__nested_two'
97
- deep_nested_component.global_id.should == 'some_component__nested_two__nested'
98
- end
99
-
100
- it "should be possible to define nested components in different ways" do
101
- composite = SomeComposite.new
102
- components = composite.components
103
-
104
- components.keys.size.should == 3
105
- components[:component_one][:class_name].should == "Netzke::ComponentOne"
106
- components[:my_component_two][:class_name].should == "Netzke::ComponentTwo"
107
- components[:netzke_1][:class_name].should == "Netzke::ComponentTwo"
108
-
109
- end
110
-
111
- # DIDN'T WORK OUT till now
112
- # it "should be possible to override the superclass's declaration of a component" do
113
- # composite = SomeComposite.new
114
- # composite.components[:component_one][:title].should == "My Cool Component"
115
- #
116
- # class ExtendedComposite < SomeComposite
117
- # component :component_one do |orig|
118
- # orig.merge(:title => orig[:title] + ", extended")
119
- # end
120
- #
121
- # component :component_two do
122
- # {:title => "Another Nested Component"}
123
- # end
124
- # end
125
- #
126
- # extended_composite = ExtendedComposite.new
127
- # extended_composite.components[:component_one][:title].should == "My Cool Component, extended"
128
- # extended_composite.components[:component_one][:class_name].should == "ComponentOne"
129
- # extended_composite.components[:component_two][:title].should == "Another Nested Component"
130
- # end
131
- end
132
- end