def binary?(relative_path)
      bytes = ::File.new(relative_path).size
      bytes = 2**12 if bytes > 2**12
      buffer = ::File.read(relative_path, bytes, 0) || ''
      buffer = buffer.force_encoding(Encoding.default_external)
      begin
        return buffer !~ /\A[\s[[:print:]]]*\z/m
      rescue ArgumentError => error
        return true if error.message =~ /invalid byte sequence/
        raise
      end
    end
def binary?(relative_path)
      bytes = ::File.new(relative_path).size
      bytes = 2**12 if bytes > 2**12
      buffer = ::File.read(relative_path, bytes, 0) || ''
      buffer = buffer.force_encoding(Encoding.default_external)
      begin
        return buffer !~ /\A[\s[[:print:]]]*\z/m
      rescue ArgumentError => error
        return true if error.message =~ /invalid byte sequence/
        raise
      end
    end
Check if file is binary

 @param [String, Pathname] relative_path
   the path to file to check

 @example
   binary?('Gemfile') # => false

 @example
   binary?('image.jpg') # => true

 @return [Boolean]
   Returns `true` if the file is binary, `false` otherwise

 @api public