Using Merb-Slices to manage your gems

Saturday, November 29, 2008

This weekend, I wanted to experiement a bit more with merb-slices, and thought it would be a good idea to use it to manage some of the gems I’ve created. It include few advantages:

  • You can add a web interface to test your gem
  • Rspec is directly include to debug the gem when problems appear
  • It’s easy to create, deploy and could be used in any rails/merb app

I’ve tested the migration with rfeedfinder, a gem to discover feed url from any webpage. In a few easy steps, I migrated the gem into a slice:

  1. Create a slice: merb-gen slice rfeedfinder-slice
  2. Copy te class you need from your gem lib in a new file inside lib/rfeedfinder-slice/ directory. Enclose it inside ‘module RfeedfinderSlice … end
  3. In lib/rfeedfinder-slice.rb, add your gem dependencies at the end of the file
  4. Don’t forget to include your lib file into the dependencies
  5. To install the gem on your system, nothing easier than: sudo rake install

I’ll let you see the web interface, all the routes are already configure, you just need to add a form, and get fancy if you want to use the slice as a proper merb-slice to be included in a complete merb app. Then you can use it in a ruby script, or in other rails/merb applications:

See the end result on github: rfeedfinder-slice

This entry was published on Saturday, November 29, 2008. Articles published around the same time can be found in the archive.