<commit_before># -*- encoding: utf-8 -*-

require 'faraday_middleware'
require 'active_support'

module PMP
  module Connection

    ALLOWED_CONNECTION_OPTIONS = [
      :headers,
      :url,
      :params,
      :request,
      :adapter,
      :ssl,
      :oauth_token,
      :debug
    ].freeze

    def connection(options={})
      opts = process_options(options)
      Faraday::Connection.new(opts) do |faraday|
        faraday.request :authorization, 'Bearer', opts[:oauth_token] unless opts[:oauth_token].nil?
        faraday.request :url_encoded

        faraday.response :mashify
        faraday.response :logger if opts[:debug]
        faraday.response :json

        faraday.adapter opts[:adapter]
      end
    end

    def process_options(opts={})
      headers = opts.delete(:headers) || {}
      options = {
        :headers => {
          # generic http headers
          'User-Agent'   => opts[:user_agent],
          'Accept'       => "application/vnd.pmp.collection.doc+json",
          'Content-Type' => "application/vnd.pmp.collection.doc+json"<commit_msg>prepping for uploads work<commit_after># -*- encoding: utf-8 -*-

require 'faraday_middleware'
require 'active_support'

module PMP
  module Connection

    ALLOWED_CONNECTION_OPTIONS = [
      :headers,
      :url,
      :params,
      :request,
      :adapter,
      :ssl,
      :oauth_token,
      :debug
    ].freeze

    def connection(options={})
      opts = process_options(options)
      Faraday::Connection.new(opts) do |faraday|
        faraday.request :authorization, 'Bearer', opts[:oauth_token] unless opts[:oauth_token].nil?
        faraday.request :url_encoded
        faraday.request :multipart

        faraday.response :mashify
        faraday.response :logger if opts[:debug]
        faraday.response :json

        faraday.adapter opts[:adapter]
      end
    end

    def process_options(opts={})
      headers = opts.delete(:headers) || {}
      options = {
        :headers => {
          # generic http headers
          'User-Agent'   => opts[:user_agent],
          'Accept'       => "application/vnd.pmp.collection.doc+json",
          'Content-Type' => "application/vnd.pmp.collection.doc+json"
{'fraction_non_alphanumeric': 0.12187357889949978, 'fraction_numerical': 0.0009095043201455207, 'mean_word_length': 2.421461897356143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5247696', 'n_tokens_mistral': 692, 'n_tokens_neox': 656, 'n_words': 130}