Posted By

noah on 02/08/10


Tagged

html script ruby configuration doc rake install documentation rdoc maintenance automation Gem rubygems Task gems Rakefile


Versions (?)

Howto set up a Rake task to update installed gems and gem sources


 / Published in: Ruby
 

URL: http://rake.rubyforge.org/files/doc/rakefile_rdoc.html

Rails has a task like this, but I couldn't locate it, and it wasn't hard to write my own, and mine worked too :|

  1. desc 'check for gem dependencies and install any missing gems'
  2.  
  3. task :gems do
  4. required_gems = %w{
  5. cucumber
  6. mechanize
  7. raakt
  8. rspec
  9. }
  10.  
  11. gem_list = %x{gem list}
  12.  
  13. # check gem sources and only add github if its not already there
  14. if ((%x{gem sources} =~ %r{http://gems.github.com})).nil?
  15. puts %x{gem sources -a http://gems.github.com}
  16. end
  17.  
  18. required_gems.each do | gem_name |
  19. if (gem_list=~ %r{#{gem_name}}).nil?
  20. puts %x{gem install #{gem_name}}
  21. end
  22. end
  23. end

Report this snippet  

You need to login to post a comment.