Class: Golem::DB::Static
- Inherits:
-
Object
- Object
- Golem::DB::Static
- Defined in:
- lib/golem/db/static.rb
Overview
Instance Method Summary collapse
-
#add_key(user_name, key) ⇒ Array
Add key to database.
-
#add_repository(name, user_name) ⇒ Array
Add repository to database.
-
#add_user(name) ⇒ Array
Add user to database.
-
#initialize ⇒ Static
constructor
Create database, initialize users, repositories and ssh_keys to [].
-
#repositories(opts = {}) ⇒ Array
Retrieve repositories.
-
#setup {|_self| ... } ⇒ Object
Setup database.
-
#ssh_keys(opts = {}) ⇒ Array
Retrieve ssh keys.
-
#users(opts = {}) ⇒ Array
Retrieve users.
Constructor Details
#initialize ⇒ Static
Create database, initialize users, repositories and ssh_keys to [].
12 13 14 |
# File 'lib/golem/db/static.rb', line 12 def initialize @users, @repositories, @ssh_keys = [], [], [] end |
Instance Method Details
#add_key(user_name, key) ⇒ Array
Add key to database.
57 58 59 60 |
# File 'lib/golem/db/static.rb', line 57 def add_key(user_name, key) abort "Cannot add key, user not found!" unless users(:return => :array).include?(user_name) @ssh_keys << {:user_name => user_name, :key => key} end |
#add_repository(name, user_name) ⇒ Array
Add repository to database.
48 49 50 51 |
# File 'lib/golem/db/static.rb', line 48 def add_repository(name, user_name) abort "Cannot add repository, user not found!" unless users(:return => :array).include?(user_name) @repositories << {:name => name, :user_name => user_name} end |
#add_user(name) ⇒ Array
Add user to database.
40 41 42 |
# File 'lib/golem/db/static.rb', line 40 def add_user(name) @users << {:name => name} end |
#repositories(opts = {}) ⇒ Array
Retrieve repositories.
26 27 28 |
# File 'lib/golem/db/static.rb', line 26 def repositories(opts = {}) opts[:return] == :array ? @repositories.collect {|r| r[:name]} : @repositories end |
#setup {|_self| ... } ⇒ Object
Setup database.
63 64 65 |
# File 'lib/golem/db/static.rb', line 63 def setup(&block) yield self end |
#ssh_keys(opts = {}) ⇒ Array
Retrieve ssh keys.
33 34 35 |
# File 'lib/golem/db/static.rb', line 33 def ssh_keys(opts = {}) opts[:return] == :array ? @ssh_keys.collect {|k| [k[:user_name], k[:key]]} : @ssh_keys end |
#users(opts = {}) ⇒ Array
Retrieve users.
19 20 21 |
# File 'lib/golem/db/static.rb', line 19 def users(opts = {}) opts[:return] == :array ? @users.collect {|u| u[:name]} : @users end |