lib/gitolite/ssh_key.rb in gitolite-0.0.1.alpha vs lib/gitolite/ssh_key.rb in gitolite-0.0.2.alpha

- old
+ new

@@ -13,11 +13,11 @@ def initialize(type, blob, email, owner = nil, location = "") @type = type @blob = blob @email = email - + @owner = owner || email @location = location end def self.from_file(key) @@ -34,35 +34,36 @@ #If the key didn't have an email, just use the owner if email.nil? email = owner end - + self.new(type, blob, email, owner, location) end def to_s [@type, @blob, @email].join(' ') end - - def to_file(filename) - File.open(filename, "w") do |f| + + def to_file(path) + key_file = File.join(path, self.filename) + File.open(key_file, "w") do |f| f.write (self.to_s) end + key_file end - + def filename file = @owner file += "@#{@location}" unless @location.empty? file += ".pub" end - + def ==(key) @type == key.type && @blob == key.blob && @email == key.email && @owner == key.owner && @location == key.location end end end -