<commit_before>require 'net/sftp'

class BatchPrintFtp
  def initialize(
    host:     ENV['FTP_HOST'],
    username: ENV['FTP_USERNAME'],
    password: ENV['<PASSWORD>']
  )
    @host     = host
    @username = username
    @password = password
  end

  def call(data)
    Net::SFTP.start(host, username, password: password) do |sftp|
      sftp.file.open(filename, 'w') do |file|
        file.puts(data)
      end
    end
  end

  private

  def filename
    "#{Time.zone.today}.csv"
  end

  attr_reader :host
  attr_reader :username
  attr_reader :password
end<commit_msg>Direct SFTP traffic through proxy<commit_after>require 'uri'
require 'net/ssh'
require 'net/sftp'
require 'net/ssh/proxy/http'

class BatchPrintFtp
  def initialize(
    host:      ENV['FTP_HOST'],
    username:  ENV['FTP_USERNAME'],
    password:  ENV['<PASSWORD>'],
    proxy_uri: ENV['QUOTAGUARDSTATIC_URL']
  )
    @host      = host
    @username  = username
    @password  = password
    @proxy_uri = URI(proxy_uri)
  end

  def call(data)
    Net::SFTP.start(host, username, password: password, proxy: proxy) do |sftp|
      sftp.file.open(filename, 'w') do |file|
        file.puts(data)
      end
    end
  end

  private

  def proxy
    Net::SSH::Proxy::HTTP.new(
      proxy_uri.host,
      proxy_uri.port,
      user: proxy_uri.user,
      password: proxy_uri.password
    )
  end

  def filename
    "#{Time.zone.today}.csv"
  end

  attr_reader :host
  attr_reader :username
  attr_reader :password
  attr_reader :proxy_uri
end
{'fraction_non_alphanumeric': 0.11667765326301911, 'fraction_numerical': 0.0, 'mean_word_length': 2.8823529411764706, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1848361', 'n_tokens_mistral': 557, 'n_tokens_neox': 537, 'n_words': 121}