Module: Amp::Servers::RepoUserManagement::DataMapper

Defined in:
lib/amp/server/repo_user_management.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/amp/server/repo_user_management.rb', line 190

def self.extended(klass)
  require 'dm-core'
  
  users = Class.new do
    include DataMapper::Resource
    property :username, String
    property :password, String
    
    has n, :perms
  end
  const_set 'User', users
  
  perms = Class.new do
    include DataMapper::Resource
    property :read
    property :write
    
    belongs_to :user
    belongs_to :repo
  end
  const_set 'Perm', perms
  
  repo = Class.new do
    include DataMapper::Resource
    property :url,  String
    property :path, String
    
    has n, :perms
  end
  const_set 'Repo', repo
end

Instance Method Details

#add_user(user_info = {}) ⇒ Object Also known as: <<

Adds a user to the system. This is not repository specific.

Parameters:

  • user_info (Hash) (defaults to: {})

    The user data, in hash form. Passed to User.from_hash

Options Hash (user_info):

  • :username (String)

    The username for the user

  • :password (String)

    The cleartext (unencrypted) password.



243
244
245
# File 'lib/amp/server/repo_user_management.rb', line 243

def add_user(={})
  
end

#reposObject

TODO:

slow as fuck

All the repositories stored in a hash.

:private => Boolean}

Examples:

repos = {:users => {String => {:user => Amp::Servers::User,

:read => Boolean, :write => Boolean}},


229
230
231
# File 'lib/amp/server/repo_user_management.rb', line 229

def repos
  
end

#set_private(repository, _private = true) ⇒ Object

TODO:

don’t know if this actually works

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.

Parameters:

  • repository (Repository)

    The repository for which to set privacy settings

  • _private (Boolean) (defaults to: true)

    (true) whether the repository should be private or not



280
281
282
# File 'lib/amp/server/repo_user_management.rb', line 280

def set_private(repository, _private=true)
  
end

#set_reader(repository, user) ⇒ Object

TODO:

don’t know if this actually works

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.

Parameters:

  • repository (Repository)

    The repository to which are associating the user

  • user (Amp::Servers::User)

    The user to give write priveleges to



268
269
270
# File 'lib/amp/server/repo_user_management.rb', line 268

def set_reader(repository, user)
  
end

#set_writer(repository, user) ⇒ Object

TODO:

don’t know if this actually works

Adds a given username/password combination to the system, for a given repository, with write privileges.

Parameters:

  • repository (Repository)

    The repository to which are associating the user

  • user (Amp::Servers::User)

    The user to give write priveleges to



255
256
257
# File 'lib/amp/server/repo_user_management.rb', line 255

def set_writer(repository, user)
  
end

#usersObject



233
234
235
# File 'lib/amp/server/repo_user_management.rb', line 233

def users
  
end