Module: PoiseApplication::Utils
Overview
Utility methods for PoiseApplication.
Class Method Summary collapse
-
.primary_group_for(user) ⇒ String
Try to find the primary group name for a given user.
Instance Method Summary collapse
-
#primary_group_for(user) ⇒ String
Try to find the primary group name for a given user.
Class Method Details
.primary_group_for(user) ⇒ String
Try to find the primary group name for a given user.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/poise_application/utils.rb', line 36 def primary_group_for(user) # Force a reload in case any users were created earlier in the run. Etc.endpwent Etc.endgrent user = if user.is_a?(Integer) Etc.getpwuid(user) else Etc.getpwnam(user.to_s) end Etc.getgrgid(user.gid).name rescue ArgumentError # One of the get* calls exploded. ¯\_(ツ)_/¯ user.to_s end |
Instance Method Details
#primary_group_for(user) ⇒ String
Try to find the primary group name for a given user.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/poise_application/utils.rb', line 36 def primary_group_for(user) # Force a reload in case any users were created earlier in the run. Etc.endpwent Etc.endgrent user = if user.is_a?(Integer) Etc.getpwuid(user) else Etc.getpwnam(user.to_s) end Etc.getgrgid(user.gid).name rescue ArgumentError # One of the get* calls exploded. ¯\_(ツ)_/¯ user.to_s end |