Created
July 10, 2012 15:59
-
-
Save BugRoger/3084317 to your computer and use it in GitHub Desktop.
How to load global gems not defined in a 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
begin | |
# Blerg. Mess global gems into the load path. This doesn't work for all gems. | |
# But it's good enough for basic irb gems. | |
if defined?(::Bundler) | |
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first | |
if global_gemset | |
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*") | |
all_global_gem_paths.each do |p| | |
gem_path = "#{p}/lib" | |
$LOAD_PATH << gem_path | |
end | |
end | |
end | |
require "awesome_print" | |
IRB::Irb.class_eval do | |
def output_value | |
ap @context.last_value | |
end | |
end | |
rescue Exception => e | |
warn "Error loading irbrc: #{e}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment