Skip to content

Instantly share code, notes, and snippets.

@mamantoha
Created November 13, 2018 07:56
Show Gist options
  • Save mamantoha/b5f06b1240ed9ef7b1904671f1b0bf6d to your computer and use it in GitHub Desktop.
Save mamantoha/b5f06b1240ed9ef7b1904671f1b0bf6d to your computer and use it in GitHub Desktop.
Pry everywhere
# config/initializers/pry_everywhere.rb
require 'sidekiq'
# Perform Sidekiq jobs immediately in development,
# so you don't have to run a separate process.
# You'll also benefit from code reloading.
if Rails.env.development? && ENV['SIDEKIQ_INLINE'].present?
require 'sidekiq/testing'
Sidekiq::Testing.inline!
end
# Use pry even if it not defined in Gemfile
if defined?(::Bundler)
global_gemset = `rbenv exec gem environment | grep '\\- INSTALLATION' | cut -d : -f 2 | xargs`.chomp
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
if gem_path =~ /(pry|method_source|coderay|slop|pry-rails)-\d+\.\d+\.\d+/
$LOAD_PATH << gem_path
end
end
end
end
require 'pry'
require 'pry-rails'
if defined?(Rails) && Rails.env
if defined?(Rails::ConsoleMethods)
include Rails::ConsoleMethods
else
def reload!(print=true)
puts "Reloading..." if print
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment