Created
January 24, 2011 09:36
-
-
Save rkh/793008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def require_or_install(path, gem_name = path, version = '> 0') | |
require path | |
rescue LoadError | |
require 'rubygems' | |
require 'rubygems/user_interaction' | |
require 'rubygems/dependency_installer' | |
installer = Gem::DependencyInstaller.new | |
installer.install gem_name, version | |
Gem.refresh | |
Gem.activate gem_name, version | |
require path | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment