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
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ class Parent < Netzke::Base
4
+ class_attribute :with_feature
5
+ self.with_feature = "yes"
6
+ end
7
+
8
+ class Child < Parent; end
9
+
10
+ module Netzke
11
+ module MyComponents
12
+ class CoolComponent < Netzke::Base
13
+ end
14
+ end
15
+ end
16
+
17
+ describe Netzke::Base do
18
+ it "should preserve class config within class hierarchy" do
19
+ Parent.with_feature.should == "yes"
20
+ Child.with_feature.should == "yes"
21
+
22
+ Child.with_feature = "no"
23
+
24
+ Parent.with_feature.should == "yes"
25
+ Child.with_feature.should == "no"
26
+
27
+ Parent.with_feature = "maybe"
28
+ Parent.with_feature.should == "maybe"
29
+ Child.with_feature.should == "no"
30
+ end
31
+
32
+ it "should return correct i18n_id" do
33
+ Netzke::MyComponents::CoolComponent.i18n_id.should == "netzke.my_components.cool_component"
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ class MyComponent < Netzke::Base
4
+ js_configure do |c|
5
+ c.title = "My stupid component"
6
+ end
7
+ end
8
+
9
+ describe Netzke::Core::ClientClass do
10
+ it "should allow reading class-level properties" do
11
+ MyComponent.js_config.title.should == "My stupid component"
12
+ end
13
+
14
+ it "should return nil when non-existing property is requested" do
15
+ MyComponent.js_config.foo.should be_nil
16
+ end
17
+ end
File without changes
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ class SomeComposite < Netzke::Base
4
+ component :nested_one do |c|
5
+ c.klass = NestedComponentOne
6
+ end
7
+
8
+ component :nested_two do |c|
9
+ c.klass = NestedComponentTwo
10
+ end
11
+ end
12
+
13
+ class NestedComponentOne < Netzke::Base
14
+ end
15
+
16
+ class NestedComponentTwo < Netzke::Base
17
+ component :nested do |c|
18
+ c.klass = DeepNestedComponent
19
+ end
20
+ end
21
+
22
+ class DeepNestedComponent < Netzke::Base
23
+ component :nested do |c|
24
+ c.klass = VeryDeepNestedComponent
25
+ end
26
+ end
27
+
28
+ class VeryDeepNestedComponent < Netzke::Base
29
+ end
30
+
31
+ class ComponentOne < Netzke::Base
32
+ end
33
+
34
+ class ::ComponentTwo < Netzke::Base
35
+ end
36
+
37
+ class BaseComposite < Netzke::Base
38
+ component :component_one do |c|
39
+ c.klass = ComponentOne
40
+ c.title = "My Cool Component"
41
+ end
42
+
43
+ component :first_component_two do |c|
44
+ c.klass = ComponentTwo
45
+ end
46
+
47
+ component :second_component_two do |c|
48
+ c.klass = ComponentTwo
49
+ end
50
+
51
+ def configure(c)
52
+ super
53
+ c.items = [ :first_component_two, :second_component_two ]
54
+ end
55
+ end
56
+
57
+ class ExtendedComposite < BaseComposite
58
+ component :component_one do |c|
59
+ super c
60
+ c.title = c.title + ", extended"
61
+ end
62
+
63
+ component :component_two do |c|
64
+ c.title = "Another Nested Component"
65
+ end
66
+ end
67
+
68
+ class ComponentWithExcluded < Netzke::Base
69
+ component :accessible do |c|
70
+ c.klass = Netzke::Core::Panel
71
+ end
72
+ component :inaccessible do |c|
73
+ c.klass = Netzke::Core::Panel
74
+ c.excluded = true
75
+ end
76
+ end
77
+
78
+ module Netzke::Core
79
+ describe Composition do
80
+ it "should set item_id to component's name by default" do
81
+ component = SomeComposite.new(:name => 'some_composite')
82
+ component.components[:nested_one][:item_id].should == "nested_one"
83
+ end
84
+
85
+ it "should be possible to create (nested) component instances" do
86
+ component = SomeComposite.new(:name => 'some_composite')
87
+
88
+ # instantiate components
89
+ nested_component_one = component.component_instance(:nested_one)
90
+ nested_component_two = component.component_instance(:nested_two)
91
+ deep_nested_component = component.component_instance(:nested_two__nested)
92
+
93
+ nested_component_one.class.should == NestedComponentOne
94
+ nested_component_two.class.should == NestedComponentTwo
95
+ deep_nested_component.class.should == DeepNestedComponent
96
+
97
+ component.js_id.should == 'some_composite'
98
+ nested_component_one.js_id.should == 'some_composite__nested_one'
99
+ nested_component_two.js_id.should == 'some_composite__nested_two'
100
+ deep_nested_component.js_id.should == 'some_composite__nested_two__nested'
101
+ end
102
+
103
+ it "should be possible to override the superclass's declaration of a component" do
104
+ composite = BaseComposite.new
105
+ composite.components[:component_one][:title].should == "My Cool Component"
106
+
107
+ extended_composite = ExtendedComposite.new
108
+ extended_composite.components[:component_one][:title].should == "My Cool Component, extended"
109
+ extended_composite.components[:component_one][:klass].should == ComponentOne
110
+ extended_composite.components[:component_two][:title].should == "Another Nested Component"
111
+ end
112
+
113
+ it "should be impossible to access excluded component config" do
114
+ c = ComponentWithExcluded.new
115
+ c.components[:inaccessible].should == {excluded: true}
116
+ end
117
+ end
118
+ end
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  describe "Core extensions" do
2
3
  it "should properly do deep_each_pair" do
