return unless Rails.application.server? || Rails.application.console? def grant(patch) case patch when 'action_dispatch/middleware/debug_exceptions.rb' then Rails.application.server? when 'rails_live_reload/watcher.rb' then Rails.application.server? && Rails.env.development? when /^semantic/ then true end end puts 'MonkeyPatcher runs:' patches = Dir.glob(Rails.root.join('lib', 'monkey_patches', '**', '*.rb')) patches.each do |file| patch = Pathname.new(file).relative_path_from(Rails.root.join('lib', 'monkey_patches')).to_s next unless grant patch puts "🐵 patching... #{patch}" require file end