diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/commands/plugin.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 63b6fee2ad..d2f564485a 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added uninstall.rb hook to plugin handling, such that plugins have a way of removing assets and other artifacts on removal #5003 [takiuchi@drecom.co.jp] + * Create temporary dirs relative to RAILS_ROOT when running script/server #5014 [elliot@townx.org] * Minor tweak to dispatcher to use recognize instead of recognize!, as per the new routes. [Jamis Buck] diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb index 946e947f70..f18a49d683 100644 --- a/railties/lib/commands/plugin.rb +++ b/railties/lib/commands/plugin.rb @@ -185,6 +185,7 @@ class Plugin path = "#{rails_env.root}/vendor/plugins/#{name}" if File.directory?(path) puts "Removing 'vendor/plugins/#{name}'" if $verbose + run_uninstall_hook rm_r path else puts "Plugin doesn't exist: #{path}" @@ -216,6 +217,11 @@ class Plugin load install_hook_file if File.exists? install_hook_file end + def run_uninstall_hook + uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb" + load uninstall_hook_file if File.exists? uninstall_hook_file + end + def install_using_export(options = {}) svn_command :export, options end diff --git a/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb b/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb index ea5fdf2b7d..8a55952ffe 100644 --- a/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +++ b/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb @@ -17,6 +17,7 @@ class PluginGenerator < Rails::Generator::NamedBase m.template 'Rakefile', "#{plugin_path}/Rakefile" m.template 'init.rb', "#{plugin_path}/init.rb" m.template 'install.rb', "#{plugin_path}/install.rb" + m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb" m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb" m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake" m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb" |