From: Robert 'phaylon' Sedlacek Date: Wed, 9 May 2012 22:08:43 +0000 (+0000) Subject: use command pipe output and exception handling utils X-Git-Tag: v0.001_001~102 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9ee104ccb5eda929b50c1c45fd4e77a235d0350c;p=scpubgit%2FSystem-Introspector.git use command pipe output and exception handling utils --- diff --git a/lib/System/Introspector/Packages/Apt.pm b/lib/System/Introspector/Packages/Apt.pm index 07e17a8..6b742d5 100644 --- a/lib/System/Introspector/Packages/Apt.pm +++ b/lib/System/Introspector/Packages/Apt.pm @@ -1,19 +1,23 @@ package System::Introspector::Packages::Apt; use Moo; +use System::Introspector::Util qw( + handle_from_command + transform_exceptions +); + sub gather { my ($self) = @_; return { - installed => $self->_gather_installed, + installed => transform_exceptions { + return { packages => $self->_gather_installed }; + }, }; } sub _open_dpkg_query_pipe { my ($self) = @_; - my $command = 'dpkg-query --show'; - open my $pipe, '-|', $command - or die "Unable to open pipe to '$command': $!\n"; - return $pipe; + return handle_from_command 'dpkg-query --show'; } sub _gather_installed {