capture origin/<name> of active branch in case remote is not tracked
[scpubgit/System-Introspector.git] / lib / System / Introspector / Probe / Groups.pm
1 package System::Introspector::Probe::Groups;
2 use Moo;
3
4 use System::Introspector::Util qw(
5     handle_from_file
6     transform_exceptions
7 );
8
9 sub gather {
10     my ($self) = @_;
11     return transform_exceptions {
12         my %group;
13         my $fh = $self->_open_group_file;
14         while (defined( my $line = <$fh> )) {
15             chomp $line;
16             next if !(length $line);
17             my ($name, undef, $gid, $users) = split m{:}, $line;
18             $users = length($users)
19                 ? [split m{,}, $users]
20                 : [];
21             $group{ $name } = {
22                 name    => $name,
23                 gid     => $gid,
24                 users   => $users,
25             };
26         }
27         return { groups => \%group };
28     };
29 }
30
31 sub _open_group_file {
32     my ($self) = @_;
33     return handle_from_file '/etc/group';
34 }
35
36 1;
37
38 __END__
39
40 =head1 NAME
41
42 System::Introspector::Probe::Groups - Gather group information
43
44 =head1 DESCRIPTION
45
46 Uses C</etc/group> to gather information about groups.
47
48 =head1 SEE ALSO
49
50 =over
51
52 =item L<System::Introspector>
53
54 =back
55
56 =head1 COPYRIGHT
57
58 Copyright (c) 2012 the L<System::Introspector>
59 L<AUTHOR|System::Introspector/AUTHOR>,
60 L<CONTRIBUTORS|System::Introspector/CONTRIBUTORS> and
61 L<SPONSORS|System::Introspector/SPONSORS>.
62
63 =head1 LICENSE
64
65 This library is free software and may be distributed under the same terms
66 as perl itself.
67
68 =cut