You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
624 B

  1. return unless Rails.application.server? || Rails.application.console?
  2. def grant(patch)
  3. case patch
  4. when 'action_dispatch/middleware/debug_exceptions.rb' then Rails.application.server?
  5. when 'rails_live_reload/watcher.rb' then Rails.application.server? && Rails.env.development?
  6. when /^semantic/ then true
  7. end
  8. end
  9. puts 'MonkeyPatcher runs:'
  10. patches = Dir.glob(Rails.root.join('lib', 'monkey_patches', '**', '*.rb'))
  11. patches.each do |file|
  12. patch = Pathname.new(file).relative_path_from(Rails.root.join('lib', 'monkey_patches')).to_s
  13. next unless grant patch
  14. puts "🐵 patching... #{patch}"
  15. require file
  16. end