<commit_before>require 'rest_client'
require 'json'
require 'set'
require 'cgi'

require File.expand_path('../version', __FILE__) unless defined?(RightApi::Client::VERSION)
require File.expand_path('../helper', __FILE__)
require File.expand_path('../resource', __FILE__)
require File.expand_path('../resource_detail', __FILE__)
require File.expand_path('../resources', __FILE__)
require File.expand_path('../exceptions', __FILE__)

# RightApiClient has the generic get/post/delete/put calls that are used by resources
module RightApi
  class Client
    include Helper

    ROOT_RESOURCE = '/api/session'
    ROOT_INSTANCE_RESOURCE = '/api/session/instance'
    DEFAULT_API_URL = 'https://my.rightscale.com'

    # permitted parameters for initializing
    AUTH_PARAMS = %w(email password account_id api_url api_version cookies instance_token)
    attr_reader :cookies, :instance_token

    def initialize(args)
      @api_url, @api_version = DEFAULT_API_URL, API_VERSION
      # Initializing all instance variables from hash
      args.each { |key,value|
        instance_variable_set("@#{key}", value) if value && AUTH_PARAMS.include?(key.to_s)
      } if args.is_a? Hash

      raise 'This API client is only compatible with the RightScale API 1.5 and upwards.' if (Float(@api_version) < 1.5)
      @rest_client = RestClient::Resource.new(@api_url, :timeout => -1)

      # There are three options for login: credentials, instance token, or if the user already
      # has the cookies they can just use those. See config/login.yml.example for more info.<commit_msg>Enforce Ruby 1.9 interpreter to avoid weirdness<commit_after>require 'rest_client'
require 'json'
require 'set'
require 'cgi'

require File.expand_path('../version', __FILE__) unless defined?(RightApi::Client::VERSION)
require File.expand_path('../helper', __FILE__)
require File.expand_path('../resource', __FILE__)
require File.expand_path('../resource_detail', __FILE__)
require File.expand_path('../resources', __FILE__)
require File.expand_path('../exceptions', __FILE__)

# RightApiClient has the generic get/post/delete/put calls that are used by resources
module RightApi
  class Client
    include Helper

    ROOT_RESOURCE = '/api/session'
    ROOT_INSTANCE_RESOURCE = '/api/session/instance'
    DEFAULT_API_URL = 'https://my.rightscale.com'

    # permitted parameters for initializing
    AUTH_PARAMS = %w(email password account_id api_url api_version cookies instance_token)
    attr_reader :cookies, :instance_token

    def initialize(args)
      raise 'This API client is only compatible with Ruby 1.9 and upwards.' if (RUBY_VERSION < '1.9')
      @api_url, @api_version = DEFAULT_API_URL, API_VERSION
      # Initializing all instance variables from hash
      args.each { |key,value|
        instance_variable_set("@#{key}", value) if value && AUTH_PARAMS.include?(key.to_s)
      } if args.is_a? Hash

      raise 'This API client is only compatible with the RightScale API 1.5 and upwards.' if (Float(@api_version) < 1.5)
      @rest_client = RestClient::Resource.new(@api_url, :timeout => -1)

      # There are three options for login: credentials, instance token, or if the user already
      # has the cookies they can just use those. See config/login.yml.example for more info.
{'fraction_non_alphanumeric': 0.10672782874617737, 'fraction_numerical': 0.004892966360856269, 'mean_word_length': 4.200317965023848, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, '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': '7196208', 'n_tokens_mistral': 963, 'n_tokens_neox': 941, 'n_words': 292}