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.

17 lines
495 B

  1. class MonkeyPatcher
  2. class << self
  3. MONKEY_PATCHES = Rails.root.join('lib', 'monkey_patches')
  4. def run(&)
  5. patches = Dir.glob(MONKEY_PATCHES.join('**', '*.rb'))
  6. patches.each do |patch|
  7. file = Pathname.new(patch).relative_path_from(MONKEY_PATCHES).to_s
  8. next if file == 'monkey_patcher.rb' # filter off its own file!
  9. if !block_given? || yield(file)
  10. puts "🐵 patching... #{file}"
  11. require file
  12. end
  13. end
  14. end
  15. end
  16. end