3
4
  res = {}
@@ -12,19 +13,7 @@ describe "Core extensions" do
12
13
  res.should == {:one => 1, :three => 3, :four => 4, :six => 6, :eight => 8}
13
14
  end
14
15
 
15
- it "should jsonify '_meta' to '_meta'" do
16
- '_meta'.jsonify.should == '_meta'
17
- end
18
-
19
- it "should jsonify '_meta_data' to '_metaData'" do
20
- '_meta_data'.jsonify.should == '_metaData'
21
- end
22
-
23
- it "should jsonify 'some_property' to 'someProperty'" do
24
- 'some_property'.jsonify.should == 'someProperty'
25
- end
26
-
27
- it "should jsonify :_meta to :_meta" do
28
- :_meta.jsonify.should == :_meta
16
+ it "should properly do deep_map" do
17
+ {a: [1,2,{b:3},{c:[4,5]}], d: 6}.deep_map{|el| el.is_a?(Hash) ? el.merge(e:7) : el + 10}.should == { a: [11,12,{e:7, b:3},{e:7, c:[14,15]}], d: 6}
29
18
  end
30
19
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Netzke::Core::EndpointResponse do
4
+ it "should allow to mimick calling methods on client side" do
5
+ this = Netzke::Core::EndpointResponse.new
6
+
7
+ this.set_title("Title")
8
+ this.set_title.should == ["Title"]
9
+ end
10
+
11
+ it "should allow assigning values directly" do
12
+ this = Netzke::Core::EndpointResponse.new
13
+
14
+ this.result = 42
15
+ this.result.should == 42
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ class HasMultipleJsConfigures < Netzke::Base
4
+ js_configure do |c|
5
+ c.title = "Original"
6
+ c.some_property = :some_property
7
+ end
8
+
9
+ # because this could be done from an included module
10
+ js_configure do |c|
11
+ c.title = "Overridden"
12
+ c.another_property = :another_property
13
+ end
14
+ end
15
+
16
+ describe Netzke::Core::Javascript do
17
+ it "should provide JS config from a component instance" do
18
+ c = Netzke::Core::Panel.new
19
+ c.js_config.should be_present
20
+ end
21
+
22
+ it "should evaluate js_configure class-level block late" do
23
+ ConfigurableOnClassLevel.title = "Overridden"
24
+ ConfigurableOnClassLevel.js_config.title.should == "Overridden"
25
+ end
26
+
27
+ it "should evaluate all js_configure blocks" do
28
+ c = HasMultipleJsConfigures.js_config
29
+ c.title.should == "Overridden"
30
+ c.some_property.should == :some_property
31
+ c.another_property.should == :another_property
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ class SomeComponent < Netzke::Base
4
+ end
5
+
6
+ module MyCompanyComponents
7
+ class SomeComponent < Netzke::Base
8
+ end
9
+ end
10
+
11
+ class InheritedComponent < SomeComponent
12
+ end
13
+
14
+ module Netzke
15
+ module Basepack
16
+ class GridPanel < Netzke::Base
17
+ end
18
+ end
19
+ end
20
+
21
+ describe Netzke::Core::ClientClass do
22
+ it "should build scope based on component scope" do
23
+ SomeComponent.js_config.scope.should == "Netzke.classes"
24
+ MyCompanyComponents::SomeComponent.js_config.scope.should == "Netzke.classes.MyCompanyComponents"
25
+ end
26
+
27
+ it "should properly detect whether we are extending a Netzke component" do
28
+ SomeComponent.js_config.extending_extjs_component?.should be_true
29
+ InheritedComponent.js_config.extending_extjs_component?.should be_false
30
+ end
31
+
32
+ it "should build full client class name based on class name" do
33
+ SomeComponent.js_config.class_name.should == "Netzke.classes.SomeComponent"
34
+ MyCompanyComponents::SomeComponent.js_config.class_name.should == "Netzke.classes.MyCompanyComponents.SomeComponent"
35
+ Netzke::Basepack::GridPanel.js_config.class_name.should == "Netzke.classes.Netzke.Basepack.GridPanel"
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ class MyPanel < Netzke::Core::Panel
4
+ end
5
+
6
+ describe Netzke::Core::Panel do
7
+ it "should set default title based on its name" do
8
+ panel = MyPanel.new(name: 'just_panel')
9
+ panel.config.title.should == "Just panel"
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ class TestComponent < Netzke::Base
4
+ endpoint :some_action do |params, this|
5
+ end
6
+ end
7
+
8
+ describe Netzke::Core::Services do
9
+ it "should be able to register endpoints" do
10
+ TestComponent.endpoints.should include :some_action
11
+ end
12
+
13
+ it "should have deliver_component endpoint" do
14
+ TestComponent.endpoints.should include :deliver_component
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ module Netzke::Core
4
+ describe State do
5
+ it "should be possible to save component's state" do
6
+ Netzke::Base.session = {} # mimick session
7
+
8
+ component = Netzke::Base.new(:name => 'some_component', :persistence => true)
9
+ component.state.should == {}
10
+
11
+ component.state[:value_to_remember] = 42
12
+ component.state.should == {:value_to_remember => 42}
13
+
14
+ component.state[:more_to_remember] = "a string"
15
+ component.state[:and_yet_more] = "another string"
16
+
17
+ component.state.should == {:value_to_remember => 42, :more_to_remember => "a string", :and_yet_more => "another string"}
18
+ end
19
+ end
20
+ end
@@ -2,60 +2,7 @@ require 'test_helper'
2
2
  require 'netzke/core_ext'
