netzke-core 0.6.2 → 0.6.3

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 (73) hide show
  1. data/CHANGELOG.rdoc +9 -6
  2. data/README.rdoc +14 -15
  3. data/Rakefile +20 -15
  4. data/TODO +1 -1
  5. data/app/controllers/netzke_controller.rb +9 -9
  6. data/app/models/netzke_preference.rb +27 -27
  7. data/features/actions.feature +1 -1
  8. data/features/basic.feature +1 -1
  9. data/features/client-server.feature +1 -1
  10. data/features/component_loader.feature +6 -7
  11. data/features/composition.feature +5 -6
  12. data/features/custom_css.feature +1 -1
  13. data/features/inheritance.feature +0 -1
  14. data/features/persistence.feature +3 -3
  15. data/features/scopes.feature +3 -3
  16. data/features/step_definitions/web_steps.rb +5 -5
  17. data/features/support/env.rb +6 -6
  18. data/generators/netzke_core/netzke_core_generator.rb +2 -2
  19. data/javascripts/core.js +43 -43
  20. data/lib/generators/migration_helper.rb +6 -6
  21. data/lib/generators/netzke/USAGE +2 -3
  22. data/lib/generators/netzke/core_generator.rb +7 -7
  23. data/lib/netzke/actions.rb +18 -18
  24. data/lib/netzke/base.rb +72 -85
  25. data/lib/netzke/composition.rb +30 -30
  26. data/lib/netzke/configuration.rb +15 -15
  27. data/lib/netzke/core/masquerading.rb +3 -3
  28. data/lib/netzke/core/session.rb +1 -1
  29. data/lib/netzke/core/version.rb +1 -1
  30. data/lib/netzke/core.rb +9 -9
  31. data/lib/netzke/core_ext/array.rb +5 -5
  32. data/lib/netzke/core_ext/hash.rb +7 -7
  33. data/lib/netzke/core_ext/string.rb +4 -4
  34. data/lib/netzke/core_ext/symbol.rb +3 -3
  35. data/lib/netzke/embedding.rb +2 -2
  36. data/lib/netzke/ext_component.rb +4 -4
  37. data/lib/netzke/javascript.rb +36 -25
  38. data/lib/netzke/persistence.rb +16 -16
  39. data/lib/netzke/rails/action_view_ext.rb +20 -20
  40. data/lib/netzke/rails/controller_extensions.rb +1 -1
  41. data/lib/netzke/rails/routes.rb +1 -1
  42. data/lib/netzke/services.rb +12 -12
  43. data/lib/netzke/session.rb +4 -4
  44. data/lib/netzke/stylesheets.rb +8 -8
  45. data/lib/netzke-core.rb +2 -2
  46. data/netzke-core.gemspec +4 -5
  47. data/spec/component/actions_spec.rb +18 -18
  48. data/spec/component/base_spec.rb +6 -6
  49. data/spec/component/composition_spec.rb +12 -12
  50. data/spec/component/javascript_spec.rb +2 -2
  51. data/spec/core_ext_spec.rb +3 -3
  52. data/templates/core/create_netzke_preferences.rb +1 -1
  53. data/test/rails_app/app/components/component_loader.rb +8 -8
  54. data/test/rails_app/app/components/component_with_actions.rb +9 -9
  55. data/test/rails_app/app/components/component_with_custom_css.rb +2 -2
  56. data/test/rails_app/app/components/component_with_included_js.rb +5 -5
  57. data/test/rails_app/app/components/component_with_session_persistence.rb +3 -3
  58. data/test/rails_app/app/components/deprecated/server_caller.rb +2 -2
  59. data/test/rails_app/app/components/extended_component_with_actions.rb +1 -1
  60. data/test/rails_app/app/components/extended_server_caller.rb +3 -3
  61. data/test/rails_app/app/components/kinda_complex_component/basic_stuff.rb +8 -8
  62. data/test/rails_app/app/components/kinda_complex_component/extra_stuff.rb +2 -2
  63. data/test/rails_app/app/components/loader_of_component_with_custom_css.rb +2 -2
  64. data/test/rails_app/app/components/server_caller.rb +3 -3
  65. data/test/rails_app/app/components/simple_component.rb +1 -1
  66. data/test/rails_app/app/components/simple_tab_panel.rb +2 -2
  67. data/test/rails_app/app/components/some_composite.rb +16 -16
  68. data/test/rails_app/config/routes.rb +2 -2
  69. data/test/test_helper.rb +1 -1
  70. data/test/unit/core_ext_test.rb +13 -13
  71. data/test/unit/netzke_core_test.rb +20 -20
  72. data/test/unit/netzke_preference_test.rb +12 -12
  73. metadata +6 -6
@@ -8,16 +8,16 @@ class CoreExtTest < ActiveSupport::TestCase
8
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
9
 
10
10
  assert_equal([
11
- {:a => [{:e => 5}]},
12
- {},
11
+ {:a => [{:e => 5}]},
12
+ {},
13
13
  {:b => {:c => 4, :d => 5}}
14
14
  ], [
15
- {:a => [{:e => 5, :ee => nil}]},
16
- {:aa => nil},
15
+ {:a => [{:e => 5, :ee => nil}]},
16
+ {:aa => nil},
17
17
  {:b => {:c => 4, :d => 5, :cc => nil}}
18
18
  ].recursive_delete_if_nil)
19
19
  end
20
-
20
+
21
21
  test "convert keys" do
22
22
  assert_equal({:a => 1, :b => {:bb => 2}}, {"a" => 1, "b" => {"bb" => 2}}.deep_convert_keys{ |k| k.to_sym })
23
23
  assert_equal([{"a" => 1}, {"b" => {"bb" => 2}}], [{:a => 1}, {:b => {:bb => 2}}].deep_convert_keys{ |k| k.to_s })
@@ -26,23 +26,23 @@ class CoreExtTest < ActiveSupport::TestCase
26
26
  {:aB => 1, :cDD => [{:lookMa => true},{:wowNow => true}]}
27
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
28
  end
29
-
29
+
30
30
  test "javascript-like access to hash data" do
31
31
  a = {}
32
32
  a["b"] = 100
33
33
  assert_equal(100, a.b)
34
-
34
+
35
35
  a.b = 200
36
36
  assert_equal(200, a["b"])
37
-
37
+
38
38
  a.c = 300
39
39
  assert_equal(300, a[:c])
40
40
  end
41
-
41
+
42
42
  test "jsonify" do
43
43
  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)
44
44
  end
45
-
45
+
46
46
  test "flatten_with_type" do
47
47
  test_flatten_with_type = {
48
48
  :one => 1,
@@ -54,9 +54,9 @@ class CoreExtTest < ActiveSupport::TestCase
54
54
  }
55
55
  }
56
56
  }.flatten_with_type
57
-
57
+
58
58
  assert_equal(4, test_flatten_with_type.size)
59
-
59
+
60
60
  test_flatten_with_type.each do |i|
61
61
  assert([{
62
62
  :name => :one, :value => 1, :type => :Fixnum
@@ -69,5 +69,5 @@ class CoreExtTest < ActiveSupport::TestCase
69
69
  }].include?(i))
70
70
  end
71
71
  end
72
-
72
+
73
73
  end
@@ -4,25 +4,25 @@ require 'netzke-core'
4
4
  module Netzke
5
5
  class Component < Base
6
6
  api :method_one, :method_two
7
-
7
+
8
8
  def self.config
9
9
  super.merge({
10
10
  :pref_one => 1,
11
11
  :pref_two => 2
12
12
  })
13
13
  end
14
-
14
+
15
15
  def initial_components
16
16
  {
17
17
  :nested_one => {:class_name => 'NestedComponentOne'},
18
18
  :nested_two => {:class_name => 'NestedComponentTwo'}
19
19
  }
20
20
  end
21
-
21
+
22
22
  def available_permissions
23
23
  %w(read update)
24
24
  end
25
-
25
+
26
26
  def default_config
27
27
  {
28
28
  :config_uno => true,
@@ -49,18 +49,18 @@ module Netzke
49
49
  }
50
50
  end
51
51
  end
52
-
52
+
53
53
  class VeryDeepNestedComponent < Base
54
54
  end
55
55
 
56
56
  class JsInheritanceComponent < Component
57
57
  end
58
-
58
+
59
59
  module ScopedComponents
60
60
  class SomeScopedComponent < Base
61
61
  end
62
62
  end
63
-
63
+
64
64
  class InheritedComponent < Component
65
65
  def self.config
