<commit_before>module Samuel
  class NetHttpLogEntry < LogEntry

    def host
      @http.address
    end

    def path
      @request.path.split("?")[0]
    end

    def query
      @request.path.split("?")[1]
    end

    def scheme
      @http.use_ssl? ? "https" : "http"
    end

    def port
      @http.port
    end

    def method
      @request.method.to_s.upcase
    end

    def status_code
      @response.code
    end

    def status_message
      @response.message.strip
    end

    def error?
      error_classes = [Exception, Net::HTTPClientError, Net::HTTPServerError]
      error_classes.any? { |c| @response.is_a?(c) }
    end

  end
end<commit_msg>Check classes using strings, so this file can be safely required when Net::HTTP isn't loaded<commit_after>module Samuel
  class NetHttpLogEntry < LogEntry

    def host
      @http.address
    end

    def path
      @request.path.split("?")[0]
    end

    def query
      @request.path.split("?")[1]
    end

    def scheme
      @http.use_ssl? ? "https" : "http"
    end

    def port
      @http.port
    end

    def method
      @request.method.to_s.upcase
    end

    def status_code
      @response.code
    end

    def status_message
      @response.message.strip
    end

    def error?
      error_classes = %w(Exception Net::HTTPClientError Net::HTTPServerError)
      response_ancestors = @response.class.ancestors.map { |a| a.to_s }
      (error_classes & response_ancestors).any?
    end

  end
end
{'fraction_non_alphanumeric': 0.09507754551584625, 'fraction_numerical': 0.0026972353337828725, 'mean_word_length': 2.205183585313175, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5311924', 'n_tokens_mistral': 497, 'n_tokens_neox': 478, 'n_words': 118}