Sha256: 3240a917469053854ffa1b962a41151391c78f255533e930862d401c141b1fcc
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module PryMoves::Restartable attr_accessor :restart_requested, :reload_requested, :reload_ruby_scripts, :reloader, :reload_rake_tasks def restartable context trigger :each_new_run, context context[:retry] ||= 0 yield context re_execution rescue PryMoves::Restart puts "🔄️ Restarting execution" self.restart_requested = false PryMoves.reset PryMoves.reloader&.reload trigger :restart, context context[:retry] += 1 retry rescue PryMoves::Reload puts "🔮 try to use @ with reload" exit 3 end def re_execution raise PryMoves::Restart if restart_requested raise PryMoves::Reload if reload_requested end end class PryMoves::Restart < RuntimeError end class PryMoves::Reload < RuntimeError end RSpec::Support::AllExceptionsExceptOnesWeMustNotRescue::AVOID_RESCUING.concat [PryMoves::Restart, PryMoves::Reload] if defined? RSpec Pry.config.hooks.add_hook(:after_eval, :exit_on_re_execution) do |_, _, _pry_| if PryMoves.restart_requested or PryMoves.reload_requested Pry.run_command 'exit-all' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pry-moves-1.0.3 | lib/pry-moves/restartable.rb |