66
66
  super.merge({
@@ -72,18 +72,18 @@ end
72
72
 
73
73
  class NetzkeCoreTest < ActiveSupport::TestCase
74
74
  include Netzke
75
-
75
+
76
76
  def setup
77
77
  end
78
-
78
+
79
79
  test "base class loaded" do
80
80
  assert_kind_of Netzke::Base, Netzke::Base.new
81
81
  end
82
-
82
+
83
83
  test "short component class name" do
84
84
  assert_equal 'Component', Component.short_component_class_name
85
85
  end
86
-
86
+
87
87
  test "api" do
88
88
  component_class = Component
89
89
  assert_equal [:deliver_component, :method_one, :method_two], component_class.endpoints
@@ -91,22 +91,22 @@ class NetzkeCoreTest < ActiveSupport::TestCase
91
91
 
92
92
  test "components" do
93
93
  component = Component.new(:name => 'my_component')
94
-
94
+
95
95
  # instantiate components
96
96
  nested_component_one = component.component_instance(:nested_one)
97
97
  nested_component_two = component.component_instance(:nested_two)
98
98
  deep_nested_component = component.component_instance(:nested_two__nested)
99
-
99
+
100
100
  assert_kind_of NestedComponentOne, nested_component_one
101
101
  assert_kind_of NestedComponentTwo, nested_component_two
102
102
  assert_kind_of DeepNestedComponent, deep_nested_component
103
-
103
+
104
104
  assert_equal 'my_component', component.global_id
105
105
  assert_equal 'my_component__nested_one', nested_component_one.global_id
106
106
  assert_equal 'my_component__nested_two', nested_component_two.global_id
107
107
  assert_equal 'my_component__nested_two__nested', deep_nested_component.global_id
108
108
  end
109
-
109
+
110
110
  test "global_id_by_reference" do
111
111
  w = Component.new(:name => "a_component")
112
112
  deep_nested_component = w.component_instance(:nested_two__nested)
@@ -117,7 +117,7 @@ class NetzkeCoreTest < ActiveSupport::TestCase
117
117
  assert_equal("a_component__nested_two__nested__non_existing", deep_nested_component.global_id_by_reference(:non_existing))
118
118
  assert_nil(deep_nested_component.global_id_by_reference(:parent__parent__parent)) # too far up
119
119
  end
120
-
120
+
121
121
  test "default config" do
122
122
  component = Component.new
123
123
  assert_equal({:config_uno => true, :config_dos => false}, component.config)
@@ -132,7 +132,7 @@ class NetzkeCoreTest < ActiveSupport::TestCase
132
132
  assert(component.dependencies.include?('NestedComponentTwo'))
133
133
  assert(!component.dependencies.include?('DeepNestedComponent'))
134
134
  end
135
-
135
+
136
136
  test "dependency classes" do
137
137
  component = Component.new
138
138
  # not testing the order
@@ -160,18 +160,18 @@ class NetzkeCoreTest < ActiveSupport::TestCase
160
160
 
161
161
  Netzke::Component.config[:pref_for_component] = 1
162
162
  Netzke::InheritedComponent.config[:pref_for_component] = 2
163
-
163
+
164
164
  # this is broken in 1.9
165
165
  # assert_equal(1, Netzke::Component.config[:pref_for_component])
166
166
  # assert_equal(2, Netzke::InheritedComponent.config[:pref_for_component])
167
- #
167
+ #
168
168
  end
169
169
 
170
170
  test "JS class names and scopes" do
171
171
  klass = Netzke::NestedComponentOne
172
172
  assert_equal("Netzke.classes", klass.js_full_scope)
173
173
  assert_equal("", klass.js_class_name_to_scope(klass.short_component_class_name))
174
-
174
+
175
175
  klass = Netzke::ScopedComponents::SomeScopedComponent
176
176
  assert_equal("Netzke.classes", klass.js_default_scope)
177
177
  assert_equal("ScopedComponents::SomeScopedComponent", klass.short_component_class_name)
@@ -5,12 +5,12 @@ class NetzkePreferenceTest < ActiveSupport::TestCase
5
5
  p = NetzkePreference
6
6
  session = Netzke::Core.session
7
7
  session.clear
8
-
8
+
9
9
  assert_not_nil(p.pref_to_write(:test))
10
10
  p[:test] = "a value"
11
11
  assert_not_nil(p.pref_to_read(:test))
12
12
  end
13
-
13
+
14
14
  test "basic values" do
15
15
  an_integer = 1976
16
16
  a_float = 1976.1345
@@ -20,8 +20,8 @@ class NetzkePreferenceTest < ActiveSupport::TestCase
20
20
  a_nil = nil
21
21
  a_hash = {"a" => an_integer, "b" => a_true, "c" => nil, "d" => a_float}
22
22
  an_array = [1, "a", a_hash, [1,3,4], a_true, a_false, a_nil, a_float]
23
-
24
-
23
+
24
+
25
25
  p = NetzkePreference
26
26
  p[:a_hash] = a_hash
27
27
  p["an_integer"] = an_integer
@@ -31,7 +31,7 @@ class NetzkePreferenceTest < ActiveSupport::TestCase
31
31
  p[:an_array] = an_array
32
32
  p[:a_symbol] = a_symbol
33
33
  p[:a_float] = a_float
34
-
34
+
35
35
  assert_equal(a_hash, p[:a_hash])
36
36
  assert_equal(an_integer, p[:an_integer])
37
37
  assert_equal(a_true, p[:a_true])
@@ -40,17 +40,17 @@ class NetzkePreferenceTest < ActiveSupport::TestCase
40
40
  assert_equal(a_nil, p[:a_nil])
41
41
  assert_equal(a_symbol, p[:a_symbol])
42
42
  assert_equal(a_float, p[:a_float])
43
-
43
+
44
44
  assert_equal(nil, p[:non_existing])
45
45
  end
46
-
46
+
47
47
  test "multi-user/multi-role support" do
48
48
  p = NetzkePreference
49
49
  session = Netzke::Core.session
50
-
50
+
51
51
  admin_role = Role.create(:name => 'admin')
52
52
  user_role = Role.create(:name => 'user')
53
-
53
+
54
54
  admin1 = User.create(:login => 'admin1', :role => admin_role)
55
55
  user1 = User.create(:login => 'user1', :role => user_role)
56
56
  user2 = User.create(:login => 'user2', :role => user_role)
@@ -71,7 +71,7 @@ class NetzkePreferenceTest < ActiveSupport::TestCase
71
71
  session.clear
72
72
  session[:netzke_user_id] = user2.id
73
73
  assert_equal(100, p[:test])
74
-
74
+
75
75
  #
76
76
  # now overwrite the value for user2
77
77
  #
@@ -81,7 +81,7 @@ class NetzkePreferenceTest < ActiveSupport::TestCase
81
81
  session.clear
82
82
  session[:netzke_user_id] = user1.id
83
83
  assert_equal(100, p[:test])
84
-
84
+
85
85
  #
86
86
  # now overwrite it for user1 by means of masq_user
87
87
  #
@@ -98,6 +98,6 @@ class NetzkePreferenceTest < ActiveSupport::TestCase
98
98
  session.clear
99
99
  session[:netzke_user_id] = user3.id
100
100
  assert_equal(100, p[:test])
101
-
101
+
102
102
  end
103
103
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 2
9
- version: 0.6.2
8
+ - 3
9
+ version: 0.6.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sergei Kozlov
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-27 00:00:00 +02:00
17
+ date: 2010-11-02 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -187,11 +187,11 @@ files:
187
187
  - test/unit/netzke_preference_test.rb
188
188
  - uninstall.rb
189
189
  has_rdoc: true
190
- homepage: http://github.com/skozlov/netzke-core
190
+ homepage: http://netzke.org
191
191
  licenses: []
192
192
 
193
193
  post_install_message: "\n\
194
- ========================================================================\n\n Thanks for installing Netzke Core!\n \n Netzke home page: http://netzke.org\n Netzke Google Groups: http://groups.google.com/group/netzke\n Netzke tutorials: http://blog.writelesscode.com\n\n\
194
+ ========================================================================\n\n Thanks for installing Netzke Core!\n\n Netzke home page: http://netzke.org\n Netzke Google Groups: http://groups.google.com/group/netzke\n Netzke tutorials: http://blog.writelesscode.com\n\n\
195
195
  ========================================================================\n\n"
196
196
  rdoc_options: []
197
197
 
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  version: "0"
216
216
  requirements: []
217
217
 
218
- rubyforge_project: netzke-core
218
+ rubyforge_project:
219
219
  rubygems_version: 1.3.7
220
220
  signing_key:
221
221
  specification_version: 3