I have a gem which needs some rake task to be executed after installation of the gem. There is a hackish way to execute a code after install using method described at http://blog.costan.us/2008/11/post-install-post-update-scripts-for.html.
However Gem class now has hooks, and one of them is a post_install hook. I am trying to add a line like
Gem.post_install { puts 'post hook example' }
into Rakefile and it does not seem to be executed during install. Where should this line to be placed for the hook to be registered?
Create a file at
lib/rubygems_plugin.rb
In this file you can define your custom hooks. For example:
No need to require anything.
Example output:
I only found the documentation for this in the source.
If this doesn't work, or your changes to your post install hook don't always seem to update, uninstall the gem completely before rebuilding and installing it.