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
@@ -1,339 +0,0 @@
1
- module Netzke
2
- # == BaseJs
3
- # *TODO: outdated*
4
- #
5
- # Module which provides JS-class generation functionality for the widgets ("client-side"). The generated code
6
- # is evaluated once per widget class, and the results are cached in the browser. Included into Netzke::Base class.
7
- #
8
- # == Widget javascript code
9
- # Here's a brief explanation on how a javascript class for a widget gets built.
10
- # Widget gets defined as a constructor (a function) by +js_class+ class method (see "Inside widget's contstructor").
11
- # +Ext.extend+ provides inheritance from an Ext class specified in +js_base_class+ class method.
12
- #
13
- # == Inside widget's constructor
14
- # * Widget's constructor gets called with a parameter that is a configuration object provided by +js_config+ instance method. This configuration is specific for the instance of the widget, and, for example, contains this widget's unique id. As another example, by means of this configuration object, a grid receives the configuration array for its columns, a form - for its fields, etc. With other words, everything that may change from instance to instance of the same widget's class, goes in here.
15
- # * Widget executes its specific initialization code which is provided by +js_before_consttructor+ class method.
16
- # For example, a grid may define its column model, a form - its fields, a tab panel - its tabs ("items").
17
- # * Widget calls the constructor of the inherited class (see +js_class+ class method) with a parameter that is a merge of
18
- # 1) configuration parameter passed to the widget's constructor.
19
- module BaseJs
20
- def self.included(base)
21
- base.extend ClassMethods
22
- end
23
-
24
- #
25
- # Instance methods
26
- #
27
-
28
- # Config that is used for instantiating the widget in javascript
29
- def js_config
30
- res = {}
31
-
32
- # Unique id of the widget
33
- res.merge!(:id => global_id)
34
-
35
- # Recursively include configs of all non-late aggregatees, so that the widget can instantiate them
36
- # in javascript immediately.
37
- non_late_aggregatees.each_pair do |aggr_name, aggr_config|
38
- aggr_instance = aggregatee_instance(aggr_name.to_sym)
39
- aggr_instance.before_load
40
- res[:"#{aggr_name}_config"] = aggr_instance.js_config
41
- end
42
-
43
- # Api (besides the default "load_aggregatee_with_cache" - JavaScript side already knows about it)
44
- api_points = self.class.api_points.reject{ |p| p == :load_aggregatee_with_cache }
45
- res.merge!(:netzke_api => api_points) unless api_points.empty?
46
-
47
- # Widget class name. Needed for dynamic instantiation in javascript.
48
- res.merge!(:scoped_class_name => self.class.js_scoped_class_name)
49
-
50
- # Actions, toolbars and menus
51
- # tools && res.merge!(:tools => tools)
52
- actions && res.merge!(:actions => actions)
53
- menu && res.merge!(:menu => menu)
54
-
55
- # Inform the JavaScript side if persistent_config is enabled
56
- res[:persistent_config] = persistent_config_enabled?
57
-
58
- # Merge with all config options passed as hash to config[:ext_config]
59
- res.merge!(ext_config)
60
-
61
- res
62
- end
63
-
64
- # All the JS-code required by this instance of the widget to be instantiated in the browser.
65
- # It includes the JS-class for the widget itself, as well as JS-classes for all widgets' (non-late) aggregatees.
66
- def js_missing_code(cached = [])
67
- code = dependency_classes.inject("") do |r,k|
68
- cached.include?(k) ? r : r + "Netzke::#{k}".constantize.js_code(cached).strip_js_comments
69
- end
70
- code.blank? ? nil : code
71
- end
72
-
73
- def css_missing_code(cached = [])
74
- code = dependency_classes.inject("") do |r,k|
75
- cached.include?(k) ? r : r + "Netzke::#{k}".constantize.css_code(cached)
76
- end
77
- code.blank? ? nil : code
78
- end
79
-
80
- #
81
- # The following methods are used when a widget is generated stand-alone (as a part of a HTML page)
82
- #
83
-
84
- # instantiating
85
- def js_widget_instance
86
- %Q{Netzke.page.#{name.jsonify} = new #{self.class.js_full_class_name}(#{js_config.to_nifty_json});}
87
- end
88
-
89
- # rendering
90
- def js_widget_render
91
- %Q{Netzke.page.#{name.jsonify}.render("#{name.to_s.split('_').join('-')}-netzke");} unless self.class.js_xtype == "netzkewindow"
92
- end
93
-
94
- # container for rendering
95
- def js_widget_html
96
- %Q{<div id="#{name.to_s.split('_').join('-')}-netzke" class="netzke-widget"></div>}
97
- end
98
-
99
- #
100
- # Widget's actions, tools and menus that are loaded at the moment of instantiation
101
-
102
- private
103
- # Extract action names from menus and toolbars.
104
- # E.g.:
105
- # collect_actions(["->", {:text => "Menu", :menu => [{:text => "Submenu", :menu => [:another_button]}, "-", :a_button]}])
106
- # => {:a_button => {:text => "A button"}, :another_button => {:text => "Another button"}}
107
- def collect_actions(arry)
108
- res = {}
109
- arry.each do |item|
110
- if item.is_a?(Hash) && menu = item[:menu]
111
- res.merge!(collect_actions(item[:menu]))
112
- elsif item.is_a?(Symbol)
113
- # it's an action
114
- res.merge!(item => {:text => item.to_s.humanize})
115
- elsif item.is_a?(String)
116
- # it's a string item (or maybe JS code)
117
- else
118
- end
119
- end
120
- res
121
- end
122
-
123
- public
124
- # Create default actions from bbar, tbar, and fbar, which are passed in the configuration
125
- def actions
126
- bar_items = (ext_config[:bbar] || []) + (ext_config[:tbar] || []) + (ext_config[:fbar] || [])
127
- bar_items.uniq!
128
- collect_actions(bar_items)
129
- end
130
-
131
- def menu; nil; end
132
-
133
- # Little helpers
134
- def this; "this".l; end
135
- def null; "null".l; end
136
-
137
- # Methods used to create the javascript class (only once per widget class).
138
- # The generated code gets cached at the browser, and the widget intstances (at the browser side)
139
- # get instantiated from it.
140
- # All these methods can be overwritten in case you want to extend the functionality of some pre-built widget
141
- # instead of using it as is (using both would cause JS-code duplication)
142
- module ClassMethods
143
- # the JS (Ext) class that we inherit from on JS-level
144
- def js_base_class
145
- "Ext.Panel"
146
- end
147
-
148
- # Properties (including methods) that will be used to extend the functionality of (Ext) JS-class specified in js_base_class
149
- def js_extend_properties
150
- {}
151
- end
152
-
153
- # widget's menus
154
- def js_menus; []; end
155
-
156
- # Given class name, e.g. GridPanelLib::Widgets::RecordFormWindow,
157
- # returns its scope: "Widgets.RecordFormWindow"
158
- def js_class_name_to_scope(name)
159
- name.split("::")[0..-2].join(".")
160
- end
161
-
162
- # Top level scope which will be used to cope out Netzke classes, e.g. "Netzke.classes" (default)
163
- def js_default_scope
164
- "Netzke.classes"
165
- end
166
-
167
- # Scope of this widget without default scope
168
- # e.g.: GridPanelLib.Widgets
169
- def js_scope
170
- js_class_name_to_scope(short_widget_class_name)
171
- end
172
-
173
- # Returns the scope of this widget
174
- # e.g. "Netzke.classes.GridPanelLib"
175
- def js_full_scope
176
- js_scope.empty? ? js_default_scope : [js_default_scope, js_scope].join(".")
177
- end
178
-
179
- # Returns the name of the JavaScript class for this widget, including the scope
180
- # e.g.: "GridPanelLib.RecordFormWindow"
181
- def js_scoped_class_name
182
- short_widget_class_name.gsub("::", ".")
183
- end
184
-
185
- # Returns the full name of the JavaScript class, including the scopes *and* the common scope, which is
186
- # Netzke.classes.
187
- # E.g.: "Netzke.classes.Netzke.GridPanelLib.RecordFormWindow"
188
- def js_full_class_name
189
- [js_full_scope, short_widget_class_name.split("::").last].join(".")
190
- end
191
-
192
- # Builds this widget's xtype
193
- # E.g.: netzkewindow, netzkegridpanel
194
- def js_xtype
195
- name.gsub("::", "").downcase
196
- end
197
-
198
- # are we using JS inheritance? for now, if js_base_class is a Netzke class - yes
199
- def js_inheritance?
200
- superclass != Netzke::Base
201
- end
202
-
203
- # Declaration of widget's class (stored in the cache storage (Ext.netzke.cache) at the client side
204
- # to be reused at the moment of widget instantiation)
205
- def js_class(cached = [])
206
- # Defining the scope if it isn't known yet
207
- res = js_full_scope == "Netzke.classes" ? "" : %Q{
208
- if (!#{js_full_scope}) {
209
- Ext.ns("#{js_full_scope}");
210
- }
211
- }
212
-
213
- if js_inheritance?
214
- # Using javascript inheritance
215
- res << <<-END_OF_JAVASCRIPT
216
- // Costructor
217
- #{js_full_class_name} = function(config){
218
- #{js_full_class_name}.superclass.constructor.call(this, config);
219
- };
220
- END_OF_JAVASCRIPT
221
-
222
- # Do we specify our own extend properties (overrriding js_extend_properties)? If so, include them, if not - don't re-include those from the parent!
223
- res << (singleton_methods(false).include?("js_extend_properties") ? %Q{
224
- Ext.extend(#{js_full_class_name}, #{superclass.js_full_class_name}, #{js_extend_properties.to_nifty_json});
225
- } : %Q{
226
- Ext.extend(#{js_full_class_name}, #{superclass.js_full_class_name});
227
- })
228
-
229
- res << <<-END_OF_JAVASCRIPT
230
- Ext.reg("#{js_xtype}", #{js_full_class_name});
231
- END_OF_JAVASCRIPT
232
-
233
- else
234
- # Menus
235
- js_add_menus = "this.addMenus(#{js_menus.to_nifty_json});" unless js_menus.empty?
236
-
237
- res << <<-END_OF_JAVASCRIPT
238
- // Constructor
239
- #{js_full_class_name} = function(config){
240
- // Do all the initializations that every Netzke widget should do: create methods for API-points,
241
- // process actions, tools, toolbars
242
- this.commonBeforeConstructor(config);
243
- // Call the constructor of the inherited class
244
- #{js_full_class_name}.superclass.constructor.call(this, config);
245
- // What every widget should do after calling the constructor of the inherited class, like
246
- // setting extra events
247
- this.commonAfterConstructor(config);
248
- };
249
- Ext.extend(#{js_full_class_name}, #{js_base_class}, Ext.applyIf(#{js_extend_properties.to_nifty_json}, Ext.widgetMixIn));
250
- Ext.reg("#{js_xtype}", #{js_full_class_name});
251
- END_OF_JAVASCRIPT
252
- end
253
-
254
- res
255
- end
256
-
257
- #
258
- # Extra JavaScript
259
- #
260
-
261
- # Override this method. Must return an array of paths to javascript files that we depend on.
262
- # This javascript code will be loaded along with the widget's class, and before it.
263
- # def include_js
264
- # []
265
- # end
266
-
267
- # Returns all extra JavaScript-code (as string) required by this widget's class
268
- def js_included
269
- res = ""
270
-
271
- # Prevent re-including code that was already included by the parent
272
- singleton_methods(false).include?("include_js") && include_js.each do |path|
273
- f = File.new(path)
274
- res << f.read << "\n"
275
- end
276
-
277
- res
278
- end
279
-
280
- # All JavaScript code needed for this class, including one from the ancestor widget
281
- def js_code(cached = [])
282
- res = ""
283
-
284
- # include the base-class javascript if doing JS inheritance
285
- if js_inheritance? && !cached.include?(superclass.short_widget_class_name)
286
- res << superclass.js_code(cached) << "\n"
287
- end
288
-
289
- # include static javascripts
290
- res << js_included << "\n"
291
-
292
- # our own JS class definition
293
- res << js_class(cached)
294
- res
295
- end
296
-
297
- #
298
- # Extra CSS
299
- #
300
-
301
- # Override this method. Must return an array of paths to css files that we depend on.
302
- # def include_css
303
- # []
304
- # end
305
-
306
- # Returns all extra CSS code (as string) required by this widget's class
307
- def css_included
308
- res = ""
309
-
310
- singleton_methods(false).include?("include_css") && include_css.each do |path|
311
- f = File.new(path)
312
- res << f.read << "\n"
313
- end
314
-
315
- res
316
- end
317
-
318
- # All CSS code needed for this class including the one from the ancestor widget
319
- def css_code(cached = [])
320
- res = ""
321
-
322
- # include the base-class javascript if doing JS inheritance
323
- res << superclass.css_code << "\n" if js_inheritance? && !cached.include?(superclass.short_widget_class_name)
324
-
325
- res << css_included << "\n"
326
-
327
- res
328
- end
329
-
330
-
331
- # Little helper
332
- def this; "this".l; end
333
-
334
- # Little helper
335
- def null; "null".l; end
336
-
337
- end
338
- end
339
- end
@@ -1,9 +0,0 @@
1
- module Netzke
2
- module Routing
3
- module MapperExtensions
4
- def netzke
5
- @set.add_route("/netzke/:action.:format", {:controller => "netzke"})
6
- end
7
- end
8
- end
9
- end
@@ -1,3 +0,0 @@
1
- class Role < ActiveRecord::Base
2
- has_many :users
3
- end
@@ -1,3 +0,0 @@
1
- class User < ActiveRecord::Base
2
- belongs_to :role
3
- end
@@ -1,115 +0,0 @@
1
- # Allow customization of the rails framework path
2
- RAILS_FRAMEWORK_ROOT = (ENV['RAILS_FRAMEWORK_ROOT'] || "#{File.dirname(__FILE__)}/../../../../../../vendor/rails") unless defined?(RAILS_FRAMEWORK_ROOT)
3
-
4
- # Don't change this file!
5
- # Configure your app in config/environment.rb and config/environments/*.rb
6
-
7
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
8
-
9
- module Rails
10
- class << self
11
- def boot!
12
- unless booted?
13
- preinitialize
14
- pick_boot.run
15
- end
16
- end
17
-
18
- def booted?
19
- defined? Rails::Initializer
20
- end
21
-
22
- def pick_boot
23
- (vendor_rails? ? VendorBoot : GemBoot).new
24
- end
25
-
26
- def vendor_rails?
27
- File.exist?(RAILS_FRAMEWORK_ROOT)
28
- end
29
-
30
- def preinitialize
31
- load(preinitializer_path) if File.exist?(preinitializer_path)
32
- end
33
-
34
- def preinitializer_path
35
- "#{RAILS_ROOT}/config/preinitializer.rb"
36
- end
37
- end
38
-
39
- class Boot
40
- def run
41
- load_initializer
42
- Rails::Initializer.run(:set_load_path)
43
- end
44
- end
45
-
46
- class VendorBoot < Boot
47
- def load_initializer
48
- require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/initializer"
49
- Rails::Initializer.run(:install_gem_spec_stubs)
50
- Rails::GemDependency.add_frozen_gem_path
51
- end
52
- end
53
-
54
- class GemBoot < Boot
55
- def load_initializer
56
- self.class.load_rubygems
57
- load_rails_gem
58
- require 'initializer'
59
- end
60
-
61
- def load_rails_gem
62
- if version = self.class.gem_version
63
- gem 'rails', version
64
- else
65
- gem 'rails'
66
- end
67
- rescue Gem::LoadError => load_error
68
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
69
- exit 1
70
- end
71
-
72
- class << self
73
- def rubygems_version
74
- Gem::RubyGemsVersion rescue nil
75
- end
76
-
77
- def gem_version
78
- if defined? RAILS_GEM_VERSION
79
- RAILS_GEM_VERSION
80
- elsif ENV.include?('RAILS_GEM_VERSION')
81
- ENV['RAILS_GEM_VERSION']
82
- else
83
- parse_gem_version(read_environment_rb)
84
- end
85
- end
86
-
87
- def load_rubygems
88
- require 'rubygems'
89
- min_version = '1.3.1'
90
- unless rubygems_version >= min_version
91
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
92
- exit 1
93
- end
94
-
95
- rescue LoadError
96
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
97
- exit 1
98
- end
99
-
100
- def parse_gem_version(text)
101
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
102
- end
103
-
104
- private
105
- def read_environment_rb
106
- environment_rb = "#{RAILS_ROOT}/config/environment.rb"
107
- environment_rb = "#{HELPER_RAILS_ROOT}/config/environment.rb" unless File.exists?(environment_rb)
108
- File.read(environment_rb)
109
- end
110
- end
111
- end
112
- end
113
-
114
- # All that for this:
115
- Rails.boot!
@@ -1,31 +0,0 @@
1
- in_memory:
2
- adapter: sqlite3
3
- database: ":memory:"
4
- verbosity: quiet
5
- pool: 5
6
- timeout: 5000
7
- sqlite:
8
- adapter: sqlite
9
- dbfile: plugin_test.sqlite.db
10
- pool: 5
11
- timeout: 5000
12
- sqlite3:
13
- adapter: sqlite3
14
- dbfile: plugin_test.sqlite3.db
15
- pool: 5
16
- timeout: 5000
17
- postgresql:
18
- adapter: postgresql
19
- username: postgres
20
- password: postgres
21
- database: plugin_test
22
- pool: 5
23
- timeout: 5000
24
- mysql:
25
- adapter: mysql
26
- host: localhost
27
- username: root
28
- password:
29
- database: netzke_core_test
30
- pool: 5
31
- timeout: 5000
@@ -1,14 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'boot')
2
-
3
- Rails::Initializer.run do |config|
4
- config.cache_classes = false
5
- config.whiny_nils = true
6
- config.action_controller.session = {:key => 'rails_session', :secret => 'd229e4d22437432705ab3985d4d246'}
7
- config.plugin_locators.unshift(
8
- Class.new(Rails::Plugin::Locator) do
9
- def plugins
10
- [Rails::Plugin.new(File.expand_path('.'))]
11
- end
12
- end
13
- ) unless defined?(PluginTestHelper::PluginLocator)
14
- end
File without changes
File without changes
@@ -1,4 +0,0 @@
1
- ActionController::Routing::Routes.draw do |map|
2
- map.connect ':controller/:action/:id'
3
- map.connect ':controller/:action/:id.:format'
4
- end
@@ -1,11 +0,0 @@
1
- class CreateRoles < ActiveRecord::Migration
2
- def self.up
3
- create_table :roles do |t|
4
- t.string :name
5
- end
6
- end
7
-
8
- def self.down
9
- drop_table :roles
10
- end
11
- end
@@ -1,12 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def self.up
3
- create_table :users do |t|
4
- t.string :login
5
- t.integer :role_id
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :users
11
- end
12
- end
@@ -1,4 +0,0 @@
1
- # Loads fixtures into the database when running the test app via the console
2
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, '../fixtures/*.{yml,csv}'))).each do |fixture_file|
3
- Fixtures.create_fixtures(File.join(Rails.root, '../fixtures'), File.basename(fixture_file, '.*'))
4
- end
@@ -1,7 +0,0 @@
1
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
2
- libs = " -r irb/completion"
3
- libs << " -r test/test_helper"
4
- libs << " -r console_app"
5
- libs << " -r console_with_helpers"
6
- libs << " -r console_with_fixtures"
7
- exec "#{irb} #{libs} --simple-prompt"