simplified hosts to be standard file data structure, also preserves comments
[scpubgit/System-Introspector.git] / lib / System / Introspector / Probe / Hosts.pm
CommitLineData
afd7c030 1package System::Introspector::Probe::Hosts;
645a8f49 2use Moo;
3
a042903a 4use System::Introspector::Util qw(
5a9311b3 5 output_from_file
a042903a 6 transform_exceptions
7);
8
8d888cc1 9has hosts_file => (
10 is => 'ro',
11 default => sub { '/etc/hosts' },
12);
13
645a8f49 14sub gather {
15 my ($self) = @_;
5a9311b3 16 my $file = $self->hosts_file;
17 return {
18 hosts_file => transform_exceptions {
19 return {
20 file_name => $file,
21 body => scalar output_from_file $file,
22 };
23 },
a042903a 24 };
645a8f49 25}
26
645a8f49 271;
535e84b6 28
29__END__
30
31=head1 NAME
32
33System::Introspector::Hosts - Gather known hosts
34
35=head1 DESCRIPTION
36
37Reads a C<hosts> file to produce a list of known hosts
38
39=head1 ATTRIBUTES
40
41=head2 hosts_file
42
43The path to the C<hosts> file that should be read. Defaults to C</etc/hosts>.
44
45=head1 SEE ALSO
46
47=over
48
49=item L<System::Introspector>
50
51=back
52
53=cut
54