package System::Introspector::ResolvConf;
use Moo;

sub gather {
    my ($self) = @_;
    my $fh = $self->_open_resolv_conf_file;
    my @resolv;
    while (defined( my $line = <$fh> )) {
        chomp $line;
        next if $line =~ m{^\s*$}
             or $line =~ m{^\s*#};
        push @resolv, [split m{\s+}, $line];
    }
    return \@resolv;
}

sub _open_resolv_conf_file {
    my ($self) = @_;
    open my $fh, '<', '/etc/resolv.conf'
        or die "Unable to read /etc/resolv.conf: $!";
    return $fh;
}

1;
