Class: LinuxHub::LinuxUser
- Inherits:
-
Object
- Object
- LinuxHub::LinuxUser
- Defined in:
- lib/linux-hub/linux_user.rb
Constant Summary collapse
- DEFAULT_GROUP =
The default group is used to keep track of members Members in this group not in the appropriate Github Team are purged
'linuxhub'
Instance Attribute Summary collapse
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(username:, groups: [], ssh_keys: []) ⇒ LinuxUser
constructor
A new instance of LinuxUser.
Constructor Details
#initialize(username:, groups: [], ssh_keys: []) ⇒ LinuxUser
Returns a new instance of LinuxUser.
23 24 25 26 27 |
# File 'lib/linux-hub/linux_user.rb', line 23 def initialize(username:, groups: [], ssh_keys: []) @username = username @groups = (groups || []) + [DEFAULT_GROUP] @ssh_keys = ssh_keys end |
Instance Attribute Details
#username ⇒ Object (readonly)
Returns the value of attribute username.
21 22 23 |
# File 'lib/linux-hub/linux_user.rb', line 21 def username @username end |
Class Method Details
.users_in_group ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/linux-hub/linux_user.rb', line 9 def self.users_in_group File.open("/etc/group") do |f| f.each_line do |line| user = line.split(":") if user.first == DEFAULT_GROUP return user[3].chomp.split(',').collect { |u| new(username: u) } end end end [] end |
Instance Method Details
#create ⇒ Object
29 30 31 32 33 |
# File 'lib/linux-hub/linux_user.rb', line 29 def create create_default_group create_user create_user_keys end |
#delete ⇒ Object
35 36 37 38 |
# File 'lib/linux-hub/linux_user.rb', line 35 def delete delete_home delete_user end |