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