<commit_before>require 'net/ssh'

class Remote::Exec::Ssh
  attr_reader :host, :user, :last_status

  def initialize(host, user = nil)
    @host = host
    @user = user
  end

  # TODO: make it run in one session
  def execute(command)
    @last_status = nil
    ssh.open_channel do |channel|
      channel.request_pty
      channel.exec command do |ch, success|
        channel.on_data do |ch, data|
          yield(data, nil)
        end
        channel.on_extended_data do |ch, type, data|
          yield(nil, data)
        end
        channel.on_request("exit-status") do |ch, data|
          @last_status = data.read_long
        end
      end
      channel.wait
    end
    ssh.loop
    @last_status
  end

  def ssh
    @ssh ||= Net::SSH.start(host, user)
  end
end<commit_msg>add options for ssh<commit_after>require 'net/ssh'

class Remote::Exec::Ssh
  attr_reader :host, :user, :last_status
  attr_accessor :options

  def initialize(host, user = nil, options)
    @host = host
    @user = user
    @options = options
  end

  # TODO: make it run in one session
  def execute(command)
    @last_status = nil
    ssh.open_channel do |channel|
      channel.request_pty
      channel.exec command do |ch, success|
        channel.on_data do |ch, data|
          yield(data, nil)
        end
        channel.on_extended_data do |ch, type, data|
          yield(nil, data)
        end
        channel.on_request("exit-status") do |ch, data|
          @last_status = data.read_long
        end
      end
      channel.wait
    end
    ssh.loop
    @last_status
  end

  def ssh
    @ssh ||= Net::SSH.start(host, user, options)
  end
end
{'fraction_non_alphanumeric': 0.09683313032886723, 'fraction_numerical': 0.0, 'mean_word_length': 2.2534653465346532, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '623310', 'n_tokens_mistral': 553, 'n_tokens_neox': 535, 'n_words': 152}