<commit_before>require 'json'
require 'cgi'
require 'net/http' # also requires uri

class Fastly
  # The UserAgent to communicate with the API
  class Client #:nodoc: all
    ROOT_CA = File.join("../../cacert.pem", __FILE__)
    attr_accessor :http, :api_key, :user, :password, :cookie, :customer

    def initialize(opts)
      @api_key  = opts.fetch(:api_key, nil)
      @user     = opts.fetch(:user, nil)
      @password = opts.fetch(:password, nil)
      @customer = opts.fetch(:customer, nil)

      certificate_store = opts.fetch(:certificate_store, ROOT_CA)

      base      = opts.fetch(:base_url, 'https://api.fastly.com')
      uri       = URI.parse(base)
      ssl       = uri.is_a? URI::HTTPS  # detect if we should pass `use_ssl`
      @http     = Net::HTTP.start(uri.host, uri.port, use_ssl: ssl)

      http.ca_path      = certificate_store
      http.verify_mode  = OpenSSL::SSL::VERIFY_PEER
      http.verify_depth = 5

      return self unless fully_authed?<commit_msg>rely on Net::HTTP default ca_path<commit_after>require 'json'
require 'cgi'
require 'net/http' # also requires uri

class Fastly
  # The UserAgent to communicate with the API
  class Client #:nodoc: all
    attr_accessor :http, :api_key, :user, :password, :cookie, :customer

    def initialize(opts)
      @api_key  = opts.fetch(:api_key, nil)
      @user     = opts.fetch(:user, nil)
      @password = opts.fetch(:password, <PASSWORD>)
      @customer = opts.fetch(:customer, nil)

      base      = opts.fetch(:base_url, 'https://api.fastly.com')
      uri       = URI.parse(base)
      ssl       = uri.is_a? URI::HTTPS  # detect if we should pass `use_ssl`
      @http     = Net::HTTP.start(uri.host, uri.port, use_ssl: ssl)

      http.verify_mode  = OpenSSL::SSL::VERIFY_PEER
      http.verify_depth = 5

      return self unless fully_authed?
{'fraction_non_alphanumeric': 0.12527233115468409, 'fraction_numerical': 0.0010893246187363835, 'mean_word_length': 2.925213675213675, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4360947', 'n_tokens_mistral': 621, 'n_tokens_neox': 604, 'n_words': 151}