netzke-core 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/.autotest +1 -1
  2. data/.gitignore +4 -2
  3. data/CHANGELOG.rdoc +37 -15
  4. data/README.rdoc +93 -28
  5. data/Rakefile +5 -7
  6. data/TODO +24 -3
  7. data/app/controllers/netzke_controller.rb +70 -0
  8. data/app/models/netzke_preference.rb +170 -0
  9. data/autotest/discover.rb +2 -3
  10. data/features/actions.feature +13 -0
  11. data/features/basic.feature +7 -0
  12. data/features/client-server.feature +15 -0
  13. data/features/complex_component.feature +18 -0
  14. data/features/component.feature +13 -0
  15. data/features/component_loader.feature +31 -0
  16. data/features/composition.feature +32 -0
  17. data/features/custom_css.feature +17 -0
  18. data/features/file_inclusion.feature +13 -0
  19. data/features/inheritance.feature +19 -0
  20. data/features/persistence.feature +16 -0
  21. data/features/scopes.feature +17 -0
  22. data/features/step_definitions/custom_css_steps.rb +7 -0
  23. data/features/step_definitions/generic_steps.rb +15 -0
  24. data/features/step_definitions/web_steps.rb +219 -0
  25. data/features/support/env.rb +62 -0
  26. data/features/support/paths.rb +45 -0
  27. data/generators/netzke_core/USAGE +3 -3
  28. data/generators/netzke_core/netzke_core_generator.rb +8 -0
  29. data/install.rb +1 -1
  30. data/javascripts/core.js +542 -499
  31. data/lib/generators/migration_helper.rb +32 -0
  32. data/lib/generators/netzke/USAGE +9 -0
  33. data/lib/generators/netzke/core_generator.rb +24 -0
  34. data/lib/netzke/actions.rb +102 -0
  35. data/lib/netzke/base.rb +77 -529
  36. data/lib/netzke/composition.rb +251 -0
  37. data/lib/netzke/configuration.rb +134 -0
  38. data/lib/netzke/core/masquerading.rb +34 -0
  39. data/lib/netzke/core/session.rb +30 -0
  40. data/lib/netzke/core/version.rb +11 -0
  41. data/lib/netzke/core.rb +53 -0
  42. data/lib/netzke/core_ext/array.rb +30 -0
  43. data/lib/netzke/core_ext/hash.rb +84 -0
  44. data/lib/netzke/core_ext/string.rb +26 -0
  45. data/lib/netzke/core_ext/symbol.rb +13 -0
  46. data/lib/netzke/core_ext/time_with_zone.rb +7 -0
  47. data/lib/netzke/core_ext.rb +5 -141
  48. data/lib/netzke/embedding.rb +21 -0
  49. data/lib/netzke/ext_component.rb +25 -0
  50. data/lib/netzke/javascript.rb +248 -0
  51. data/lib/netzke/persistence.rb +118 -0
  52. data/lib/netzke/rails/action_view_ext.rb +103 -0
  53. data/lib/netzke/{controller_extensions.rb → rails/controller_extensions.rb} +7 -2
  54. data/lib/netzke/rails/routes.rb +7 -0
  55. data/lib/netzke/services.rb +68 -0
  56. data/lib/netzke/session.rb +35 -0
  57. data/lib/netzke/stylesheets.rb +52 -0
  58. data/lib/netzke-core.rb +28 -29
  59. data/netzke-core.gemspec +253 -0
  60. data/spec/component/actions_spec.rb +94 -0
  61. data/spec/component/base_spec.rb +25 -0
  62. data/spec/component/composition_spec.rb +132 -0
  63. data/spec/component/javascript_spec.rb +15 -0
  64. data/spec/core_ext_spec.rb +16 -0
  65. data/spec/spec.opt +2 -0
  66. data/spec/spec_helper.rb +35 -0
  67. data/{test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb → templates/core/create_netzke_preferences.rb} +4 -4
  68. data/test/rails_app/.gitignore +4 -0
  69. data/test/rails_app/Gemfile +36 -0
  70. data/test/rails_app/Gemfile.lock +137 -0
  71. data/test/rails_app/README +15 -0
  72. data/test/rails_app/Rakefile +7 -0
  73. data/test/rails_app/app/components/border_layout_panel.rb +4 -0
  74. data/test/rails_app/app/components/component_loader.rb +59 -0
  75. data/test/rails_app/app/components/component_with_actions.rb +58 -0
  76. data/test/rails_app/app/components/component_with_custom_css.rb +8 -0
  77. data/test/rails_app/app/components/component_with_included_js.rb +16 -0
  78. data/test/rails_app/app/components/component_with_session_persistence.rb +25 -0
  79. data/test/rails_app/app/components/custom.css +3 -0
  80. data/test/rails_app/app/components/deprecated/server_caller.rb +20 -0
  81. data/test/rails_app/app/components/extended_component_with_actions.rb +5 -0
  82. data/test/rails_app/app/components/extended_server_caller.rb +18 -0
  83. data/test/rails_app/app/components/included.js +5 -0
  84. data/test/rails_app/app/components/kinda_complex_component/basic_stuff.rb +35 -0
  85. data/test/rails_app/app/components/kinda_complex_component/extra_stuff.rb +16 -0
  86. data/test/rails_app/app/components/kinda_complex_component.rb +7 -0
  87. data/test/rails_app/app/components/loader_of_component_with_custom_css.rb +15 -0
  88. data/test/rails_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +7 -0
  89. data/test/rails_app/app/components/scoped_components/extended_scoped_component.rb +5 -0
  90. data/test/rails_app/app/components/scoped_components/some_scoped_component.rb +5 -0
  91. data/test/rails_app/app/components/server_caller.rb +21 -0
  92. data/test/rails_app/app/components/simple_component.rb +5 -0
  93. data/test/rails_app/app/components/simple_tab_panel.rb +27 -0
  94. data/test/rails_app/app/components/simple_window.rb +3 -0
  95. data/test/rails_app/app/components/some_composite.rb +65 -0
  96. data/test/rails_app/app/components/some_ext_component.rb +8 -0
  97. data/test/{app_root → rails_app}/app/controllers/application_controller.rb +1 -0
  98. data/test/rails_app/app/controllers/components_controller.rb +12 -0
  99. data/test/rails_app/app/controllers/multiple_components_controller.rb +2 -0
  100. data/test/rails_app/app/controllers/welcome_controller.rb +5 -0
  101. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  102. data/test/rails_app/app/views/layouts/application.html.erb +13 -0
  103. data/test/rails_app/app/views/multiple_components/set_one.html.erb +3 -0
  104. data/test/rails_app/config/application.rb +45 -0
  105. data/test/rails_app/config/boot.rb +13 -0
  106. data/test/rails_app/config/database.yml +22 -0
  107. data/test/rails_app/config/environment.rb +6 -0
  108. data/test/rails_app/config/environments/development.rb +22 -0
  109. data/test/rails_app/config/environments/production.rb +49 -0
  110. data/test/rails_app/config/environments/test.rb +35 -0
  111. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  112. data/test/rails_app/config/initializers/inflections.rb +10 -0
  113. data/test/rails_app/config/initializers/mime_types.rb +5 -0
  114. data/test/rails_app/config/initializers/netzke.rb +3 -0
  115. data/test/rails_app/config/initializers/secret_token.rb +7 -0
  116. data/test/rails_app/config/initializers/session_store.rb +8 -0
  117. data/test/rails_app/config/locales/en.yml +5 -0
  118. data/test/rails_app/config/routes.rb +64 -0
  119. data/test/rails_app/config.ru +4 -0
  120. data/test/rails_app/db/development_structure.sql +4 -0
  121. data/{generators/netzke_core/templates/create_netzke_preferences.rb → test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb} +1 -3
  122. data/test/rails_app/db/schema.rb +24 -0
  123. data/test/rails_app/db/seeds.rb +7 -0
  124. data/test/{app_root/config/environments/in_memory.rb → rails_app/lib/tasks/.gitkeep} +0 -0
  125. data/test/rails_app/public/404.html +26 -0
  126. data/test/rails_app/public/422.html +26 -0
  127. data/test/rails_app/public/500.html +26 -0
  128. data/test/{app_root/config/environments/mysql.rb → rails_app/public/favicon.ico} +0 -0
  129. data/test/rails_app/public/images/rails.png +0 -0
  130. data/test/rails_app/public/robots.txt +5 -0
  131. data/test/rails_app/script/rails +6 -0
  132. data/test/{app_root/config/environments/postgresql.rb → rails_app/vendor/plugins/.gitkeep} +0 -0
  133. data/test/unit/netzke_core_test.rb +74 -75
  134. data/test/unit/netzke_preference_test.rb +2 -2
  135. metadata +176 -48
  136. data/lib/app/controllers/netzke_controller.rb +0 -46
  137. data/lib/app/models/netzke_preference.rb +0 -171
  138. data/lib/netzke/action_view_ext.rb +0 -81
  139. data/lib/netzke/base_js.rb +0 -339
  140. data/lib/netzke/routing.rb +0 -9
  141. data/test/app_root/app/models/role.rb +0 -3
  142. data/test/app_root/app/models/user.rb +0 -3
  143. data/test/app_root/config/boot.rb +0 -115
  144. data/test/app_root/config/database.yml +0 -31
  145. data/test/app_root/config/environment.rb +0 -14
  146. data/test/app_root/config/environments/sqlite.rb +0 -0
  147. data/test/app_root/config/environments/sqlite3.rb +0 -0
  148. data/test/app_root/config/routes.rb +0 -4
  149. data/test/app_root/db/migrate/20090423214303_create_roles.rb +0 -11
  150. data/test/app_root/db/migrate/20090423222114_create_users.rb +0 -12
  151. data/test/app_root/lib/console_with_fixtures.rb +0 -4
  152. data/test/app_root/script/console +0 -7
