ioquatix-engines 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +280 -0
- data/MIT-LICENSE +21 -0
- data/README +95 -0
- data/Rakefile +199 -0
- data/about.yml +7 -0
- data/bin/rails_engines +103 -0
- data/generators/plugin_migration/USAGE +45 -0
- data/generators/plugin_migration/plugin_migration_generator.rb +78 -0
- data/generators/plugin_migration/templates/plugin_migration.erb +13 -0
- data/lib/engines.rb +185 -0
- data/lib/engines/assets.rb +38 -0
- data/lib/engines/load_engine_tasks.rake +6 -0
- data/lib/engines/plugin.rb +173 -0
- data/lib/engines/plugin/list.rb +57 -0
- data/lib/engines/plugin/migrator.rb +45 -0
- data/lib/engines/rails_extensions/action_mailer.rb +85 -0
- data/lib/engines/rails_extensions/asset_helpers.rb +149 -0
- data/lib/engines/rails_extensions/dependencies.rb +151 -0
- data/lib/engines/rails_extensions/routing.rb +88 -0
- data/lib/engines/testing.rb +87 -0
- data/lib/engines/version.rb +10 -0
- data/rails/init.rb +6 -0
- data/tasks/engines.rake +249 -0
- data/test/app/controllers/app_and_plugin_controller.rb +5 -0
- data/test/app/controllers/application.rb +18 -0
- data/test/app/controllers/namespace/app_and_plugin_controller.rb +5 -0
- data/test/app/helpers/mail_helper.rb +5 -0
- data/test/app/models/app_and_plugin_model.rb +3 -0
- data/test/app/models/notify_mail.rb +26 -0
- data/test/app/things/thing.rb +3 -0
- data/test/app/views/app_and_plugin/a_view.html.erb +1 -0
- data/test/app/views/namespace/app_and_plugin/a_view.html.erb +1 -0
- data/test/app/views/notify_mail/implicit_multipart.text.html.erb +1 -0
- data/test/app/views/notify_mail/implicit_multipart.text.plain.erb +1 -0
- data/test/app/views/notify_mail/multipart_html.html.erb +1 -0
- data/test/app/views/notify_mail/multipart_plain.html.erb +1 -0
- data/test/app/views/notify_mail/signup.text.plain.erb +5 -0
- data/test/app/views/plugin_mail/mail_from_plugin_with_application_template.text.plain.erb +1 -0
- data/test/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb +1 -0
- data/test/functional/controller_loading_test.rb +51 -0
- data/test/functional/exception_notification_compatibility_test.rb +29 -0
- data/test/functional/routes_test.rb +33 -0
- data/test/functional/view_helpers_test.rb +32 -0
- data/test/functional/view_loading_test.rb +60 -0
- data/test/lib/app_and_plugin_lib_model.rb +3 -0
- data/test/lib/engines_test_helper.rb +36 -0
- data/test/plugins/alpha_plugin/app/controllers/alpha_plugin_controller.rb +8 -0
- data/test/plugins/alpha_plugin/app/controllers/app_and_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/namespace/alpha_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/namespace/app_and_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/namespace/shared_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/controllers/shared_plugin_controller.rb +5 -0
- data/test/plugins/alpha_plugin/app/models/alpha_plugin_model.rb +3 -0
- data/test/plugins/alpha_plugin/app/models/app_and_plugin_model.rb +7 -0
- data/test/plugins/alpha_plugin/app/models/shared_plugin_model.rb +3 -0
- data/test/plugins/alpha_plugin/app/views/alpha_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/app_and_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/layouts/plugin_layout.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/namespace/alpha_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/namespace/app_and_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/namespace/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/app/views/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/alpha_plugin/lib/alpha_plugin_lib_model.rb +3 -0
- data/test/plugins/alpha_plugin/lib/app_and_plugin_lib_model.rb +7 -0
- data/test/plugins/beta_plugin/app/controllers/app_and_plugin_controller.rb +5 -0
- data/test/plugins/beta_plugin/app/controllers/namespace/shared_plugin_controller.rb +5 -0
- data/test/plugins/beta_plugin/app/controllers/shared_plugin_controller.rb +5 -0
- data/test/plugins/beta_plugin/app/models/shared_plugin_model.rb +3 -0
- data/test/plugins/beta_plugin/app/views/namespace/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/beta_plugin/app/views/shared_plugin/a_view.html.erb +1 -0
- data/test/plugins/beta_plugin/init.rb +1 -0
- data/test/plugins/not_a_plugin/public/should_not_be_copied.txt +0 -0
- data/test/plugins/test_assets/app/controllers/assets_controller.rb +2 -0
- data/test/plugins/test_assets/app/views/assets/index.html.erb +3 -0
- data/test/plugins/test_assets/app/views/layouts/assets.html.erb +3 -0
- data/test/plugins/test_assets/init.rb +0 -0
- data/test/plugins/test_assets/public/file.txt +0 -0
- data/test/plugins/test_assets/public/subfolder/file_in_subfolder.txt +0 -0
- data/test/plugins/test_assets_with_assets_directory/assets/file.txt +0 -0
- data/test/plugins/test_assets_with_assets_directory/assets/subfolder/file_in_subfolder.txt +0 -0
- data/test/plugins/test_assets_with_assets_directory/init.rb +0 -0
- data/test/plugins/test_assets_with_no_subdirectory/assets/file.txt +0 -0
- data/test/plugins/test_assets_with_no_subdirectory/init.rb +0 -0
- data/test/plugins/test_code_mixing/app/things/thing.rb +3 -0
- data/test/plugins/test_code_mixing/init.rb +1 -0
- data/test/plugins/test_load_path/init.rb +0 -0
- data/test/plugins/test_migration/db/migrate/001_create_tests.rb +11 -0
- data/test/plugins/test_migration/db/migrate/002_create_others.rb +11 -0
- data/test/plugins/test_migration/db/migrate/003_create_extras.rb +11 -0
- data/test/plugins/test_migration/init.rb +0 -0
- data/test/plugins/test_plugin_mailing/app/models/plugin_mail.rb +26 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.text.plain.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_html.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_plain.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_html.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/app/views/plugin_mail/multipart_from_plugin_with_application_template_plain.html.erb +1 -0
- data/test/plugins/test_plugin_mailing/init.rb +0 -0
- data/test/plugins/test_routing/app/controllers/namespace/test_routing_controller.rb +5 -0
- data/test/plugins/test_routing/app/controllers/test_routing_controller.rb +9 -0
- data/test/plugins/test_routing/init.rb +0 -0
- data/test/plugins/test_routing/routes.rb +2 -0
- data/test/plugins/test_testing/init.rb +0 -0
- data/test/plugins/test_testing/test/fixtures/testing_fixtures.yml +0 -0
- data/test/unit/action_mailer_test.rb +54 -0
- data/test/unit/arbitrary_code_mixing_test.rb +41 -0
- data/test/unit/assets_test.rb +48 -0
- data/test/unit/load_path_test.rb +58 -0
- data/test/unit/migration_test.rb +63 -0
- data/test/unit/model_and_lib_test.rb +37 -0
- data/test/unit/plugins_test.rb +11 -0
- data/test/unit/testing_test.rb +18 -0
- metadata +259 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
= EDGE
|
2
|
+
|
3
|
+
* Samuel Williams (http://www.oriontransfer.co.nz/):
|
4
|
+
Updated asset helper to support a new syntax which is compatible with :cache. Retained old syntax behaviour too.
|
5
|
+
New syntax is as follows, for javascript and css helpers
|
6
|
+
javascript_include_tag [:plugin_name, 'jsfile'], [:other_plugin_name, 'jsfile']
|
7
|
+
This means all javascript files can be referenced in one helper, and thus :cache can be used to combine them all together.
|
8
|
+
|
9
|
+
* Samuel Williams (http://www.oriontransfer.co.nz/):
|
10
|
+
Thanks to Tekin for his patches.
|
11
|
+
Updated migrations system to tie in more closely with the current rails mechanism.
|
12
|
+
Rake task for updating database schema info
|
13
|
+
rake db:migrate:upgrade_plugin_migrations
|
14
|
+
Please see http://engines.lighthouseapp.com/projects/10178-engines-plugin/tickets/17 for more information.
|
15
|
+
|
16
|
+
* Refactored the view loading to work with changes in Edge Rails
|
17
|
+
|
18
|
+
* Fixed integration of plugin migrations with the new, default timestamped migrations in Edge Rails
|
19
|
+
|
20
|
+
* Refactored tests into the plugin itself - the plugin can now generate its own test_app harness and run tests within it.
|
21
|
+
|
22
|
+
|
23
|
+
= 2.0.0 - (ANOTHER) MASSIVE INTERNAL REFACTORING
|
24
|
+
|
25
|
+
* Engines now conforms to the new plugin loading mechanism, delegating plugin load order and lots of other things to Rails itself.
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
= 1.2.2
|
30
|
+
|
31
|
+
* Added the ability to code mix different types of files, cleaning up the existing code-mixing implementation slightly (Ticket #271)
|
32
|
+
|
33
|
+
|
34
|
+
= 1.2.1
|
35
|
+
|
36
|
+
* Added documentation to clarify some of the issues with Rails unloading classes that aren't required using "require_dependency" (Ticket #266)
|
37
|
+
|
38
|
+
* Fixed a bug where test_help was being loaded when it wasn't needed, and was actually causing problems (Ticket #265)
|
39
|
+
|
40
|
+
|
41
|
+
= 1.2.0 - MASSIVE INTERNAL REFACTORING
|
42
|
+
|
43
|
+
* !!!Support for Rails < 1.2 has been dropped!!!; if you are using Rails =< 1.1.6, please use Engines 1.1.6, available from http://svn.rails-engines.org/engines/tags/rel_1.1.6
|
44
|
+
|
45
|
+
* Engines are dead! Long live plugins! There is now no meaningful notion of an engine - all plugins can take advantage of the more powerful features that the engines plugin provides by including app directories, etc.
|
46
|
+
|
47
|
+
* Init_engine.rb is no longer used; please use the plugin-standard init.rb instead.
|
48
|
+
|
49
|
+
* Engines.start is no longer required; please use the config.plugins array provided by Rails instead
|
50
|
+
|
51
|
+
* To get the most benefit from Engines, set config.plugins to ["engines", "*"] to load the engines plugin first, and then all other plugins in their normal order after.
|
52
|
+
|
53
|
+
* Access all loaded plugins via the new Rails.plugins array, and by name using Rails.plugins[:plugin_name].
|
54
|
+
|
55
|
+
* Access plugin metadata loaded automatically from about.yml: Rails.plugins[:name].about. Plugin#version is provided directly, for easy access.
|
56
|
+
|
57
|
+
* Module.config is has been removed - use mattr_accessor instead, and initialize your default values via the init.rb mechanism.
|
58
|
+
|
59
|
+
* Public asset helpers have been rewritten; instead of engine_stylesheet, now use stylesheet_link_tag :name, :plugin => "plugin_name"
|
60
|
+
|
61
|
+
* Plugin migrations have been reworked to integrate into the main migration stream. Please run script/generate plugin_migration to create plugin migrations in your main application.
|
62
|
+
|
63
|
+
* The fixture method for loading fixtures against any class has been removed; instead, engines will now provide a mechanism for loading fixtures from all plugins, by mirroring fixtures into a common location.
|
64
|
+
|
65
|
+
* All references to engines have been removed; For example, any rake tasks which applied to engines now apply to all plugins. The default Rails rake tasks for plugins are overridden where necessary.
|
66
|
+
|
67
|
+
* Layouts can now be shared via plugins - inspiration gratefully taken from PluginAWeek's plugin_routing :)
|
68
|
+
|
69
|
+
* Actual routing from plugins is now possible, by including routes.rb in your plugin directory and using the from_plugin method in config/routes.rb (Ticket #182)
|
70
|
+
|
71
|
+
* Controllers are no longer loaded twice if they're not present in the normal app/ directory (Ticket #177)
|
72
|
+
|
73
|
+
* The preferred location for javascripts/stylesheets/etc is now 'assets' rather than 'public'
|
74
|
+
|
75
|
+
* Ensure that plugins started before routing have their controllers appropriately added to config.controller_paths (Ticket #258)
|
76
|
+
|
77
|
+
* Removed Engines.version - it's not longer relevant, now we're loading version information from about.yml files.
|
78
|
+
|
79
|
+
* Added a huge amount of documentation to all new modules.
|
80
|
+
|
81
|
+
* Added new warning message if installation of engines 1.2.x is attempted in a Rails 1.1.x application
|
82
|
+
|
83
|
+
* Added details of the removal of the config method to UPGRADING
|
84
|
+
|
85
|
+
* Removed the plugins:info rake task in favour of adding information to script/about via the Rails::Info module (Ticket #261)
|
86
|
+
|
87
|
+
* Improved handling of testing and documentation tasks for plugins
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
= 1.1.4
|
92
|
+
|
93
|
+
* Fixed creation of multipart emails (Ticket #190)
|
94
|
+
|
95
|
+
* Added a temporary fix to the code-mixing issue. In your engine's test/test_helper.rb, please add the following lines:
|
96
|
+
|
97
|
+
# Ensure that the code mixing and view loading from the application is disabled
|
98
|
+
Engines.disable_app_views_loading = true
|
99
|
+
Engines.disable_app_code_mixing = true
|
100
|
+
|
101
|
+
which will prevent code mixing for controllers and helpers, and loading views from the application. One thing to remember is to load any controllers/helpers using 'require_or_load' in your tests, to ensure that the engine behaviour is respected (Ticket #135)
|
102
|
+
|
103
|
+
* Added tasks to easily test engines individually (Ticket #120)
|
104
|
+
|
105
|
+
* Fixture extensions will now fail with an exception if the corresponding class cannot be loaded (Ticket #138)
|
106
|
+
|
107
|
+
* Patch for new routing/controller loading in Rails 1.1.6. The routing code is now replaced with the contents of config.controller_paths, along with controller paths from any started engines (Ticket #196)
|
108
|
+
|
109
|
+
* Rails' Configuration instance is now stored, and available from all engines and plugins.
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
= 1.1.3
|
114
|
+
|
115
|
+
* Fixed README to show 'models' rather than 'model' class (Ticket #167)
|
116
|
+
* Fixed dependency loading to work with Rails 1.1.4 (Ticket #180)
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
= 1.1.2
|
121
|
+
|
122
|
+
* Added better fix to version checking (Ticket #130, jdell@gbdev.com).
|
123
|
+
|
124
|
+
* Fixed generated init_engine.rb so that VERSION module doesn't cause probems (Ticket #131, japgolly@gmail.com)
|
125
|
+
|
126
|
+
* Fixed error with Rails 1.0 when trying to ignore the engine_schema_info table (Ticket #132, snowblink@gmail.com)
|
127
|
+
|
128
|
+
* Re-added old style rake tasks (Ticket #133)
|
129
|
+
|
130
|
+
* No longer adding all subdirectories of <engine>/app or <engine>/lib, as this can cause issues when files are grouped in modules (Ticket #149, kasatani@gmail.com)
|
131
|
+
|
132
|
+
* Fixed engine precidence ordering for Rails 1.1 (Ticket #146)
|
133
|
+
|
134
|
+
* Added new Engines.each method to assist in processing the engines in the desired order (Ticket #146)
|
135
|
+
|
136
|
+
* Fixed annoying error message at appears when starting the console in development mode (Ticket #134)
|
137
|
+
|
138
|
+
* Engines is now super-careful about loading the correct version of Rails from vendor (Ticket #154)
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
= 1.1.1
|
143
|
+
|
144
|
+
* Fixed migration rake task failing when given a specific version (Ticket #115)
|
145
|
+
|
146
|
+
* Added new rake task "test:engines" which will test engines (and other plugins) but ensure that the test database is cloned from development beforehand (Ticket #125)
|
147
|
+
|
148
|
+
* Fixed issue where 'engine_schema_info' table was included in schema dumps (Ticket #87)
|
149
|
+
|
150
|
+
* Fixed multi-part emails (Ticket #121)
|
151
|
+
|
152
|
+
* Added an 'install.rb' file to new engines created by the bundled generator, which installs the engines plugin automatically if it doesn't already exist (Ticket #122)
|
153
|
+
|
154
|
+
* Added a default VERSION module to generated engines (Ticket #123)
|
155
|
+
|
156
|
+
* Refactored copying of engine's public files to a method of an Engine instance. You can now call Engines.get(:engine_name).copy_public_files (Ticket #108)
|
157
|
+
|
158
|
+
* Changed engine generator templates from .rb files to .erb files (Ticket #106)
|
159
|
+
|
160
|
+
* Fixed the test_helper.erb file to use the correct testing extensions and not load any schema - the schema will be cloned automatically via rake test:engines
|
161
|
+
|
162
|
+
* Fixed problem when running with Rails 1.1.1 where version wasn't determined correctly (Ticket #129)
|
163
|
+
|
164
|
+
* Fixed bug preventing engines from loading when both Rails 1.1.0 and 1.1.1 gems are installed and in use.
|
165
|
+
|
166
|
+
* Updated version (d'oh!)
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
= 1.1.0
|
171
|
+
|
172
|
+
* Improved regexp matching for Rails 1.0 engines with peculiar paths
|
173
|
+
|
174
|
+
* Engine instance objects can be accessed via Engines[:name], an alias for Engines.get(:name) (Ticket #99)
|
175
|
+
|
176
|
+
* init_engine.rb is now processed as the final step in the Engine.start process, so it can access files within the lib directory, which is now in the $LOAD_PATH at that point. (Ticket #99)
|
177
|
+
|
178
|
+
* Clarified MIT license (Ticket #98)
|
179
|
+
|
180
|
+
* Updated Rake tasks to integrate smoothly with Rails 1.1 namespaces
|
181
|
+
|
182
|
+
* Changed the version to "1.1.0 (svn)"
|
183
|
+
|
184
|
+
* Added more information about using the plugin with Edge Rails to the README
|
185
|
+
|
186
|
+
* moved extensions into lib/engines/ directory to enable use of Engines module in extension code.
|
187
|
+
|
188
|
+
* Added conditional require_or_load method which attempts to detect the current Rails version. To use the Edge Rails version of the loading mechanism, add the line:
|
189
|
+
|
190
|
+
* Engines.config :edge, true
|
191
|
+
|
192
|
+
* to your environment.rb file.
|
193
|
+
|
194
|
+
* Merged changes from /branches/edge and /branches/rb_1.0 into /trunk
|
195
|
+
|
196
|
+
* engine_schema_info now respects the prefix/suffixes set for ActiveRecord::Base (Ticket #67)
|
197
|
+
|
198
|
+
* added ActiveRecord::Base.wrapped_table_name(name) method to assist in determining the correct table name
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
= 1.0.6
|
203
|
+
|
204
|
+
* Added ability to determine version information for engines: rake engine_info
|
205
|
+
|
206
|
+
* Added a custom logger for the Engines module, to stop pollution of the Rails logs.
|
207
|
+
|
208
|
+
* Added some more tests (in particular, see rails_engines/applications/engines_test).
|
209
|
+
|
210
|
+
* Another attempt at solving Ticket #53 - controllers and helpers should now be loadable from modules, and if a full path (including RAILS_ROOT/ENGINES_ROOT) is given, it should be safely stripped from the require filename such that corresponding files can be located in any active engines. In other words, controller/helper overloading should now completely work, even if the controllers/helpers are in modules.
|
211
|
+
|
212
|
+
* Added (finally) patch from Ticket #22 - ActionMailer helpers should now load
|
213
|
+
|
214
|
+
* Removed support for Engines.start :engine, :engine_name => 'whatever'. It was pointless.
|
215
|
+
|
216
|
+
* Fixed engine name referencing; engine_stylesheet/engine_javascript can now happily use shorthand engine names (i.e. :test == :test_engine) (Ticket #45)
|
217
|
+
|
218
|
+
* Fixed minor documentation error ('Engine.start' ==> 'Engines.start') (Ticket #57)
|
219
|
+
|
220
|
+
* Fixed double inclusion of RAILS_ROOT in engine_migrate rake task (Ticket #61)
|
221
|
+
|
222
|
+
* Added ability to force config values even if given as a hash (Ticket #62)
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
= 1.0.5
|
227
|
+
|
228
|
+
* Fixed bug stopping fixtures from loading with PostgreSQL
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
= 1.0.4
|
233
|
+
|
234
|
+
* Another attempt at loading controllers within modules (Ticket #56)
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
= 1.0.3
|
239
|
+
|
240
|
+
* Fixed serious dependency bug stopping controllers being loaded (Ticket #56)
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
= 1.0.2
|
245
|
+
|
246
|
+
* Fixed bug with overloading controllers in modules from /app directory
|
247
|
+
|
248
|
+
* Fixed exception thrown when public files couldn't be created; exception is now logged (Ticket #52)
|
249
|
+
|
250
|
+
* Fixed problem with generated test_helper.rb file via File.expand_path (Ticket #50)
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
= 1.0.1
|
255
|
+
|
256
|
+
* Added engine generator for creation of new engines
|
257
|
+
|
258
|
+
* Fixed 'Engine' typo in README
|
259
|
+
|
260
|
+
* Fixed bug in fixtures extensions
|
261
|
+
|
262
|
+
* Fixed /lib path management bug
|
263
|
+
|
264
|
+
* Added method to determine public directory location from Engine object
|
265
|
+
|
266
|
+
* Fixed bug in the error message in get_engine_dir()
|
267
|
+
|
268
|
+
* Added proper component loading
|
269
|
+
|
270
|
+
* Added preliminary tests for the config() methods module
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
= pre-v170
|
275
|
+
|
276
|
+
* Fixed copyright notices to point to DHH, rather than me.
|
277
|
+
|
278
|
+
* Moved extension require statements into lib/engines.rb, so the will be loaded if another module/file calls require 'engines
|
279
|
+
|
280
|
+
* Added a CHANGELOG file (this file)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2008 James Adam
|
2
|
+
|
3
|
+
The MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
The gemified engines plugin is a work in progress. Thanks to all the people who have made engines possible. It is a great project.
|
2
|
+
|
3
|
+
This is my fork of engines. I'll be maintaining it for as long as it is relevant.
|
4
|
+
|
5
|
+
The engines plugin enhances Rails' own plugin framework, making it simple to share controllers, helpers, models, public assets, routes and migrations in plugins.
|
6
|
+
|
7
|
+
For information regarding this particular gem, please see http://wiki.oriontransfer.org/?rails:engines
|
8
|
+
|
9
|
+
For information regarding the original project, see http://rails-engines.org
|
10
|
+
|
11
|
+
= Installing the gem
|
12
|
+
|
13
|
+
gem install ioquatix-engines --source=http://gems.github.com/
|
14
|
+
|
15
|
+
= Using the plugin
|
16
|
+
|
17
|
+
Once you've installed the engines plugin, you'll need to add a few lines to the top of config/environment.rb:
|
18
|
+
|
19
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
20
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
21
|
+
|
22
|
+
+ # Load engines plugin
|
23
|
+
+ gem 'ioquatix-engines', Rails::VERSION::STRING
|
24
|
+
+ require 'engines'
|
25
|
+
|
26
|
+
You should add this line just below the require for Rails' own boot.rb file.
|
27
|
+
|
28
|
+
With that aside, you're now ready to start using more powerful plugins in your application. Read on to find out more about what the engines plugin enables.
|
29
|
+
|
30
|
+
== Better plugins
|
31
|
+
|
32
|
+
In addition to the regular set of plugin-supported files (lib, init.rb, tasks, generators, tests), plugins can carry the following when the engines plugin is also installed.
|
33
|
+
|
34
|
+
=== Controllers, Helpers, and Views
|
35
|
+
|
36
|
+
Include these files in an <tt>app</tt> directory just like you would in a normal Rails application. If you need to override a method, view or partial, create the corresponding file in your main <tt>app</tt> directory and it will be used instead.
|
37
|
+
|
38
|
+
* Controllers & Helpers: See Engines::RailsExtensions::Dependencies for more information.
|
39
|
+
* Views: now handled almost entirely by ActionView itself (see Engines::Plugin#add_plugin_view_paths for more information)
|
40
|
+
|
41
|
+
=== Models
|
42
|
+
|
43
|
+
Model code can similarly be placed in an <tt>app/models/</tt> directory. Unfortunately, it's not possible to automatically override methods within a model; if your application needs to change the way a model behaves, consider creating a subclass, or replacing the model entirely within your application's <tt>app/models/</tt> directory. See Engines::RailsExtensions::Dependencies for more information.
|
44
|
+
|
45
|
+
IMPORTANT NOTE: when you load code from within plugins, it is typically not handled well by Rails in terms of unloading and reloading changes. Look here for more information - http://rails-engines.org/development/common-issues-when-overloading-code-from-plugins/
|
46
|
+
|
47
|
+
=== Routes
|
48
|
+
|
49
|
+
Include your route declarations in a <tt>routes.rb</tt> file at the root of your plugins, e.g.:
|
50
|
+
|
51
|
+
connect "/my/url", :controller => "some_controller"
|
52
|
+
my_named_route "do_stuff", :controller => "blah", :action => "stuff"
|
53
|
+
# etc.
|
54
|
+
|
55
|
+
You can then load these files into your application by declaring their inclusion in the application's <tt>config/routes.rb</tt>:
|
56
|
+
|
57
|
+
map.from_plugin :plugin_name
|
58
|
+
|
59
|
+
See Engines::RailsExtensions::Routing for more information.
|
60
|
+
|
61
|
+
=== Migrations
|
62
|
+
|
63
|
+
Migrations record the changes in your database as your application evolves. With engines 1.2, migrations from plugins can also join in this evolution as first-class entities. To add migrations to a plugin, include a <tt>db/migrate/</tt> folder and add migrations there as normal. These migrations can then be integrated into the main flow of database evolution by running the plugin_migration generator:
|
64
|
+
|
65
|
+
script/generate plugin_migration
|
66
|
+
|
67
|
+
This will produce a migration in your application. Running this migration (via <tt>rake db:migrate</tt>, as normal) will migrate the database according to the latest migrations in each plugin. See Engines::RailsExtensions::Migrations for more information.
|
68
|
+
|
69
|
+
=== More powerful Rake tasks
|
70
|
+
|
71
|
+
The engines plugin enhances and adds to the suite of default rake tasks for working with plugins. The <tt>doc:plugins</tt> task now includes controllers, helpers and models under <tt>app</tt>, and anything other code found under the plugin's <tt>code_paths</tt> attribute. New testing tasks have been added to run unit, functional and integration tests from plugins, whilst making it easier to load fixtures from plugins. See Engines::Testing for more details about testing, and run
|
72
|
+
|
73
|
+
rake -T
|
74
|
+
|
75
|
+
to see the set of rake tasks available.
|
76
|
+
|
77
|
+
= Testing the engines plugin itself
|
78
|
+
|
79
|
+
Because of the way the engines plugin modifies Rails, the simplest way to consistently test it against multiple versions is by generating a test harness application - a full Rails application that includes tests to verify the engines plugin behaviour in a real, running environment.
|
80
|
+
|
81
|
+
Run the tests like this (example is on Mac OS X):
|
82
|
+
|
83
|
+
$ cd /Library/Ruby/Gems/1.8/gems/ioquatix-engines/
|
84
|
+
$ rake test
|
85
|
+
|
86
|
+
This will generate a test_app directory within the engines plugin (using the default 'rails' command), import tests and code into that application and then run the test suite.
|
87
|
+
|
88
|
+
If you wish to test against a specific version of Rails, run the tests with the RAILS environment variable set to the local directory containing your Rails checkout
|
89
|
+
|
90
|
+
$ rake test RAILS=/Users/james/Code/rails_edge_checkout
|
91
|
+
|
92
|
+
Alternatively, you can clone the latest version of Rails ('edge rails') from github like so:
|
93
|
+
|
94
|
+
$ rake test RAILS=edge
|
95
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
task :default => :doc
|
6
|
+
|
7
|
+
desc 'Generate documentation for the engines plugin.'
|
8
|
+
Rake::RDocTask.new(:doc) do |doc|
|
9
|
+
doc.rdoc_dir = 'doc'
|
10
|
+
doc.title = 'Engines'
|
11
|
+
doc.main = "README"
|
12
|
+
doc.rdoc_files.include("README", "CHANGELOG", "MIT-LICENSE")
|
13
|
+
doc.rdoc_files.include('lib/**/*.rb')
|
14
|
+
doc.options << '--line-numbers' << '--inline-source'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Run the engine plugin tests within their test harness'
|
18
|
+
task :cruise do
|
19
|
+
# checkout the project into a temporary directory
|
20
|
+
version = "rails_2.0"
|
21
|
+
test_dir = "#{Dir.tmpdir}/engines_plugin_#{version}_test"
|
22
|
+
puts "Checking out test harness for #{version} into #{test_dir}"
|
23
|
+
`svn co http://svn.rails-engines.org/test/engines/#{version} #{test_dir}`
|
24
|
+
|
25
|
+
# run all the tests in this project
|
26
|
+
Dir.chdir(test_dir)
|
27
|
+
load 'Rakefile'
|
28
|
+
puts "Running all tests in test harness"
|
29
|
+
['db:migrate', 'test', 'test:plugins'].each do |t|
|
30
|
+
Rake::Task[t].invoke
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
task :clean => [:clobber_doc, "test:clean"]
|
35
|
+
|
36
|
+
namespace :test do
|
37
|
+
|
38
|
+
# Yields a block with STDOUT and STDERR silenced. If you *really* want
|
39
|
+
# to output something, the block is yielded with the original output
|
40
|
+
# streams, i.e.
|
41
|
+
#
|
42
|
+
# silence do |o, e|
|
43
|
+
# puts 'hello!' # no output produced
|
44
|
+
# o.puts 'hello!' # output on STDOUT
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# (based on silence_stream in ActiveSupport.)
|
48
|
+
def silence
|
49
|
+
yield(STDOUT, STDERR) if ENV['VERBOSE']
|
50
|
+
streams = [STDOUT, STDERR]
|
51
|
+
actual_stdout = STDOUT.dup
|
52
|
+
actual_stderr = STDERR.dup
|
53
|
+
streams.each do |s|
|
54
|
+
s.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
55
|
+
s.sync = true
|
56
|
+
end
|
57
|
+
yield actual_stdout, actual_stderr
|
58
|
+
ensure
|
59
|
+
STDOUT.reopen(actual_stdout)
|
60
|
+
STDERR.reopen(actual_stderr)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_app_dir
|
64
|
+
File.join(File.dirname(__FILE__), 'test_app')
|
65
|
+
end
|
66
|
+
|
67
|
+
def run(cmd)
|
68
|
+
cmd = cmd.join(" && ") if cmd.is_a?(Array)
|
69
|
+
system(cmd) || raise("failed running '#{cmd}'")
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'Remove the test application'
|
73
|
+
task :clean do
|
74
|
+
FileUtils.rm_r(test_app_dir) if File.exist?(test_app_dir)
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Build the test rails application (use RAILS=[edge,<directory>] to test against specific version)'
|
78
|
+
task :generate_app do
|
79
|
+
silence do |out, err|
|
80
|
+
out.puts "> Creating test application at #{test_app_dir}"
|
81
|
+
|
82
|
+
if ENV['RAILS']
|
83
|
+
vendor_dir = File.join(test_app_dir, 'vendor')
|
84
|
+
FileUtils.mkdir_p vendor_dir
|
85
|
+
|
86
|
+
if ENV['RAILS'] == 'edge'
|
87
|
+
out.puts " Cloning Edge Rails from GitHub"
|
88
|
+
run "cd #{vendor_dir} && git clone --depth 1 git://github.com/rails/rails.git"
|
89
|
+
elsif ENV['RAILS'] =~ /\d\.\d\.\d/
|
90
|
+
if ENV['CURL']
|
91
|
+
out.puts " Cloning Rails Tag #{ENV['RAILS']} from GitHub using curl and tar"
|
92
|
+
run ["cd #{vendor_dir}",
|
93
|
+
"mkdir rails",
|
94
|
+
"cd rails",
|
95
|
+
"curl -s -L http://github.com/rails/rails/tarball/#{ENV['RAILS']} | tar xzv --strip-components 1"]
|
96
|
+
else
|
97
|
+
out.puts " Cloning Rails Tag #{ENV['RAILS']} from GitHub (can be slow - set CURL=true to use curl)"
|
98
|
+
run ["cd #{vendor_dir}",
|
99
|
+
"git clone git://github.com/rails/rails.git",
|
100
|
+
"cd rails",
|
101
|
+
"git pull",
|
102
|
+
"git checkout v#{ENV['RAILS']}"]
|
103
|
+
end
|
104
|
+
elsif File.exist?(ENV['RAILS'])
|
105
|
+
out.puts " Linking rails from #{ENV['RAILS']}"
|
106
|
+
run "cd #{vendor_dir} && ln -s #{ENV['RAILS']} rails"
|
107
|
+
else
|
108
|
+
raise "Couldn't build test application from '#{ENV['RAILS']}'"
|
109
|
+
end
|
110
|
+
|
111
|
+
out.puts " generating rails default directory structure"
|
112
|
+
run "ruby #{File.join(vendor_dir, 'rails', 'railties', 'bin', 'rails')} #{test_app_dir}"
|
113
|
+
else
|
114
|
+
version = `rails --version`.chomp.split.last
|
115
|
+
out.puts " building rails using the 'rails' command (rails version: #{version})"
|
116
|
+
run "rails #{test_app_dir}"
|
117
|
+
end
|
118
|
+
|
119
|
+
# get the database config and schema in place
|
120
|
+
out.puts " writing database.yml"
|
121
|
+
require 'yaml'
|
122
|
+
File.open(File.join(test_app_dir, 'config', 'database.yml'), 'w') do |f|
|
123
|
+
f.write(%w(development test).inject({}) do |h, env|
|
124
|
+
h[env] = {"adapter" => "sqlite3", "database" => "engines_#{env}.sqlite3"} ; h
|
125
|
+
end.to_yaml)
|
126
|
+
end
|
127
|
+
out.puts " installing exception_notification plugin"
|
128
|
+
run "cd #{test_app_dir} && ./script/plugin install exception_notification"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def insert_line(line, options)
|
133
|
+
line = line + "\n"
|
134
|
+
target_file = File.join(test_app_dir, options[:into])
|
135
|
+
lines = File.readlines(target_file)
|
136
|
+
return if lines.include?(line)
|
137
|
+
|
138
|
+
if options[:after]
|
139
|
+
if options[:after].is_a?(String)
|
140
|
+
after_line = options[:after] + "\n"
|
141
|
+
else
|
142
|
+
after_line = lines.find { |l| l =~ options[:after] }
|
143
|
+
raise "couldn't find a line matching #{options[:after].inspect} in #{target_file}" unless after_line
|
144
|
+
end
|
145
|
+
index = lines.index(after_line)
|
146
|
+
raise "couldn't find line '#{after_line}' in #{target_file}" unless index
|
147
|
+
lines.insert(index + 1, line)
|
148
|
+
else
|
149
|
+
lines << line
|
150
|
+
end
|
151
|
+
File.open(target_file, 'w') { |f| f.write lines.join }
|
152
|
+
end
|
153
|
+
|
154
|
+
def mirror_test_files(src, dest=nil)
|
155
|
+
destination_dir = File.join(*([test_app_dir, dest].compact))
|
156
|
+
FileUtils.cp_r(File.join(File.dirname(__FILE__), 'test', src), destination_dir)
|
157
|
+
end
|
158
|
+
|
159
|
+
desc 'Update the plugin and tests files in the test application from the plugin'
|
160
|
+
task :mirror_engine_files => [:test_app] do
|
161
|
+
puts "> Modifying default config files to load engines plugin"
|
162
|
+
insert_line("gem 'ioquatix-engines', Rails::VERSION::STRING\nrequire 'engines'",
|
163
|
+
:into => 'config/environment.rb',
|
164
|
+
:after => "require File.join(File.dirname(__FILE__), 'boot')")
|
165
|
+
|
166
|
+
insert_line('map.from_plugin :test_routing', :into => 'config/routes.rb',
|
167
|
+
:after => /\AActionController::Routing::Routes/)
|
168
|
+
|
169
|
+
insert_line("require 'engines_test_helper'", :into => 'test/test_helper.rb')
|
170
|
+
|
171
|
+
puts "> Mirroring test application files into #{test_app_dir}"
|
172
|
+
mirror_test_files('app')
|
173
|
+
mirror_test_files('lib')
|
174
|
+
mirror_test_files('plugins', 'vendor')
|
175
|
+
mirror_test_files('unit', 'test')
|
176
|
+
mirror_test_files('functional', 'test')
|
177
|
+
end
|
178
|
+
|
179
|
+
desc 'Prepare the engines test environment'
|
180
|
+
task :test_app do
|
181
|
+
version_tag = File.join(test_app_dir, 'RAILS_VERSION')
|
182
|
+
existing_version = File.read(version_tag).chomp rescue 'unknown'
|
183
|
+
if existing_version == ENV['RAILS']
|
184
|
+
puts "> Reusing existing test application (#{ENV['RAILS']})"
|
185
|
+
else
|
186
|
+
puts "> Recreating test application"
|
187
|
+
Rake::Task["test:clean"].invoke
|
188
|
+
Rake::Task["test:generate_app"].invoke
|
189
|
+
|
190
|
+
File.open(version_tag, "w") { |f| f.write ENV['RAILS'] }
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
task :test => "test:mirror_engine_files" do
|
196
|
+
puts "> Loading the test application environment and running tests"
|
197
|
+
# We use exec here to replace the current running rake process
|
198
|
+
exec("cd #{test_app_dir} && rake db:migrate && rake")
|
199
|
+
end
|