Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify a Ruby gem

Tags:

ruby

gem

How can I modify an existing *.gem file? I want to modify a Rakefile in a gem so that it will be able to compile on Windows.

like image 394
aztack Avatar asked Apr 01 '11 16:04

aztack


2 Answers

Download its source code into a separate folder (perhaps from github). Then modify your Gemfile to point to the source directly so that you can edit it and test your changes directly.

For example, let's say that you want to edit the secure_headers gem and that you've cloned it into ~/workspace/secureheaders. Then you can use the following in your Gemfile:

gem 'secure_headers', :path => "~/workspace/secureheaders" 

Then, just modify the source files inside the source tree and you should be able to see your changes applied directly.

like image 188
dionyziz Avatar answered Sep 19 '22 13:09

dionyziz


You can gem unpack it, add your modification, then modify the gemspec if necessary and build it again:

  • gem unpack
  • gem build
like image 29
Michael Kohl Avatar answered Sep 21 '22 13:09

Michael Kohl