@@ -0,0 +1,68 @@
1
+ module Netzke
2
+ module Services
3
+ class BadEndpointReturnType < RuntimeError; end
4
+
5
+ module ClassMethods
6
+ # Declare connection points between client side of a component and its server side. For example:
7
+ #
8
+ # api :reset_data
9
+ #
10
+ # will provide JavaScript side with a method <tt>resetData</tt> that will result in a call to Ruby
11
+ # method <tt>reset_data</tt>, e.g.:
12
+ #
13
+ # this.resetData({hard:true});
14
+ #
15
+ # See netzke-basepack's GridPanel for an example.
16
+ #
17
+ def api(*api_points)
18
+ ::ActiveSupport::Deprecation.warn("Using the 'api' call is deprecated. Use the 'endpoint' approach instead", caller)
19
+
20
+ api_points.each do |apip|
21
+ add_endpoint(apip)
22
+ end
23
+
24
+ # It may be needed later for security
25
+ api_points.each do |apip|
26
+ module_eval <<-END, __FILE__, __LINE__
27
+ def endpoint_#{apip}(*args)
28
+ before_api_call_result = defined?(before_api_call) && before_api_call('#{apip}', *args) || {}
29
+ (before_api_call_result.empty? ? #{apip}(*args) : before_api_call_result).to_nifty_json
30
+ end
31
+ END
32
+ end
33
+ end
34
+
35
+ # Defines an endpoint
36
+ def endpoint(name, options = {}, &block)
37
+ add_endpoint(name)
38
+ define_method name, &block if block # if no block is given, the method is supposed to be defined elsewhere
39
+
40
+ # define_method name, &block if block # if no block is given, the method is supposed to be defined elsewhere
41
+ define_method :"endpoint_#{name}" do |*args|
42
+ res = send(name, *args)
43
+ res.respond_to?(:to_nifty_json) && res.to_nifty_json || ""
44
+ end
45
+ end
46
+
47
+ # Register an endpoint
48
+ def add_endpoint(ep)
49
+ current_endpoints = read_inheritable_attribute(:endpoints) || []
50
+ current_endpoints << ep
51
+ write_inheritable_attribute(:endpoints, current_endpoints.uniq)
52
+ end
53
+
54
+ # Returns registered endpoints
55
+ def endpoints
56
+ read_inheritable_attribute(:endpoints)
57
+ end
58
+ end
59
+
60
+ module InstanceMethods
61
+ end
62
+
63
+ def self.included(receiver)
64
+ receiver.extend ClassMethods
65
+ receiver.send :include, InstanceMethods
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,35 @@
1
+ module Netzke
2
+ # This modules provides (component-specific) session manupulation.
3
+ # The :session_persistence config option should be set to true in order for the component to make use of this.
4
+ module Session
5
+ # Top-level session (straight from the controller).
6
+ def session
7
+ ::Netzke::Core.session
8
+ end
9
+
10
+ # Component-specific session.
11
+ def component_session
12
+ session[global_id] ||= {}
13
+ end
14
+
15
+ # Returns this component's configuration options stored in the session. Those get merged into the component's configuration at instantiation.
16
+ def session_options
17
+ session_persistence_enabled? && component_session[:options] || {}
18
+ end
19
+
20
+ # Updates the session options
21
+ def update_session_options(hash)
22
+ if session_persistence_enabled?
23
+ component_session[:options] ||= {}
24
+ component_session[:options].merge!(hash)
25
+ else
26
+ logger.debug "Netzke warning: No session persistence enabled for component '#{global_id}'"
27
+ end
28
+ end
29
+
30
+ private
31
+ def session_persistence_enabled?
32
+ initial_config[:session_persistence]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,52 @@
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
+ # Definition of CSS files which will be dynamically loaded together with this component
31
+ # e.g.
32
+ # css_include "#{File.dirname(__FILE__)}/themis_navigation/static.css"
33
+ # or
34
+ # css_include "#{File.dirname(__FILE__)}/themis_navigation/one.css","#{File.dirname(__FILE__)}/themis_navigation/two.css"
35
+ # This is alternative to defining self.include_css
36
+ def css_include(*args)
37
+ self.css_included_files += args
38
+ end
39
+
40
+ end
41
+
42
+ module InstanceMethods
43
+ def css_missing_code(cached = [])
44
+ code = dependency_classes.inject("") do |r,k|
45
+ cached.include?(k) ? r : r + constantize_class_name(k).css_code(cached)
46
+ end
47
+ code.blank? ? nil : code
48
+ end
49
+
50
+ end
51
+ end
52
+ end
data/lib/netzke-core.rb CHANGED
@@ -1,38 +1,37 @@
1
- require 'active_support'
1
+ $LOAD_PATH << File.dirname(__FILE__)
2
2
 
3
- # NetzkeCore
4
- require 'netzke/base'
3
+ # require 'netzke/core_ext'
5
4
 
6
- require 'netzke/action_view_ext'
7
- require 'netzke/controller_extensions'
8
- require 'netzke/core_ext'
9
- require 'netzke/routing'
5
+ require 'netzke/core'
6
+ require 'netzke/base'
10
7
 
11
- # Load models and controllers from lib/app
12
- %w{ models controllers }.each do |dir|
13
- path = File.join(File.dirname(__FILE__), 'app', dir)
14
- $LOAD_PATH << path
15
- ActiveSupport::Dependencies.load_paths << path
16
- ActiveSupport::Dependencies.load_once_paths.delete(path)
8
+ module Netzke
9
+ autoload :Core, 'netzke/core'
10
+ autoload :ExtComponent, 'netzke/ext_component'
11
+
12
+ class Engine < ::Rails::Engine
13
+ config.after_initialize do
14
+ # Do some initialization which is only possible after Rails is initialized
15
+ Netzke::Core.ext_location ||= ::Rails.root.join("public", "extjs")
16
+ Netzke::Core.with_icons = File.exists?("#{Rails.root}/public#{Netzke::Core.icons_uri}") if Netzke::Core.with_icons.nil?
17
+ end
18
+ end
17
19
  end
18
20
 
19
- if defined? ActionController
20
- ActionController::Base.class_eval do
21
+ # Rails specific
22
+ if defined? Rails
23
+ require 'netzke/rails/routes'
24
+
25
+ ActiveSupport.on_load(:action_controller) do
26
+ require 'netzke/rails/controller_extensions'
21
27
  include Netzke::ControllerExtensions
22
28
  end
23
29
 
24
- # Include the route to the Netzke controller
25
- ActionController::Routing::RouteSet::Mapper.send :include, Netzke::Routing::MapperExtensions
30
+ ActiveSupport.on_load(:action_view) do
31
+ require 'netzke/rails/action_view_ext'
32
+ include Netzke::ActionViewExt
33
+ end
34
+
35
+ # Make this plugin auto-reloadable for easier development
36
+ # ActiveSupport::Dependencies.autoload_once_paths.delete(File.join(File.dirname(__FILE__)))
26
37
  end
27
-
28
- if defined? ActionView
29
- ActionView::Base.send :include, Netzke::ActionViewExt
30
- end
31
-
32
- # Make this plugin auto-reloadable for easier development
33
- ActiveSupport::Dependencies.load_once_paths.delete(File.join(File.dirname(__FILE__)))
34
-
35
- # Include javascript & styles required by all Netzke widgets.
36
- # These files will get loaded at the initial load of the framework (along with Ext).
37
- Netzke::Base.config[:javascripts] << "#{File.dirname(__FILE__)}/../javascripts/core.js"
38
- Netzke::Base.config[:stylesheets] << "#{File.dirname(__FILE__)}/../stylesheets/core.css"
@@ -0,0 +1,253 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{netzke-core}
8
+ s.version = "0.6.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Sergei Kozlov"]
12
+ s.date = %q{2010-10-24}
13
+ s.description = %q{Allows building ExtJS/Rails reusable code in a DRY way}
14
+ s.email = %q{sergei@playcode.nl}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".autotest",
22
+ ".gitignore",
23
+ "CHANGELOG.rdoc",
24
+ "LICENSE",
25
+ "Manifest",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "TODO",
29
+ "app/controllers/netzke_controller.rb",
30
+ "app/models/netzke_preference.rb",
31
+ "autotest/discover.rb",
32
+ "features/actions.feature",
33
+ "features/basic.feature",
34
+ "features/client-server.feature",
35
+ "features/complex_component.feature",
36
+ "features/component.feature",
37
+ "features/component_loader.feature",
38
+ "features/composition.feature",
39
+ "features/custom_css.feature",
40
+ "features/file_inclusion.feature",
41
+ "features/inheritance.feature",
42
+ "features/persistence.feature",
43
+ "features/scopes.feature",
44
+ "features/step_definitions/custom_css_steps.rb",
45
+ "features/step_definitions/generic_steps.rb",
46
+ "features/step_definitions/web_steps.rb",
47
+ "features/support/env.rb",
48
+ "features/support/paths.rb",
49
+ "generators/netzke_core/USAGE",
50
+ "generators/netzke_core/netzke_core_generator.rb",
51
+ "init.rb",
52
+ "install.rb",
53
+ "javascripts/core.js",
54
+ "lib/generators/migration_helper.rb",
55
+ "lib/generators/netzke/USAGE",
56
+ "lib/generators/netzke/core_generator.rb",
57
+ "lib/netzke-core.rb",
58
+ "lib/netzke/actions.rb",
59
+ "lib/netzke/base.rb",
60
+ "lib/netzke/composition.rb",
61
+ "lib/netzke/configuration.rb",
62
+ "lib/netzke/core.rb",
63
+ "lib/netzke/core/masquerading.rb",
64
+ "lib/netzke/core/session.rb",
65
+ "lib/netzke/core/version.rb",
66
+ "lib/netzke/core_ext.rb",
67
+ "lib/netzke/core_ext/array.rb",
68
+ "lib/netzke/core_ext/hash.rb",
69
+ "lib/netzke/core_ext/string.rb",
70
+ "lib/netzke/core_ext/symbol.rb",
71
+ "lib/netzke/core_ext/time_with_zone.rb",
72
+ "lib/netzke/embedding.rb",
73
+ "lib/netzke/ext_component.rb",
74
+ "lib/netzke/javascript.rb",
75
+ "lib/netzke/persistence.rb",
76
+ "lib/netzke/rails/action_view_ext.rb",
77
+ "lib/netzke/rails/controller_extensions.rb",
78
+ "lib/netzke/rails/routes.rb",
79
+ "lib/netzke/services.rb",
80
+ "lib/netzke/session.rb",
81
+ "lib/netzke/stylesheets.rb",
82
+ "lib/tasks/netzke_core_tasks.rake",
83
+ "netzke-core.gemspec",
84
+ "spec/component/actions_spec.rb",
85
+ "spec/component/base_spec.rb",
86
+ "spec/component/composition_spec.rb",
87
+ "spec/component/javascript_spec.rb",
88
+ "spec/core_ext_spec.rb",
89
+ "spec/spec.opt",
90
+ "spec/spec_helper.rb",
91
+ "stylesheets/core.css",
92
+ "templates/core/create_netzke_preferences.rb",
93
+ "test/fixtures/roles.yml",
94
+ "test/fixtures/users.yml",
95
+ "test/rails_app/.gitignore",
96
+ "test/rails_app/Gemfile",
97
+ "test/rails_app/Gemfile.lock",
98
+ "test/rails_app/README",
99
+ "test/rails_app/Rakefile",
100
+ "test/rails_app/app/components/border_layout_panel.rb",
101
+ "test/rails_app/app/components/component_loader.rb",
102
+ "test/rails_app/app/components/component_with_actions.rb",
103
+ "test/rails_app/app/components/component_with_custom_css.rb",
104
+ "test/rails_app/app/components/component_with_included_js.rb",
105
+ "test/rails_app/app/components/component_with_session_persistence.rb",
106
+ "test/rails_app/app/components/custom.css",
107
+ "test/rails_app/app/components/deprecated/server_caller.rb",
108
+ "test/rails_app/app/components/extended_component_with_actions.rb",
109
+ "test/rails_app/app/components/extended_server_caller.rb",
110
+ "test/rails_app/app/components/included.js",
111
+ "test/rails_app/app/components/kinda_complex_component.rb",
112
+ "test/rails_app/app/components/kinda_complex_component/basic_stuff.rb",
113
+ "test/rails_app/app/components/kinda_complex_component/extra_stuff.rb",
114
+ "test/rails_app/app/components/loader_of_component_with_custom_css.rb",
115
+ "test/rails_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb",
116
+ "test/rails_app/app/components/scoped_components/extended_scoped_component.rb",
117
+ "test/rails_app/app/components/scoped_components/some_scoped_component.rb",
118
+ "test/rails_app/app/components/server_caller.rb",
119
+ "test/rails_app/app/components/simple_component.rb",
120
+ "test/rails_app/app/components/simple_tab_panel.rb",
121
+ "test/rails_app/app/components/simple_window.rb",
122
+ "test/rails_app/app/components/some_composite.rb",
123
+ "test/rails_app/app/components/some_ext_component.rb",
124
+ "test/rails_app/app/controllers/application_controller.rb",
125
+ "test/rails_app/app/controllers/components_controller.rb",
126
+ "test/rails_app/app/controllers/multiple_components_controller.rb",
127
+ "test/rails_app/app/controllers/welcome_controller.rb",
128
+ "test/rails_app/app/helpers/application_helper.rb",
129
+ "test/rails_app/app/views/layouts/application.html.erb",
130
+ "test/rails_app/app/views/multiple_components/set_one.html.erb",
131
+ "test/rails_app/config.ru",
132
+ "test/rails_app/config/application.rb",
133
+ "test/rails_app/config/boot.rb",
134
+ "test/rails_app/config/database.yml",
135
+ "test/rails_app/config/environment.rb",
136
+ "test/rails_app/config/environments/development.rb",
137
+ "test/rails_app/config/environments/production.rb",
138
+ "test/rails_app/config/environments/test.rb",
139
+ "test/rails_app/config/initializers/backtrace_silencers.rb",
140
+ "test/rails_app/config/initializers/inflections.rb",
141
+ "test/rails_app/config/initializers/mime_types.rb",
142
+ "test/rails_app/config/initializers/netzke.rb",
143
+ "test/rails_app/config/initializers/secret_token.rb",
144
+ "test/rails_app/config/initializers/session_store.rb",
145
+ "test/rails_app/config/locales/en.yml",
146
+ "test/rails_app/config/routes.rb",
147
+ "test/rails_app/db/development_structure.sql",
148
+ "test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb",
149
+ "test/rails_app/db/schema.rb",
150
+ "test/rails_app/db/seeds.rb",
151
+ "test/rails_app/lib/tasks/.gitkeep",
152
+ "test/rails_app/public/404.html",
153
+ "test/rails_app/public/422.html",
154
+ "test/rails_app/public/500.html",
155
+ "test/rails_app/public/favicon.ico",
156
+ "test/rails_app/public/images/rails.png",
157
+ "test/rails_app/public/robots.txt",
158
+ "test/rails_app/script/rails",
159
+ "test/rails_app/vendor/plugins/.gitkeep",
160
+ "test/test_helper.rb",
161
+ "test/unit/core_ext_test.rb",
162
+ "test/unit/netzke_core_test.rb",
163
+ "test/unit/netzke_preference_test.rb",
164
+ "uninstall.rb"
165
+ ]
166
+ s.homepage = %q{http://github.com/skozlov/netzke-core}
167
+ s.post_install_message = %q{
168
+ ========================================================================
169
+
170
+ Thanks for installing Netzke Core!
171
+
172
+ Netzke home page: http://netzke.org
173
+ Netzke Google Groups: http://groups.google.com/group/netzke
174
+ Netzke tutorials: http://blog.writelesscode.com
175
+
176
+ ========================================================================
177
+
178
+ }
179
+ s.rdoc_options = ["--charset=UTF-8"]
180
+ s.require_paths = ["lib"]
181
+ s.rubyforge_project = %q{netzke-core}
182
+ s.rubygems_version = %q{1.3.7}
183
+ s.summary = %q{Build ExtJS/Rails components with minimum effort}
184
+ s.test_files = [
185
+ "spec/component/actions_spec.rb",
186
+ "spec/component/base_spec.rb",
187
+ "spec/component/composition_spec.rb",
188
+ "spec/component/javascript_spec.rb",
189
+ "spec/core_ext_spec.rb",
190
+ "spec/spec_helper.rb",
191
+ "test/rails_app/app/components/border_layout_panel.rb",
192
+ "test/rails_app/app/components/component_loader.rb",
193
+ "test/rails_app/app/components/component_with_actions.rb",
194
+ "test/rails_app/app/components/component_with_custom_css.rb",
195
+ "test/rails_app/app/components/component_with_included_js.rb",
196
+ "test/rails_app/app/components/component_with_session_persistence.rb",
197
+ "test/rails_app/app/components/deprecated/server_caller.rb",
198
+ "test/rails_app/app/components/extended_component_with_actions.rb",
199
+ "test/rails_app/app/components/extended_server_caller.rb",
200
+ "test/rails_app/app/components/kinda_complex_component/basic_stuff.rb",
201
+ "test/rails_app/app/components/kinda_complex_component/extra_stuff.rb",
202
+ "test/rails_app/app/components/kinda_complex_component.rb",
203
+ "test/rails_app/app/components/loader_of_component_with_custom_css.rb",
204
+ "test/rails_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb",
205
+ "test/rails_app/app/components/scoped_components/extended_scoped_component.rb",
206
+ "test/rails_app/app/components/scoped_components/some_scoped_component.rb",
207
+ "test/rails_app/app/components/server_caller.rb",
208
+ "test/rails_app/app/components/simple_component.rb",
209
+ "test/rails_app/app/components/simple_tab_panel.rb",
210
+ "test/rails_app/app/components/simple_window.rb",
211
+ "test/rails_app/app/components/some_composite.rb",
212
+ "test/rails_app/app/components/some_ext_component.rb",
213
+ "test/rails_app/app/controllers/application_controller.rb",
214
+ "test/rails_app/app/controllers/components_controller.rb",
215
+ "test/rails_app/app/controllers/multiple_components_controller.rb",
216
+ "test/rails_app/app/controllers/welcome_controller.rb",
217
+ "test/rails_app/app/helpers/application_helper.rb",
218
+ "test/rails_app/config/application.rb",
219
+ "test/rails_app/config/boot.rb",
220
+ "test/rails_app/config/environment.rb",
221
+ "test/rails_app/config/environments/development.rb",
222
+ "test/rails_app/config/environments/production.rb",
223
+ "test/rails_app/config/environments/test.rb",
224
+ "test/rails_app/config/initializers/backtrace_silencers.rb",
225
+ "test/rails_app/config/initializers/inflections.rb",
226
+ "test/rails_app/config/initializers/mime_types.rb",
227
+ "test/rails_app/config/initializers/netzke.rb",
228
+ "test/rails_app/config/initializers/secret_token.rb",
229
+ "test/rails_app/config/initializers/session_store.rb",
230
+ "test/rails_app/config/routes.rb",
231
+ "test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb",
232
+ "test/rails_app/db/schema.rb",
233
+ "test/rails_app/db/seeds.rb",
234
+ "test/test_helper.rb",
235
+ "test/unit/core_ext_test.rb",
236
+ "test/unit/netzke_core_test.rb",
237
+ "test/unit/netzke_preference_test.rb"
238
+ ]
239
+
240
+ if s.respond_to? :specification_version then
241
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
242
+ s.specification_version = 3
243
+
244
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
245
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0.1"])
246
+ else
247
+ s.add_dependency(%q<activesupport>, [">= 3.0.1"])
248
+ end
249
+ else
250
+ s.add_dependency(%q<activesupport>, [">= 3.0.1"])
251
+ end
252
+ end
253
+
@@ -0,0 +1,94 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'netzke-core'
3
+
4
+ module Netzke
5
+ describe Actions do
6
+ # it "should be possible to override toolbars without overriding action settings" do
7
+ # ExtendedComponentWithActions.new.actions[:another_action][:disabled].should == true
8
+ # end
9
+
10
+ class SomeComponent < Base
11
+ action :action_one
12
+ action :action_two
13
+ action :action_three do
14
+ {:text => "Action three"}
15
+ end
16
+
17
+ js_property :bbar, [:action_one.action, :action_two.action]
18
+
19
+ def config
20
+ {
21
+ :tbar => [:action_three.action]
22
+ }
23
+ end
24
+
25
+ def actions
26
+ super.deep_merge({
27
+ :action_four => {:text => "Action 4"}
28
+ })
29
+ end
30
+
31
+ action :action_five, :text => "Action 5"
32
+ end
33
+
34
+ class ExtendedComponent < SomeComponent
35
+ js_property :bbar, [:action_one.action, :action_two.action, :action_three.action, :action_four.action, :action_five.action]
36
+ js_property :tbar, [:action_one.action, :action_two.action, :action_three.action, :action_four.action, :action_five.action]
37
+ end
38
+
39
+ class AnotherExtendedComponent < ExtendedComponent
40
+ action :action_one, :text => "Action 1"
41
+ action :action_five, :text => "Action Five"
42
+
43
+ action :action_two do
44
+ super().merge :disabled => true, :text => super()[:text] + ", extended"
45
+ end
46
+
47
+ action :action_three do
48
+ {:text => "Action 3"}
49
+ end
50
+ end
51
+
52
+ class YetAnotherExtendedComponent < AnotherExtendedComponent
53
+ action :action_two, :disabled => false
54
+ end
55
+
56
+ # it "should auto collect actions from both js_methods and config" do
57
+ # component = SomeComponent.new
58
+ # component.actions.keys.size.should == 5
59
+ # component.actions[:action_one][:text].should == "Action one"
60
+ # component.actions[:action_two][:text].should == "Action two"
61
+ # component.actions[:action_three][:text].should == "Action three"
62
+ # component.actions[:action_four][:text].should == "Action 4"
63
+ # component.actions[:action_five][:text].should == "Action 5"
64
+ # end
65
+
66
+ it "should not override previous actions when reconfiguring bars in child class" do
67
+ component = ExtendedComponent.new
68
+ # component.actions.keys.size.should == 5
69
+ component.actions[:action_one][:text].should == "Action one"
70
+ component.actions[:action_two][:text].should == "Action two"
71
+ component.actions[:action_three][:text].should == "Action three"
72
+ component.actions[:action_four][:text].should == "Action 4"
73
+ component.actions[:action_five][:text].should == "Action 5"
74
+ end
75
+
76
+ it "should be possible to override actions in child class" do
77
+ component = AnotherExtendedComponent.new
78
+ component.actions[:action_one][:text].should == "Action 1"
79
+ component.actions[:action_five][:text].should == "Action Five"
80
+
81
+ component.actions[:action_two][:text].should == "Action two, extended"
82
+ component.actions[:action_two][:disabled].should == true
83
+
84
+ component.actions[:action_three][:text].should == "Action 3"
85
+ end
86
+
87
+ it "should only override the specified actions" do
88
+ component = YetAnotherExtendedComponent.new
89
+ component.actions[:action_two][:disabled].should == false
90
+ component.actions[:action_two][:text].should == "Action two, extended"
91
+ end
92
+
93
+ end
94
+ end
@@ -0,0 +1,25 @@
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
+ end