Skip to content

Instantly share code, notes, and snippets.

@pinzolo
Last active August 29, 2015 14:03
Show Gist options
  • Save pinzolo/54cf22c9d50c6547becc to your computer and use it in GitHub Desktop.
Save pinzolo/54cf22c9d50c6547becc to your computer and use it in GitHub Desktop.
.pryrc
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