Module: Amp::Servers::RepoUserManagement::Memory
- Defined in:
- lib/amp/server/repo_user_management.rb
Instance Method Summary collapse
-
#add_user(user_info = {}) ⇒ Object
(also: #<<)
Adds a user to the system.
-
#repos ⇒ Object
All the repositories stored in a hash.
-
#set_private(repository, _private = true) ⇒ Object
Sets the given repository’s privacy levels.
-
#set_reader(repository, user) ⇒ Object
Adds a given username/password combination to the system, for a given repository, with read-only privileges.
-
#set_writer(repository, user) ⇒ Object
Adds a given username/password combination to the system, for a given repository, with write privileges.
- #users ⇒ Object
Instance Method Details
#add_user(user_info = {}) ⇒ Object Also known as: <<
Adds a user to the system. This is not repository specific.
25 26 27 28 |
# File 'lib/amp/server/repo_user_management.rb', line 25 def add_user(user_info={}) new_user = User.from_hash user_info users[new_user.username] = new_user # universal list of users end |
#repos ⇒ Object
All the repositories stored in a hash.
:private => Boolean}
15 |
# File 'lib/amp/server/repo_user_management.rb', line 15 def repos; @repos ||= {}; @repos.default = {}; @repos; end |
#set_private(repository, _private = true) ⇒ Object
Sets the given repository’s privacy levels. Repositories default to being public, and must be set to be private using this method. This method can also be used to later make a private repository public without stopping the server.
67 68 69 |
# File 'lib/amp/server/repo_user_management.rb', line 67 def set_private(repository, _private=true) repos[repository][:private] = !!_private end |
#set_reader(repository, user) ⇒ Object
Adds a given username/password combination to the system, for a given repository, with read-only privileges. This will override any other settings previously set. For example, a call to #set_writer and then #set_reader would be as though #set_writer never happened.
53 54 55 56 57 58 |
# File 'lib/amp/server/repo_user_management.rb', line 53 def set_reader(repository, user) repos[repository] ||= {:users => {}, :private => false} repos[repository][:users][user.username] ||= {:user => user, :read => true, :write => false} repos[repository][:users][user.username][:read] = true repos[repository][:users][user.username][:write] = false end |
#set_writer(repository, user) ⇒ Object
Adds a given username/password combination to the system, for a given repository, with write privileges.
38 39 40 41 42 43 |
# File 'lib/amp/server/repo_user_management.rb', line 38 def set_writer(repository, user) repos[repository] ||= {:users => {}, :private => false} repos[repository][:users][user.username] ||= {:user => user, :read => true, :write => true} repos[repository][:users][user.username][:read] = true # these are unnecessary if we are adding a user repos[repository][:users][user.username][:write] = true end |
#users ⇒ Object
17 |
# File 'lib/amp/server/repo_user_management.rb', line 17 def users; @users ||= {}; end |