package System::Introspector::Report::Builder::Packages::Apt::API;
use Moo::Role;

requires qw(
  _collect_from_data
);

sub collect_from {
  my ($self, $id, $data) = @_;
  my $host    = $data->{host}{hostname};
  my $package = $data->{'packages/apt'}{installed}{packages} || {};
  my $upgrade = $data->{'packages/apt'}{upgradable}{actions}{inst} || {};
  return $self->_collect_from_data($id, $host, $package, $upgrade, $data);
}

sub _clear_upgrade {
  my ($self, $string, $version) = @_;
  return undef
    unless defined $string;
  $string =~ s{^\[\Q$version\E\]\s*\((.+)\)$}{$1};
  return $string;
}

1;
