def diff(path_a, path_b, **options)
      threshold = options[:threshold] || 10_000_000
      output = []

      open_tempfile_if_missing(path_a) do |file_a|
        if ::File.size(file_a) > threshold
          raise ArgumentError, "(file size of #{file_a.path} exceeds #{threshold} bytes, diff output suppressed)"
        end
        if binary?(file_a)
          raise ArgumentError, "(#{file_a.path} is binary, diff output suppressed)"
        end
        open_tempfile_if_missing(path_b) do |file_b|
          if binary?(file_b)
            raise ArgumentError, "(#{file_a.path} is binary, diff output suppressed)"
          end
          if ::File.size(file_b) > threshold
            return "(file size of #{file_b.path} exceeds #{threshold} bytes, diff output suppressed)"
          end

          log_status(:diff, "#{file_a.path} - #{file_b.path}",
                     options.fetch(:verbose, true), options.fetch(:color, :green))
          return output.join if options[:noop]

          block_size = file_a.lstat.blksize
          while !file_a.eof? && !file_b.eof?
            output << Differ.new(file_a.read(block_size),
                                 file_b.read(block_size),
                                 options).call
          end
        end
      end
      output.join
    end
def diff(path_a, path_b, **options)
      threshold = options[:threshold] || 10_000_000
      output = []

      open_tempfile_if_missing(path_a) do |file_a|
        if ::File.size(file_a) > threshold
          raise ArgumentError, "(file size of #{file_a.path} exceeds #{threshold} bytes, diff output suppressed)"
        end
        if binary?(file_a)
          raise ArgumentError, "(#{file_a.path} is binary, diff output suppressed)"
        end
        open_tempfile_if_missing(path_b) do |file_b|
          if binary?(file_b)
            raise ArgumentError, "(#{file_a.path} is binary, diff output suppressed)"
          end
          if ::File.size(file_b) > threshold
            return "(file size of #{file_b.path} exceeds #{threshold} bytes, diff output suppressed)"
          end

          log_status(:diff, "#{file_a.path} - #{file_b.path}",
                     options.fetch(:verbose, true), options.fetch(:color, :green))
          return output.join if options[:noop]

          block_size = file_a.lstat.blksize
          while !file_a.eof? && !file_b.eof?
            output << Differ.new(file_a.read(block_size),
                                 file_b.read(block_size),
                                 options).call
          end
        end
      end
      output.join
    end
Diff files line by line

 @param [String, Pathname] path_a
 @param [String, Pathname] path_b
 @param [Hash[Symbol]] options
 @option options [Symbol] :format
   the diffining output format
 @option options [Symbol] :context_lines
   the number of extra lines for the context
 @option options [Symbol] :threshold
   maximum file size in bytes

 @example
   diff(file_a, file_b, format: :old)

 @api public