<commit_before>require 'yaml'
class ServerDefinition
  attr_accessor :host, :user, :options, :port, :password
  
  def self.lookup(server)
    
  end
  
  def initialize(host, options = {})
    @options = {:port => 22}.merge(options)
    self.host = host
    self.user = @options[:user]
    self.password = @options[:password]
    self.port = @options[:port]
  end
  
  def user=(user)
    options[:user] = user
    @user=user
  end

  def port=(port)
    options[:port] = port
    @port=port
  end

  def password=(password)
    options[:password] = password
    @password=password
  end

  def connection_info(&block)
    block.call(host, user, options.merge(ssh_options))
  end
  
  def ssh_options
    {
      :auth_methods => %w[password keyboard-interactive]
    }
  end
  
  def to_s
    "#{user}:#{'*' * password.to_s.size}@#{host}:#{port}"
  end
  
  def self.lookup(server)
    server = servers[server]
    new(server['address'],{ 
      :user => server['username'],
      :password => server['password'], 
      :port => server['port']
    })
  end
  
  def self.find(server)
    servers.has_key?(server) ? lookup(server) : parse(server)
  end
  
  def self.parse(ssh_string)
    user, password, host, port = ssh_string.match /\A(.*?):(.*?)@(.*?):(\d*?)\Z/
    new(host, :user => user, :password => password, :port => port)
  end

  class << self
    def servers
      @servers ||= YAML.load_file(File.expand_path('~/.servers.yml'))
    end
  end
end<commit_msg>Added mutator and documentation for ServerDefinition.servers<commit_after>require 'yaml'
class ServerDefinition
  attr_accessor :host, :user, :options, :port, :password
  
  def self.lookup(server)
    
  end
  
  def initialize(host, options = {})
    @options = {:port => 22}.merge(options)
    self.host = host
    self.user = @options[:user]
    self.password = @options[:password]
    self.port = @options[:port]
  end
  
  def user=(user)
    options[:user] = user
    @user=user
  end

  def port=(port)
    options[:port] = port
    @port=port
  end

  def password=(password)
    options[:password] = password
    @password=password
  end

  def connection_info(&block)
    block.call(host, user, options.merge(ssh_options))
  end
  
  def ssh_options
    {
      :auth_methods => %w[password keyboard-interactive]
    }
  end
  
  def to_s
    "#{user}:#{'*' * password.to_s.size}@#{host}:#{port}"
  end
  
  def self.lookup(server)
    server = servers[server]
    new(server['address'],{ 
      :user => server['username'],
      :password => server['password'], 
      :port => server['port']
    })
  end
  
  def self.find(server)
    servers.has_key?(server) ? lookup(server) : parse(server)
  end
  
  def self.parse(ssh_string)
    user, password, host, port = ssh_string.match /\A(.*?):(.*?)@(.*?):(\d*?)\Z/
    new(host, :user => user, :password => password, :port => port)
  end

  class << self
    attr_accessor :servers

    # Access the pre-configured servers. ~/.servers.yml is parsed for this.
    # An example entry for the servers 'foobar' and 'barfoo' would look like:
    #   ---
    #   foobar:
    #     address: "127.0.0.1"
    #     username: "foo"
    #     password: "<PASSWORD>
    #     port: 22
    #   barfoo:
    #     address: "192.168.0.1"
    #     username: "bar"
    #     password: "<PASSWORD>
    #     port: 22
    #
    # Since the parsed Hash of servers is cached, a value can be stored and
    # the configuration file ignored if desired.
    def servers
      @servers ||= YAML.load_file(File.expand_path('~/.servers.yml'))
    end
  end
end
{'fraction_non_alphanumeric': 0.1533071748878924, 'fraction_numerical': 0.00616591928251121, 'mean_word_length': 2.772727272727273, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3381763', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1221, 'n_words': 277}