Last active
August 29, 2015 14:03
-
-
Save pinzolo/54cf22c9d50c6547becc to your computer and use it in GitHub Desktop.
.pryrc
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
Pry::DEFAULT_HOOKS.add_hook(:before_session, :gem_auto_require) do |out, target, _pry_| | |
dir = `pwd`.chomp | |
gem_name = File.basename(dir) | |
if File.exist?(File.join(dir, "#{gem_name}.gemspec")) | |
lib = File.join(dir, 'lib') | |
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
if File.exist?(File.join(lib, "#{gem_name}.rb")) | |
begin | |
require gem_name | |
rescue LoadError => e | |
puts "gem_auto_require: #{e.message}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment