Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More elegant solution to loading pry-rescue via pryrc? #111

Open
gerrywastaken opened this issue Sep 28, 2018 · 0 comments
Open

More elegant solution to loading pry-rescue via pryrc? #111

gerrywastaken opened this issue Sep 28, 2018 · 0 comments

Comments

@gerrywastaken
Copy link

Hi, I want pry rescue to always work no matter how pry is loaded. It would be great if I could just do something in my pryrc to activate pry rescue at runtime. The following code works but it's not very elegant. Is there a better way?

begin
  require 'pry-rescue'

  Pry.config.hooks.add_hook(:before_eval, :save_me) do |code, _pry|
    code.replace("Pry::rescue do\n\n#{code}\n\nend")
  end
rescue LoadError => err
  puts "no pry-rescue :("
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant