<commit_before># -*- encoding : utf-8 -*-
require 'parse/protocol'
require 'parse/error'
require 'parse/util'

require 'logger'
module Parse

  # A class which encapsulates the HTTPS communication with the Parse
  # API server.
  class Client
    attr_accessor :host
    attr_accessor :application_id
    attr_accessor :api_key
    attr_accessor :master_key
    attr_accessor :session_token
    attr_accessor :session
    attr_accessor :max_retries
    attr_accessor :logger
    attr_accessor :quiet

    def initialize(data = {}, &blk)
      @host           = data[:host] || Protocol::HOST
      @application_id = data[:application_id]
      @api_key        = data[:api_key]
      @master_key     = data[:master_key]
      @session_token  = data[:session_token]
      @max_retries    = data[:max_retries] || 3
      @logger         = data[:logger] || Logger.new(STDERR).tap{|l| l.level = Logger::INFO}
      @quiet          = data[:quiet] || false

      options = {:request => {:timeout => 30, :open_timeout => 30}}

      @session = Faraday.new("https://#{host}", options) do |c|
        c.request :json

        c.use Faraday::GetMethodOverride

        c.use Faraday::BetterRetry,
          max: @max_retries,
          logger: @logger unless @quiet,
          interval: 0.5,
          exceptions: ['Faraday::Error::TimeoutError', 'Faraday::Error::ParsingError', 'Parse::ParseProtocolRetry']
        c.use Faraday::ExtendedParseJson

        c.response :logger, @logger unless @quiet
        c.adapter Faraday.default_adapter

        yield(c) if block_given?
      end
    end

    # Perform an HTTP request for the given uri and method
    # with common basic response handling. Will raise a
    # ParseProtocolError if the response has an error status code,<commit_msg>oops fixed syntax<commit_after># -*- encoding : utf-8 -*-
require 'parse/protocol'
require 'parse/error'
require 'parse/util'

require 'logger'
module Parse

  # A class which encapsulates the HTTPS communication with the Parse
  # API server.
  class Client
    attr_accessor :host
    attr_accessor :application_id
    attr_accessor :api_key
    attr_accessor :master_key
    attr_accessor :session_token
    attr_accessor :session
    attr_accessor :max_retries
    attr_accessor :logger
    attr_accessor :quiet

    def initialize(data = {}, &blk)
      @host           = data[:host] || Protocol::HOST
      @application_id = data[:application_id]
      @api_key        = data[:api_key]
      @master_key     = data[:master_key]
      @session_token  = data[:session_token]
      @max_retries    = data[:max_retries] || 3
      @logger         = data[:logger] || Logger.new(STDERR).tap{|l| l.level = Logger::INFO}
      @quiet          = data[:quiet] || false

      options = {:request => {:timeout => 30, :open_timeout => 30}}

      @session = Faraday.new("https://#{host}", options) do |c|
        c.request :json

        c.use Faraday::GetMethodOverride

        c.use Faraday::BetterRetry,
          max: @max_retries,
          logger: @logger
          interval: 0.5,
          exceptions: ['Faraday::Error::TimeoutError', 'Faraday::Error::ParsingError', 'Parse::ParseProtocolRetry']
        c.use Faraday::ExtendedParseJson

        c.response :logger, @logger unless @quiet
        c.adapter Faraday.default_adapter

        yield(c) if block_given?
      end
    end

    # Perform an HTTP request for the given uri and method
    # with common basic response handling. Will raise a
    # ParseProtocolError if the response has an error status code,
{'fraction_non_alphanumeric': 0.10838272650296359, 'fraction_numerical': 0.004515946937623483, 'mean_word_length': 2.7903743315508023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '6771997', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1035, 'n_words': 279}