<commit_before>module Faraday
  class Response::Parse < Response::Middleware
    begin
      require 'multi_json'
      require 'multi_xml'
    rescue LoadError, NameError => error
      self.load_error = error
    end

    def self.register_on_complete(env)
      env[:response].on_complete do |response|
        response[:body] = begin
          case response[:response_headers]['content-type']
          when /application\/json/
            parse_json(response[:body])
          when /application\/xml/
            parse_xml(response[:body])
          else
            ''
          end
        end
      end
    end

    def initialize(app)
      super
      @parser = nil
    end

    private

    def parse_json(response_body)
      case response_body
      when ''
        nil
      when 'true'
        true
      when 'false'
        false
      else
        ::MultiJson.decode(response[:body])
      end
    end

    def parse_xml
      ::MultiXml.parse(response_body)
    end
  end
end<commit_msg>Cleanup<commit_after>module Faraday
  class Response::Parse < Response::Middleware
    begin
      require 'multi_json'
      require 'multi_xml'
    rescue LoadError, NameError => error
      self.load_error = error
    end

    def self.register_on_complete(env)
      env[:response].on_complete do |response|
        response[:body] = begin
          case response[:response_headers]['content-type']
          when /application\/json/
            parse_json(response[:body])
          when /application\/xml/
            parse_xml(response[:body])
          else
            ''
          end
        end
      end
    end

    def initialize(app)
      super
      @parser = nil
    end

    private

    def self.parse_json(response_body)
      case response_body
      when ''
        nil
      when 'true'
        true
      when 'false'
        false
      else
        ::MultiJson.decode(response_body)
      end
    end

    def self.parse_xml(response_body)
      ::MultiXml.parse(response_body)
    end
  end
end
{'fraction_non_alphanumeric': 0.0823065549531789, 'fraction_numerical': 0.0, 'mean_word_length': 1.8, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5069949', 'n_tokens_mistral': 571, 'n_tokens_neox': 562, 'n_words': 131}