-
-
Save stormsilver/3894925 to your computer and use it in GitHub Desktop.
Allow requiring of global gems from outside of the Gemfile
This file contains hidden or 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
# Include this in your .irbrc | |
def unbundled_require(gem, options = {}) | |
if defined?(::Bundler) | |
spec_path = Dir.glob("#{Gem.dir}/specifications/#{gem}-*.gemspec").last | |
if spec_path.nil? | |
warn "Couldn't find #{gem}" | |
return | |
end | |
spec = Gem::Specification.load spec_path | |
spec.activate | |
end | |
begin | |
require options[:require] || gem | |
yield if block_given? | |
rescue Exception => err | |
warn "Couldn't load #{gem}: #{err}" | |
end | |
end | |
# Then use like this | |
unbundled_require 'wirb' do | |
Wirb.start | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment