<commit_before>require 'net/https'
require 'json'
require 'net/http/post/multipart'

module Databasedotcom
  # Interface for operating the Force.com REST API
  class Client
    # The client id (aka "Consumer Key") to use for OAuth2 authentication
    attr_accessor :client_id
    # The client secret (aka "Consumer Secret" to use for OAuth2 authentication)
    attr_accessor :client_secret
    # The OAuth access token in use by the client
    attr_accessor :oauth_token
    # The OAuth refresh token in use by the client
    attr_accessor :refresh_token
    # The base URL to the authenticated user's SalesForce instance
    attr_accessor :instance_url
    # If true, print API debugging information to stdout. Defaults to false.
    attr_accessor :debugging
    # The host to use for OAuth2 authentication. Defaults to +login.salesforce.com+
    attr_accessor :host
    # The API version the client is using. Defaults to 23.0
    attr_accessor :version
    # A Module in which to materialize Sobject classes. Defaults to the global module (Object)
    attr_accessor :sobject_module
    # The SalesForce user id of the authenticated user
    attr_reader :user_id
    # The SalesForce username
    attr_accessor :username
    # The SalesForce password
    attr_accessor :password
    # The SalesForce organization id for the authenticated user's Salesforce instance
    attr_reader :org_id
    # The CA file configured for this instance, if any
    attr_accessor :ca_file
    # The SSL verify mode configured for this instance, if any
    attr_accessor :verify_mode

    # Returns a new client object. _options_ can be one of the following
    #
    # * A String containing the name of a YAML file formatted like:
    #    ---
    #    client_id: <your_salesforce_client_id>
    #    client_secret: <your_salesforce_client_secret>
    #    host: login.salesforce.com
    #    debugging: true
    #    version: 23.0
    #    sobject_module: My::Module
    #    ca_file: some/ca/file.cert
    #    verify_mode: 
    # * A Hash containing the following keys:
    #    client_id
    #    client_secret
    #    host
    #    debugging
    #    version
    #    sobject_module
    # If the environment variables DATABASEDOTCOM_CLIENT_ID, DATABASEDOTCOM_CLIENT_SECRET, DATABASEDOTCOM_HOST,
    # DATABASEDOTCOM_DEBUGGING, DATABASEDOTCOM_VERSION, and/or DATABASEDOTCOM_SOBJECT_MODULE are present, they
    # override any other values provided
    def initialize(options = {})
      if options.is_a?(String)
        @options = YAML.load_file(options)
        @options["verify_mode"] = @options["verify_mode"].constantize if @options["verify_mode"] && @options["verify_mode"].is_a?(String)
      else
        @options = options
      end
      @options.symbolize_keys!

      if ENV['DATABASE_COM_URL']
        url = URI.parse(ENV['DATABASE_COM_URL'])
        url_options = Hash[url.query.split("&").map{|q| q.split("=")}].symbolize_keys!
        self.host = url.host
        self.client_id = url_options[:oauth_key]
        self.client_secret = url_options[:oauth_secret]
        self.username = url_options[:user]
        self.password = url_options[:password]
      else
        self.client_id = ENV['DATABASEDOTCOM_CLIENT_ID'] || @options[:client_id]
        self.client_secret = ENV['DATABASEDOTCOM_CLIENT_SECRET'] || @options[:client_secret]
        self.host = ENV['DATABASEDOTCOM_HOST'] || @options[:host] || "login.salesforce.com"
      end
      <commit_msg>clarify ca_file and verify_mode configuration parameters<commit_after>require 'net/https'
require 'json'
require 'net/http/post/multipart'

module Databasedotcom
  # Interface for operating the Force.com REST API
  class Client
    # The client id (aka "Consumer Key") to use for OAuth2 authentication
    attr_accessor :client_id
    # The client secret (aka "Consumer Secret" to use for OAuth2 authentication)
    attr_accessor :client_secret
    # The OAuth access token in use by the client
    attr_accessor :oauth_token
    # The OAuth refresh token in use by the client
    attr_accessor :refresh_token
    # The base URL to the authenticated user's SalesForce instance
    attr_accessor :instance_url
    # If true, print API debugging information to stdout. Defaults to false.
    attr_accessor :debugging
    # The host to use for OAuth2 authentication. Defaults to +login.salesforce.com+
    attr_accessor :host
    # The API version the client is using. Defaults to 23.0
    attr_accessor :version
    # A Module in which to materialize Sobject classes. Defaults to the global module (Object)
    attr_accessor :sobject_module
    # The SalesForce user id of the authenticated user
    attr_reader :user_id
    # The SalesForce username
    attr_accessor :username
    # The SalesForce password
    attr_accessor :password
    # The SalesForce organization id for the authenticated user's Salesforce instance
    attr_reader :org_id
    # The CA file configured for this instance, if any
    attr_accessor :ca_file
    # The SSL verify mode configured for this instance, if any
    attr_accessor :verify_mode

    # Returns a new client object. _options_ can be one of the following
    #
    # * A String containing the name of a YAML file formatted like:
    #    ---
    #    client_id: <your_salesforce_client_id>
    #    client_secret: <your_salesforce_client_secret>
    #    host: login.salesforce.com
    #    debugging: true
    #    version: 23.0
    #    sobject_module: My::Module
    #    ca_file: some/ca/file.cert
    #    verify_mode: OpenSSL::SSL::VERIFY_PEER
    # * A Hash containing the following keys:
    #    client_id
    #    client_secret
    #    host
    #    debugging
    #    version
    #    sobject_module
    #    ca_file
    #    verify_mode
    # If the environment variables DATABASEDOTCOM_CLIENT_ID, DATABASEDOTCOM_CLIENT_SECRET, DATABASEDOTCOM_HOST,
    # DATABASEDOTCOM_DEBUGGING, DATABASEDOTCOM_VERSION, DATABASEDOTCOM_SOBJECT_MODULE, DATABASEDOTCOM_CA_FILE, and/or 
    # DATABASEDOTCOM_VERIFY_MODE are present, they override any other values provided
    def initialize(options = {})
      if options.is_a?(String)
        @options = YAML.load_file(options)
        @options["verify_mode"] = @options["verify_mode"].constantize if @options["verify_mode"] && @options["verify_mode"].is_a?(String)
      else
        @options = options
      end
      @options.symbolize_keys!

      if ENV['DATABASE_COM_URL']
        url = URI.parse(ENV['DATABASE_COM_URL'])
        url_options = Hash[url.query.split("&").map{|q| q.split("=")}].symbolize_keys!
        self.host = url.host
        self.client_id = url_options[:oauth_key]
        self.client_secret = url_options[:oauth_secret]
        self.username = url_options[:user]
        self.password = <PASSWORD>_options[:password]
      else
        self.client_id = ENV['DATABASEDOTCOM_CLIENT_ID'] || @options[:client_id]
        self.client_secret = ENV['DATABASEDOTCOM_CLIENT_SECRET'] || @options[:client_secret]
        self.host = ENV['DATABASEDOTCOM_HOST'] || @options[:host] || "login.salesforce.com"
      end
      
{'fraction_non_alphanumeric': 0.07876905702992659, 'fraction_numerical': 0.002540937323546019, 'mean_word_length': 3.239976062238181, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '6618196', 'n_tokens_mistral': 2188, 'n_tokens_neox': 2161, 'n_words': 606}