package System::Introspector::Hosts;
use Moo;
+has hosts_file => (
+ is => 'ro',
+ default => sub { '/etc/hosts' },
+);
+
sub gather {
my ($self) = @_;
my $fh = $self->_open_hosts_file;
sub _open_hosts_file {
my ($self) = @_;
- open my $fh, '<', '/etc/hosts'
- or die "Unable to read /etc/hosts: $!\n";
+ my $file = $self->hosts_file;
+ open my $fh, '<', $file
+ or die "Unable to read $file: $!\n";
return $fh;
}