From: Robert 'phaylon' Sedlacek Date: Tue, 8 May 2012 18:45:49 +0000 (+0000) Subject: made hosts file configurable X-Git-Tag: v0.001_001~118 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8d888cc1eda6f9ec66b1d77728b65ec61394b0dc;p=scpubgit%2FSystem-Introspector.git made hosts file configurable --- diff --git a/lib/System/Introspector/Hosts.pm b/lib/System/Introspector/Hosts.pm index d5e880c..4f74d2d 100644 --- a/lib/System/Introspector/Hosts.pm +++ b/lib/System/Introspector/Hosts.pm @@ -1,6 +1,11 @@ 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; @@ -16,8 +21,9 @@ sub gather { 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; }