emacs-collab/lib/emacscollab/project.rb

60 lines
1.0 KiB
Ruby
Raw Permalink Normal View History

module EmacsCollab
class Project
attr_accessor :uid, :id, :path, :posixname, :users, :owner
attr_reader :keys
def initialize
@users = []
@keys = []
end
def to_s
"#{@id}, #{@path}"
end
def add_key(key)
@keys << key
end
def add_user(user)
@users << user
# TODO: Remove the following comments
#user.keys.each do |key|
# add_key(key)
#end
flush
end
def remove_user(user)
@user.delete(user)
# TODO Make sure to remove the key of the user
flush
refresh
end
def refresh
end
def flush
$db.update_project(self)
EmacsCollab.get_ssh_keyfile(self,"w+") do |key_file|
@users.each do |user|
EmacsCollab.get_user_by_id(user).keys.each do |key|
key_file << "#{key.to_s}\n"
end
end
end
end
end
class DuplicateProjectError < StandardError
end
class ProjectNotFoundError < StandardError
end
end