<commit_before>module Scorer
  class Client

    class NoToken < StandardError; end

    class << self

      attr_writer :token, :ssl_enabled
      attr_reader :api_host, :api_projects_path

      def get(path)
        begin
          set_response_headers(connection["#{api_version}#{path}"].get)
        rescue
          puts "Encountered Error in get: #{$!}"
          clear_connections
          set_response_headers(connection["#{api_version}#{path}"].get)
        end
      end

      def get_with_caching(path)
        begin
          connection["#{api_version}#{path}"].get
        rescue
          puts "Encountered Error in get_with_caching: #{$!}"
          clear_connections
          connection["#{api_version}#{path}"].get
        end
      end

      def put(path, updates={})
        set_response_headers(connection["#{api_version}#{path}"].put(updates))
      end

      def connection
        raise NoToken if @token.to_s.empty?
        @connections ||= {}
        cached_connection? ? cached_connection : new_connection
      end

      def clear_connections
        @connections = nil
      end

      def ssl_enabled
        @ssl_enabled || true
      end

      def token(username, password)
        response = RestClient.get("#{api_ssl_host(username, password)}#{api_version}/me")
        json = JSON.parse(response, {:symbolize_names => true})
        @token = json[:api_token]
      end

      def api_ssl_host(user=nil, password=nil)
        user_password = (user && password) ? "#{user}:#{password}@" : ''
        "https://#{user_password}www.pivotaltracker.com"
      end<commit_msg>Escaping passwords incase they contain special chars like a question mark.<commit_after>module Scorer
  class Client

    class NoToken < StandardError; end

    class << self

      attr_writer :token, :ssl_enabled
      attr_reader :api_host, :api_projects_path

      def get(path)
        begin
          set_response_headers(connection["#{api_version}#{path}"].get)
        rescue
          puts "Encountered Error in get: #{$!}"
          clear_connections
          set_response_headers(connection["#{api_version}#{path}"].get)
        end
      end

      def get_with_caching(path)
        begin
          connection["#{api_version}#{path}"].get
        rescue
          puts "Encountered Error in get_with_caching: #{$!}"
          clear_connections
          connection["#{api_version}#{path}"].get
        end
      end

      def put(path, updates={})
        set_response_headers(connection["#{api_version}#{path}"].put(updates))
      end

      def connection
        raise NoToken if @token.to_s.empty?
        @connections ||= {}
        cached_connection? ? cached_connection : new_connection
      end

      def clear_connections
        @connections = nil
      end

      def ssl_enabled
        @ssl_enabled || true
      end

      def token(username, password)
        response = RestClient.get("#{api_ssl_host(username, password)}#{api_version}/me")
        json = JSON.parse(response, {:symbolize_names => true})
        @token = json[:api_token]
      end

      def api_ssl_host(user=nil, password=nil)
        user_password = (user && password) ? "#{user}:#{CGI.escape(password)}@" : ''
        "https://#{user_password}www.pivotaltracker.com"
      end
{'fraction_non_alphanumeric': 0.11532625189681335, 'fraction_numerical': 0.0, 'mean_word_length': 2.4658254468980023, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1862792', 'n_tokens_mistral': 975, 'n_tokens_neox': 969, 'n_words': 193}