Skip to content

Instantly share code, notes, and snippets.

@oleander
Created April 29, 2011 09:35
Show Gist options
  • Save oleander/948109 to your computer and use it in GitHub Desktop.
Save oleander/948109 to your computer and use it in GitHub Desktop.

Revisions

  1. oleander created this gist Apr 29, 2011.
    17 changes: 17 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    def r(this)
    require this
    puts "#{this} is now loaded."
    rescue LoadError
    puts "The gem '#{this}' is missing."
    puts "Should I install it? [y/n]"
    if gets =~ /yes|y/i
    puts "Installing #{this}, hold on."
    if `gem install #{this}` =~ /Successfully/
    Gem.clear_paths
    require this
    puts "Done, gem loaded."
    end
    else
    puts "Okey, goodbye."
    end
    end