<commit_before>module Gitolite
  #Models an SSH key within gitolite
  #provides support for multikeys
  #
  #Types of multi keys:
  #  bob.pub => username: bob
  #  <EMAIL> => username: bob, location: desktop
  #  <EMAIL> => username: <EMAIL>
  #  <EMAIL> => username: <EMAIL>, location: desktop

  class SSHKey
    attr_accessor :owner, :location, :type, :blob, :email

    def initialize(key)

      raise "#{key} does not exist!" unless File.exists?(key)

      #Get our owner and location
      File.basename(key) =~ /^(\w+(?:@(?:\w+\.)+\D{2,4})?)(?:@(\w+))?.pub$/i
      @owner = $1
      @location = $2 || ""

      #Get parts of the key
      @type, @blob, @email = File.read(key).split

      #If the key didn't have an email, just use the owner
      if @email.nil?
        @email = @owner
      end
    end

    def to_s
      [@type, @blob, @email].join(' ')
    end
  end
end

<commit_msg>Overload constructor and add a method to get the filename for the key<commit_after>module Gitolite
  #Models an SSH key within gitolite
  #provides support for multikeys
  #
  #Types of multi keys:
  #  bob.pub => username: bob
  #  <EMAIL> => username: bob, location: desktop
  #  <EMAIL> => username: <EMAIL>
  #  <EMAIL> => username: <EMAIL>, location: desktop

  class SSHKey
    attr_accessor :owner, :location, :type, :blob, :email

    def initialize(key)

      raise "#{key} does not exist!" unless File.exists?(key)

      #Get our owner and location
      File.basename(key) =~ /^(\w+(?:@(?:\w+\.)+\D{2,4})?)(?:@(\w+))?.pub$/i
      @owner = $1
      @location = $2 || ""

      #Get parts of the key
      @type, @blob, @email = File.read(key).split

      #If the key didn't have an email, just use the owner
      if @email.nil?
        @email = @owner
      end
    end
    
    def initialize(type, blob, email, owner = nil, location = "")
      @type = type
      @blob = blob
      @email = email
      
      @owner = owner || email
      @location = location
    end

    def to_s
      [@type, @blob, @email].join(' ')
    end
    
    def filename
      file = @owner
      file << "@#{@location}" unless @location.empty?
      file << ".pub"
    end
  end
end


{'fraction_non_alphanumeric': 0.15240274599542333, 'fraction_numerical': 0.0036613272311212816, 'mean_word_length': 2.3944099378881987, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '1424402', 'n_tokens_mistral': 758, 'n_tokens_neox': 735, 'n_words': 230}