<commit_before># frozen_string_literal: true

module Mako
  class FeedRequester
    attr_reader :feed_url
    attr_accessor :ok, :body, :headers

    def initialize(args)
      @ok = true
      @body = ''
      @headers = {}
      @feed_url = args.fetch(:feed_url)
    end

    # Performs HTTP request on the given feed_url. Sets the Mako::FeedRequester
    # body attribute equal to the request body if successful and returns self.
    # If the request fails, @ok is set to false.
    #
    # @return [Mako::FeedRequester]
    def fetch
      begin
        request = HTTParty.get(feed_url)
      rescue SocketError
        Mako.errors.add_error "Could not complete request to #{feed_url}."
        self.ok = false
        return self
      end
      unless request.code == 200
        Mako.errors.add_error "Request to #{feed_url} returned #{request.code}."<commit_msg>Catch HTTParty::RedirectionTooDeep exception<commit_after># frozen_string_literal: true

module Mako
  class FeedRequester
    attr_reader :feed_url
    attr_accessor :ok, :body, :headers

    def initialize(args)
      @ok = true
      @body = ''
      @headers = {}
      @feed_url = args.fetch(:feed_url)
    end

    # Performs HTTP request on the given feed_url. Sets the Mako::FeedRequester
    # body attribute equal to the request body if successful and returns self.
    # If the request fails, @ok is set to false.
    #
    # @return [Mako::FeedRequester]
    def fetch
      begin
        request = HTTParty.get(feed_url)
      rescue SocketError, HTTParty::RedirectionTooDeep
        Mako.errors.add_error "Could not complete request to #{feed_url}."
        self.ok = false
        return self
      end
      unless request.code == 200
        Mako.errors.add_error "Request to #{feed_url} returned #{request.code}."
{'fraction_non_alphanumeric': 0.08606329816768463, 'fraction_numerical': 0.003331482509716824, 'mean_word_length': 2.6775510204081634, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5869877', 'n_tokens_mistral': 548, 'n_tokens_neox': 543, 'n_words': 168}