Skip to content

Instantly share code, notes, and snippets.

@stormsilver
Forked from zaius/unbundled_require.rb
Created October 15, 2012 19:59
Show Gist options
  • Save stormsilver/3894925 to your computer and use it in GitHub Desktop.
Save stormsilver/3894925 to your computer and use it in GitHub Desktop.
Allow requiring of global gems from outside of the Gemfile
# 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