From: Luis Lavena Date: 2011-01-07T03:31:27+09:00 Subject: Re: Execute Ruby code after Gem is installed On Jan 6, 1:36 am, Bryan Richardson wrote: > Hello All, > > Can Gem.post_install hooks be used in this case, or should I use the > extensions attribute of a gemspec file to identify code to be executed > after my gem is installed? No, post_install display a message, it doesn't execute code due the insecure nature of executing code from untrusted sources. But... > If post_install hooks can be used, where should the hooks be defined? > > If the extensions attribute can be used, can a .rb file added to the > extensions attribute simply contain random Ruby code, or does it have to > be extconf.rb-style Ruby code in it? > You can use extconf.rb (Ruby Extensions) in the gem specification to generate the required files for your gem to work. Pangolin gem used to do that: https://github.com/iconara/pangolin/blob/master/Rakefile#L8-26 But instead of using extconf.rb now it uses a Rakefile that is executed as extension: https://github.com/iconara/pangolin/blob/master/pangolin.gemspec#L15 Hope that helps you. -- Luis Lavena