<commit_before>require_relative 'query'

class Pocket
  attr_accessor :consumer_key
  attr_accessor :redirect_url
  attr_accessor :access_token
  def initialize(file_with_key = 'consumer.key', redirect_url = 'example1.com')
    @consumer_key = File.open(file_with_key) {|f| f.readline}
    @redirect_url = redirect_url
  end

  def login
    key = send_post_request('https://getpocket.com/v3/oauth/request', {consumer_key: @consumer_key, redirect_uri: @redirect_url})[:code]
    `google-chrome-stable "https://getpocket.com/auth/authorize?request_token=#{key}&redirect_uri=#{@redirect_url}"`
    sleep 5
    @access_token = send_post_request("https://getpocket.com/v3/oauth/authorize", {consumer_key: @consumer_key, code: key})[:access_token]
  end

  def add_url(url)
    send_post_request("https://getpocket.com/v3/add", {url: url, consumer_key: @consumer_key, access_token: @access_token})
  end
end<commit_msg>add logger to pocket<commit_after>require 'logger'
require_relative 'query'

class Pocket
  attr_accessor :consumer_key
  attr_accessor :redirect_url
  attr_accessor :access_token
  attr_accessor :logger

  def initialize(file_with_key = 'consumer.key', redirect_url = 'example1.com')
    @consumer_key = File.open(file_with_key) {|f| f.readline}
    @redirect_url = redirect_url
    @logger = Logger.new(STDOUT)
    @logger.level = Logger::INFO
  end

  def login
    key = send_post_request('https://getpocket.com/v3/oauth/request', {consumer_key: @consumer_key, redirect_uri: @redirect_url})[:code]
    @logger.info('Received oath key')
    `google-chrome-stable "https://getpocket.com/auth/authorize?request_token=#{key}&redirect_uri=#{@redirect_url}"`
    sleep 5
    @access_token = send_post_request("https://getpocket.com/v3/oauth/authorize", {consumer_key: @consumer_key, code: key})[:access_token]
    @logger.info('Received access token')
  end

  def add_url(url)
    send_post_request("https://getpocket.com/v3/add", {url: url, consumer_key: @consumer_key, access_token: @access_token})
    @logger.info("Added url: #{url}")
  end
end
{'fraction_non_alphanumeric': 0.13537117903930132, 'fraction_numerical': 0.0048520135856380394, 'mean_word_length': 5.463949843260188, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '860544', 'n_tokens_mistral': 739, 'n_tokens_neox': 706, 'n_words': 123}