Module: Wright::Util::User Private
- Defined in:
- lib/wright/util/user.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Various user utility functions.
Class Method Summary collapse
-
.group_to_gid(group) ⇒ Integer
private
Returns a group’s gid.
-
.owner_to_owner_group(owner) ⇒ Array<(String, String)>
private
Splits a colon-separated owner string into owner and group.
-
.user_to_uid(user) ⇒ Integer
private
Returns a user’s uid.
Class Method Details
.group_to_gid(group) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a group’s gid.
38 39 40 41 |
# File 'lib/wright/util/user.rb', line 38 def self.group_to_gid(group) return nil if group.nil? group.is_a?(String) ? Etc.getgrnam(group).gid : group.to_i end |
.owner_to_owner_group(owner) ⇒ Array<(String, String)>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Splits a colon-separated owner string into owner and group.
62 63 64 65 66 67 68 69 |
# File 'lib/wright/util/user.rb', line 62 def self.owner_to_owner_group(owner) group = nil return [owner, group] unless owner.is_a?(String) fail ArgumentError, "Invalid owner: '#{owner}'" if owner.count(':') > 1 owner, group = owner.split(':') [owner, group] end |
.user_to_uid(user) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a user’s uid.
20 21 22 23 |
# File 'lib/wright/util/user.rb', line 20 def self.user_to_uid(user) return nil if user.nil? user.is_a?(String) ? Etc.getpwnam(user).uid : user.to_i end |