3
3
 
4
4
  class CoreExtTest < ActiveSupport::TestCase
5
- test "recursive delete if nil" do
6
- assert_equal({:a => 1, :b => {:c => 4, :d => 5}}, {:a => 1, :aa => nil, :b => {:c => 4, :d => 5, :cc => nil}}.recursive_delete_if_nil)
7
-
8
- assert_equal({:a => [{:e => 5}, {:f => 7}], :b => {:c => 4, :d => 5}}, {:a => [{:e => 5, :ee => nil},{:f => 7, :ff => nil}], :aa => nil, :b => {:c => 4, :d => 5, :cc => nil}}.recursive_delete_if_nil)
9
-
10
- assert_equal([
11
- {:a => [{:e => 5}]},
12
- {},
13
- {:b => {:c => 4, :d => 5}}
14
- ], [
15
- {:a => [{:e => 5, :ee => nil}]},
16
- {:aa => nil},
17
- {:b => {:c => 4, :d => 5, :cc => nil}}
18
- ].recursive_delete_if_nil)
19
- end
20
-
21
- test "convert keys" do
22
- assert_equal({:a => 1, :b => {:bb => 2}}, {"a" => 1, "b" => {"bb" => 2}}.deep_convert_keys{ |k| k.to_sym })
23
- assert_equal([{"a" => 1}, {"b" => {"bb" => 2}}], [{:a => 1}, {:b => {:bb => 2}}].deep_convert_keys{ |k| k.to_s })
24
-
25
- assert_equal([
26
- {:aB => 1, :cDD => [{:lookMa => true},{:wowNow => true}]}
27
- ],[:a_b => 1, :c_d_d => [{:look_ma => true},{:wow_now => true}]].deep_convert_keys{|k| k.to_s.camelize(:lower).to_sym})
28
- end
29
-
30
5
  test "jsonify" do
31
6
  assert_equal({:aB => 1, "cD" => [[1, {:eF => "stay_same"}], {"literal_symbol" => :should_not_change, "literal_string".l => "also_should_not"}]}, {:a_b => 1, "c_d" => [[1, {:e_f => "stay_same"}], {:literal_symbol.l => :should_not_change, "literal_string".l => "also_should_not"}]}.jsonify)
32
7
  end
33
-
34
- test "flatten_with_type" do
35
- test_flatten_with_type = {
36
- :one => 1,
37
- :two => 2.5,
38
- :three => {
39
- :four => true,
40
- :five => {
41
- :six => "a string"
42
- }
43
- }
44
- }.flatten_with_type
45
-
46
- assert_equal(4, test_flatten_with_type.size)
47
-
48
- test_flatten_with_type.each do |i|
49
- assert([{
50
- :name => :one, :value => 1, :type => :Fixnum
51
- },{
52
- :name => :two, :value => 2.5, :type => :Float
53
- },{
54
- :name => :three__four, :value => true, :type => :Boolean
55
- },{
56
- :name => :three__five__six, :value => "a string", :type => :String
57
- }].include?(i))
58
- end
59
- end
60
-
61
8
  end
@@ -97,21 +97,21 @@ class NetzkeCoreTest < ActiveSupport::TestCase
97
97
  assert_kind_of NestedComponentTwo, nested_component_two
98
98
  assert_kind_of DeepNestedComponent, deep_nested_component
99
99
 
100
- assert_equal 'my_component', component.global_id
101
- assert_equal 'my_component__nested_one', nested_component_one.global_id
102
- assert_equal 'my_component__nested_two', nested_component_two.global_id
103
- assert_equal 'my_component__nested_two__nested', deep_nested_component.global_id
100
+ assert_equal 'my_component', component.js_id
101
+ assert_equal 'my_component__nested_one', nested_component_one.js_id
102
+ assert_equal 'my_component__nested_two', nested_component_two.js_id
103
+ assert_equal 'my_component__nested_two__nested', deep_nested_component.js_id
104
104
  end
105
105
 
106
- test "global_id_by_reference" do
106
+ test "js_id_by_reference" do
107
107
  w = Component.new(:name => "a_component")
108
108
  deep_nested_component = w.component_instance(:nested_two__nested)
109
- assert_equal("a_component__nested_two", deep_nested_component.global_id_by_reference(:parent))
110
- assert_equal("a_component", deep_nested_component.global_id_by_reference(:parent__parent))
111
- assert_equal("a_component__nested_one", deep_nested_component.global_id_by_reference(:parent__parent__nested_one))
112
- assert_equal("a_component__nested_two__nested__nested", deep_nested_component.global_id_by_reference(:nested))
113
- assert_equal("a_component__nested_two__nested__non_existing", deep_nested_component.global_id_by_reference(:non_existing))
114
- assert_nil(deep_nested_component.global_id_by_reference(:parent__parent__parent)) # too far up
109
+ assert_equal("a_component__nested_two", deep_nested_component.js_id_by_reference(:parent))
110
+ assert_equal("a_component", deep_nested_component.js_id_by_reference(:parent__parent))
111
+ assert_equal("a_component__nested_one", deep_nested_component.js_id_by_reference(:parent__parent__nested_one))
112
+ assert_equal("a_component__nested_two__nested__nested", deep_nested_component.js_id_by_reference(:nested))
113
+ assert_equal("a_component__nested_two__nested__non_existing", deep_nested_component.js_id_by_reference(:non_existing))
114
+ assert_nil(deep_nested_component.js_id_by_reference(:parent__parent__parent)) # too far up
115
115
  end
116
116
 
117
117
  test "default config" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netzke-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-20 00:00:00.000000000 Z
12
+ date: 2012-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70172615787600 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,9 +21,13 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70172615787600
25
- description: Allows building DRY Sencha Ext JS Ruby on Rails applications by enabling
26
- modular development
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.1.0
30
+ description: Allows building complex RIA by greatly facilitating modular development
27
31
  email: nmcoder@gmail.com
28
32
  executables: []
29
33
  extensions: []
@@ -33,7 +37,7 @@ extra_rdoc_files:
33
37
  files:
34
38
  - .autotest
35
39
  - .travis.yml
36
- - CHANGELOG.rdoc
40
+ - CHANGELOG.md
37
41
  - LICENSE
38
42
  - Manifest
39
43
  - README.md
@@ -44,45 +48,44 @@ files:
44
48
  - init.rb
45
49
  - install.rb
46
50
  - javascripts/base.js
47
- - javascripts/core_extensions.js
48
51
  - javascripts/ext.js
49
- - javascripts/touch.js
52
+ - javascripts/js_extensions.js
50
53
  - lib/netzke-core.rb
51
- - lib/netzke/actions.rb
52
54
  - lib/netzke/base.rb
53
- - lib/netzke/composition.rb
54
- - lib/netzke/config_to_dsl_delegator.rb
55
- - lib/netzke/configuration.rb
56
55
  - lib/netzke/core.rb
56
+ - lib/netzke/core/action_config.rb
57
+ - lib/netzke/core/actions.rb
58
+ - lib/netzke/core/client_class.rb
59
+ - lib/netzke/core/component_config.rb
60
+ - lib/netzke/core/composition.rb
61
+ - lib/netzke/core/config_to_dsl_delegator.rb
62
+ - lib/netzke/core/configuration.rb
63
+ - lib/netzke/core/css_config.rb
57
64
  - lib/netzke/core/dynamic_assets.rb
58
- - lib/netzke/core/masquerading.rb
65
+ - lib/netzke/core/embedding.rb
66
+ - lib/netzke/core/endpoint_response.rb
67
+ - lib/netzke/core/javascript.rb
59
68
  - lib/netzke/core/options_hash.rb
69
+ - lib/netzke/core/panel.rb
70
+ - lib/netzke/core/plugins.rb
71
+ - lib/netzke/core/railz.rb
72
+ - lib/netzke/core/railz/action_view_ext.rb
73
+ - lib/netzke/core/railz/action_view_ext/ext.rb
74
+ - lib/netzke/core/railz/controller_extensions.rb
75
+ - lib/netzke/core/railz/engine.rb
76
+ - lib/netzke/core/railz/routes.rb
77
+ - lib/netzke/core/ruby_ext.rb
78
+ - lib/netzke/core/ruby_ext/array.rb
79
+ - lib/netzke/core/ruby_ext/hash.rb
80
+ - lib/netzke/core/ruby_ext/string.rb
81
+ - lib/netzke/core/ruby_ext/symbol.rb
82
+ - lib/netzke/core/ruby_ext/time_with_zone.rb
83
+ - lib/netzke/core/services.rb
60
84
  - lib/netzke/core/session.rb
85
+ - lib/netzke/core/state.rb
86
+ - lib/netzke/core/stylesheets.rb
61
87
  - lib/netzke/core/version.rb
62
- - lib/netzke/core_ext.rb
63
- - lib/netzke/core_ext/array.rb
64
- - lib/netzke/core_ext/hash.rb
65
- - lib/netzke/core_ext/string.rb
66
- - lib/netzke/core_ext/symbol.rb
67
- - lib/netzke/core_ext/time_with_zone.rb
68
- - lib/netzke/embedding.rb
69
- - lib/netzke/ext_component.rb
70
- - lib/netzke/inheritance.rb
71
- - lib/netzke/javascript.rb
72
- - lib/netzke/javascript/scopes.rb
73
88
  - lib/netzke/plugin.rb
74
- - lib/netzke/plugins.rb
75
- - lib/netzke/railz.rb
76
- - lib/netzke/railz/action_view_ext.rb
77
- - lib/netzke/railz/action_view_ext/ext.rb
78
- - lib/netzke/railz/action_view_ext/touch.rb
79
- - lib/netzke/railz/controller_extensions.rb
80
- - lib/netzke/railz/engine.rb
81
- - lib/netzke/railz/routes.rb
82
- - lib/netzke/services.rb
83
- - lib/netzke/session.rb
84
- - lib/netzke/state.rb
85
- - lib/netzke/stylesheets.rb
86
89
  - lib/tasks/netzke_core_tasks.rake
87
90
  - netzke-core.gemspec
88
91
  - stylesheets/core.css
@@ -96,10 +99,10 @@ files:
96
99
  - test/core_test_app/app/components/border_layout_panel.rb
97
100
  - test/core_test_app/app/components/card_component_loader.rb
98
101
  - test/core_test_app/app/components/component_loader.rb
102
+ - test/core_test_app/app/components/component_loader/javascripts/component_loader.js
99
103
  - test/core_test_app/app/components/component_with_actions.rb
100
104
  - test/core_test_app/app/components/component_with_custom_css.rb
101
105
  - test/core_test_app/app/components/component_with_custom_css/stylesheets/custom.css
102
- - test/core_test_app/app/components/component_with_included_js.rb
103
106
  - test/core_test_app/app/components/component_with_js_mixin.rb
104
107
  - test/core_test_app/app/components/component_with_js_mixin/javascripts/component_with_js_mixin.js
105
108
  - test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_one.js
@@ -107,9 +110,12 @@ files:
107
110
  - test/core_test_app/app/components/component_with_js_mixin/javascripts/method_set_one.js
108
111
  - test/core_test_app/app/components/component_with_js_mixin/javascripts/method_set_two.js
109
112
  - test/core_test_app/app/components/component_with_nested_through.rb
110
- - test/core_test_app/app/components/component_with_session_persistence.rb
111
- - test/core_test_app/app/components/deprecated/server_caller.rb
112
- - test/core_test_app/app/components/dynamic_tab_panel.rb
113
+ - test/core_test_app/app/components/component_with_prebuilt_toolbar_control.rb
114
+ - test/core_test_app/app/components/component_with_prebuilt_toolbar_control/javascripts/component_with_prebuilt_toolbar_control.js
115
+ - test/core_test_app/app/components/component_with_required_js.rb
116
+ - test/core_test_app/app/components/configurable_on_class_level.rb
117
+ - test/core_test_app/app/components/dsl_delegated_properties.rb
118
+ - test/core_test_app/app/components/dsl_delegated_properties_base.rb
113
119
  - test/core_test_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js
114
120
  - test/core_test_app/app/components/ext_direct/composite.rb
115
121
  - test/core_test_app/app/components/ext_direct/details.rb
@@ -120,7 +126,8 @@ files:
120
126
  - test/core_test_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js
121
127
  - test/core_test_app/app/components/extended_localized_panel.rb
122
128
  - test/core_test_app/app/components/extended_server_caller.rb
123
- - test/core_test_app/app/components/hello_world_component.rb
129
+ - test/core_test_app/app/components/hello_world.rb
130
+ - test/core_test_app/app/components/hello_world/javascripts/hello_world.js
124
131
  - test/core_test_app/app/components/included.js
125
132
  - test/core_test_app/app/components/inline_composite.rb
126
133
  - test/core_test_app/app/components/kinda_complex_component.rb
@@ -137,32 +144,35 @@ files:
137
144
  - test/core_test_app/app/components/scoped_components/extended_scoped_component.rb
138
145
  - test/core_test_app/app/components/scoped_components/some_scoped_component.rb
139
146
  - test/core_test_app/app/components/server_caller.rb
147
+ - test/core_test_app/app/components/server_caller/javascripts/server_caller.js
140
148
  - test/core_test_app/app/components/server_counter.rb
149
+ - test/core_test_app/app/components/server_counter/javascripts/server_counter.js
150
+ - test/core_test_app/app/components/simple_authentication_component.rb
141
151
  - test/core_test_app/app/components/simple_component.rb
152
+ - test/core_test_app/app/components/simple_composite.rb
153
+ - test/core_test_app/app/components/simple_form_with_file_upload.rb
142
154
  - test/core_test_app/app/components/simple_panel.rb
143
155
  - test/core_test_app/app/components/simple_tab_panel.rb
144
156
  - test/core_test_app/app/components/simple_window.rb
145
157
  - test/core_test_app/app/components/some_composite.rb
146
158
  - test/core_test_app/app/components/some_ext_component.rb
147
159
  - test/core_test_app/app/components/some_plugin.rb
148
- - test/core_test_app/app/components/touch/hello_world_component.rb
149
- - test/core_test_app/app/components/touch/server_caller.rb
150
- - test/core_test_app/app/components/touch/simple_carousel.rb
160
+ - test/core_test_app/app/components/stateful_component.rb
161
+ - test/core_test_app/app/components/stateful_component_with_shared_state.rb
162
+ - test/core_test_app/app/components/window_with_simple_component.rb
151
163
  - test/core_test_app/app/controllers/application_controller.rb
152
164
  - test/core_test_app/app/controllers/components_controller.rb
153
165
  - test/core_test_app/app/controllers/simple_rails_controller.rb
154
- - test/core_test_app/app/controllers/touch_controller.rb
155
166
  - test/core_test_app/app/controllers/welcome_controller.rb
156
167
  - test/core_test_app/app/helpers/application_helper.rb
157
- - test/core_test_app/app/helpers/touch_helper.rb
158
168
  - test/core_test_app/app/views/components/panel_with_autoload.html.erb
159
169
  - test/core_test_app/app/views/components/some_tab_panel.html.erb
160
170
  - test/core_test_app/app/views/layouts/application.html.erb
161
171
  - test/core_test_app/app/views/layouts/nested.html.erb
162
- - test/core_test_app/app/views/layouts/touch.html.erb
163
172
  - test/core_test_app/app/views/simple_rails/multiple_nested.html.erb
164
173
  - test/core_test_app/app/views/simple_rails/multiple_of_different_class.html.erb
165
174
  - test/core_test_app/app/views/simple_rails/multiple_of_same_class.html.erb
175
+ - test/core_test_app/app/views/simple_rails/panel.html.erb
166
176
  - test/core_test_app/config.ru
167
177
  - test/core_test_app/config/application.rb
168
178
  - test/core_test_app/config/boot.rb
@@ -182,7 +192,6 @@ files:
182
192
  - test/core_test_app/config/locales/es.yml
183
193
  - test/core_test_app/config/routes.rb
184
194
  - test/core_test_app/db/development_structure.sql
185
- - test/core_test_app/db/migrate/20110110132720_create_netzke_component_states.rb
186
195
  - test/core_test_app/db/schema.rb
187
196
  - test/core_test_app/db/seeds.rb
188
197
  - test/core_test_app/features/actions_and_tools.feature
@@ -192,6 +201,7 @@ files:
192
201
  - test/core_test_app/features/component.feature
193
202
  - test/core_test_app/features/component_loader.feature
194
203
  - test/core_test_app/features/composition.feature
204
+ - test/core_test_app/features/config_to_dsl_delegation.feature
195
205
  - test/core_test_app/features/custom_css.feature
196
206
  - test/core_test_app/features/ext.direct.feature
197
207
  - test/core_test_app/features/file_inclusion.feature
@@ -205,31 +215,35 @@ files:
205
215
  - test/core_test_app/features/scopes.feature
206
216
  - test/core_test_app/features/step_definitions/custom_css_steps.rb
207
217
  - test/core_test_app/features/step_definitions/generic_steps.rb
208
- - test/core_test_app/features/step_definitions/touch_steps.rb
209
218
  - test/core_test_app/features/step_definitions/web_steps.rb
210
219
  - test/core_test_app/features/support/env.rb
211
220
  - test/core_test_app/features/support/paths.rb
212
- - test/core_test_app/features/touch.feature
213
- - test/core_test_app/gemfiles/rails3_1.gemfile
214
- - test/core_test_app/gemfiles/rails3_2.gemfile
215
221
  - test/core_test_app/lib/tasks/.gitkeep
216
222
  - test/core_test_app/public/404.html
217
223
  - test/core_test_app/public/422.html
218
224
  - test/core_test_app/public/500.html
219
225
  - test/core_test_app/public/favicon.ico
226
+ - test/core_test_app/public/images/icons/accept.png
227
+ - test/core_test_app/public/images/icons/anchor.png
228
+ - test/core_test_app/public/images/icons/tick.png
220
229
  - test/core_test_app/public/images/rails.png
221
230
  - test/core_test_app/public/robots.txt
222
231
  - test/core_test_app/script/rails
223
- - test/core_test_app/spec/component/actions_spec.rb
224
- - test/core_test_app/spec/component/base_spec.rb
225
- - test/core_test_app/spec/component/component_spec.rb
226
- - test/core_test_app/spec/component/composition_spec.rb
227
- - test/core_test_app/spec/component/configuration_spec.rb
228
- - test/core_test_app/spec/component/javascript_spec.rb
229
- - test/core_test_app/spec/component/state_spec.rb
232
+ - test/core_test_app/spec/action_config_spec.rb
233
+ - test/core_test_app/spec/actions_spec.rb
234
+ - test/core_test_app/spec/base_spec.rb
235
+ - test/core_test_app/spec/client_class_spec.rb
236
+ - test/core_test_app/spec/component
237
+ - test/core_test_app/spec/composition_spec.rb
230
238
  - test/core_test_app/spec/core_ext_spec.rb
239
+ - test/core_test_app/spec/endpoint_response_spec.rb
240
+ - test/core_test_app/spec/javascript_spec.rb
241
+ - test/core_test_app/spec/js_class_config_scope.rb
242
+ - test/core_test_app/spec/panel_spec.rb
243
+ - test/core_test_app/spec/services_spec.rb
231
244
  - test/core_test_app/spec/spec.opt
232
245
  - test/core_test_app/spec/spec_helper.rb
246
+ - test/core_test_app/spec/state_spec.rb
233
247
  - test/core_test_app/tmp/restart.txt
234
248
  - test/core_test_app/vendor/plugins/.gitkeep
235
249
  - test/test_helper.rb
@@ -256,8 +270,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
270
  version: '0'
257
271
  requirements: []
258
272
  rubyforge_project:
259
- rubygems_version: 1.8.10
273
+ rubygems_version: 1.8.24
260
274
  signing_key:
261
275
  specification_version: 3
262
- summary: Build complex Sencha Ext JS Ruby on Rails components with minimum effort
276
+ summary: Client-server GUI components with Sencha Ext JS and Ruby
263
277
  test_files: []