<commit_before>require 'errors'
require 'json'
require 'faraday/request/oauth'
require 'faraday/response/parse_json'

module InstapaperFull
  class API
    attr_accessor :options
    def initialize(options = {})
      @options = options
    end

    def connection(options = {})
      options.merge!({
        :proxy => @options[:proxy],
        :ssl => {:verify => false},
        :url => "https://www.instapaper.com/api/1/"
      })

      oauth_params = {
        :consumer_key => @options[:consumer_key],
        :consumer_secret => @options[:consumer_secret]
      }

      if authenticated?
        oauth_params[:token] = @options[:oauth_token]
        oauth_params[:token_secret] = @options[:oauth_token_secret]
      end

      Faraday.new(options) do |builder|
        builder.use Faraday::Request::OAuth, oauth_params
        builder.use Faraday::Request::UrlEncoded
        builder.adapter Faraday.default_adapter
      end
    end

    def authenticated?
      @options.has_key? :oauth_token and @options.has_key? :oauth_token_secret
    end

    def authenticate(username, password)
      @options.delete(:oauth_token)
      @options.delete(:oauth_token_secret)
      result = connection.post 'oauth/access_token' do |r|
        r.body = { :x_auth_username => username, :x_auth_password => password, :x_auth_mode => "client_auth" }
      end
      if result.status == 200
        data = CGI.parse(result.body)
        if data.has_key? 'oauth_token_secret'
          @options[:oauth_token] = data['oauth_token'][0]
          @options[:oauth_token_secret] = data['oauth_token_secret'][0]
          verify_credentials.each { |k,v|
            @options[k.to_sym] = v if k != 'type'
          }
        end
        return true
      else
        return false
      end<commit_msg>Does this fix the bytesize bug?<commit_after>require 'errors'
require 'json'
require 'faraday/request/oauth'
require 'faraday/response/parse_json'

module InstapaperFull
  class API
    attr_accessor :options
    def initialize(options = {})
      @options = options
    end

    def connection(options = {})
      options.merge!({
        :proxy => @options[:proxy],
        :ssl => {:verify => false},
        :url => "https://www.instapaper.com/api/1/"
      })

      oauth_params = {
        :consumer_key => @options[:consumer_key],
        :consumer_secret => @options[:consumer_secret]
      }

      if authenticated?
        oauth_params[:token] = @options[:oauth_token]
        oauth_params[:token_secret] = @options[:oauth_token_secret]
      end

      Faraday.new(options) do |builder|
        builder.use Faraday::Request::Multipart
        builder.use Faraday::Request::OAuth, oauth_params
        builder.use Faraday::Request::UrlEncoded
        builder.adapter Faraday.default_adapter
      end
    end

    def authenticated?
      @options.has_key? :oauth_token and @options.has_key? :oauth_token_secret
    end

    def authenticate(username, password)
      @options.delete(:oauth_token)
      @options.delete(:oauth_token_secret)
      result = connection.post 'oauth/access_token' do |r|
        r.body = { :x_auth_username => username, :x_auth_password => password, :x_auth_mode => "client_auth" }
      end
      if result.status == 200
        data = CGI.parse(result.body)
        if data.has_key? 'oauth_token_secret'
          @options[:oauth_token] = data['oauth_token'][0]
          @options[:oauth_token_secret] = data['oauth_token_secret'][0]
          verify_credentials.each { |k,v|
            @options[k.to_sym] = v if k != 'type'
          }
        end
        return true
      else
        return false
      end
{'fraction_non_alphanumeric': 0.11806699615595827, 'fraction_numerical': 0.0032948929159802307, 'mean_word_length': 2.6613065326633167, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1643006', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1129, 'n_words': 216}