def load_plugins(base_dir = nil, search_parents = true)
    base_dir = base_dir.nil? ? Dir.pwd : base_dir

    search_plugins = lambda do |search_dir|
      lib_dir = File.join(search_dir, 'lib')

      if File.directory?(lib_dir)
        logger.debug("Registering plugins at #{lib_dir}")
        register(lib_dir)
      end

      if search_parents
        parent_search_dir = search_dir.sub(/#{File::SEPARATOR}[^#{File::SEPARATOR}]+$/, '')
        search_plugins.call(parent_search_dir) unless parent_search_dir.split(File::SEPARATOR).empty?
      end
    end

    search_plugins.call(base_dir)
  end
def load_plugins(base_dir = nil, search_parents = true)
    base_dir = base_dir.nil? ? Dir.pwd : base_dir

    search_plugins = lambda do |search_dir|
      lib_dir = File.join(search_dir, 'lib')

      if File.directory?(lib_dir)
        logger.debug("Registering plugins at #{lib_dir}")
        register(lib_dir)
      end

      if search_parents
        parent_search_dir = search_dir.sub(/#{File::SEPARATOR}[^#{File::SEPARATOR}]+$/, '')
        search_plugins.call(parent_search_dir) unless parent_search_dir.split(File::SEPARATOR).empty?
      end
    end

    search_plugins.call(base_dir)
  end
---