|
our $VERSION = '1.12.0.1' ;
sub new {
my $that = shift ;
my $proto = ref ( $that ) || $that ;
my $self = $proto ->SUPER::new( @_ );
bless ( $self , $proto );
$self ->{commands} = {
install => 'pkg install -q --accept %s' ,
install_version => 'pkg install -q --accept %s' ,
remove => 'pkg uninstall -r -q %s' ,
update_package_db => 'pkg refresh' ,
};
return $self ;
}
sub get_installed {
my ( $self ) = @_ ;
my @lines = i_run "pkg info -l" ;
my @pkg ;
my ( $version , $name );
for my $line ( @lines ) {
if ( $line =~ m/^$/ ) {
push (
@pkg ,
{
name => $name ,
version => $version ,
}
);
next ;
}
if ( $line =~ m/Name: .*\/(.*?)$/ ) {
$name = $1;
next ;
}
if ( $line =~ m/Version: (.*)$/ ) {
$version = $1;
next ;
}
}
return @pkg ;
}
1;
|