File Coverage

blib/lib/Podman/Images.pm
Criterion Covered Total %
statement 20 27 74.0
branch 2 6 33.3
condition 1 2 50.0
subroutine 5 6 83.3
pod 1 2 50.0
total 29 43 67.4


line stmt bran cond sub pod time code
1             package Podman::Images;
2              
3 2     2   549934 use Mojo::Base 'Podman::Client';
  2         12  
  2         11  
4              
5 2     2   186 use Mojo::Collection;
  2         4  
  2         68  
6 2     2   9 use Scalar::Util qw(blessed);
  2         16  
  2         80  
7              
8 2     2   405 use Podman::Image;
  2         5  
  2         699  
9              
10             has 'names_only' => undef;
11              
12             sub list {
13 1     1 1 29806 my $self = shift;
14              
15 1 50       39 if (!blessed($self)) {
16 0         0 $self = __PACKAGE__->new();
17 0         0 my %opts = @_;
18 0         0 $self->names_only($opts{names_only});
19             }
20              
21 1         59 my $images = $self->get('images/json', parameters => {all => 1},)->json;
22              
23             my @list = map {
24 2   50     81 my ($name) = split /:/, $_->{Names}->[0] || 'none';
25 2 50       8 $self->names_only ? $name : Podman::Image->new(name => $name);
26 1         402 } @{$images};
  1         4  
27              
28 1         45 return Mojo::Collection->new(@list);
29             }
30              
31             sub prune {
32 0     0 0   my $self = shift;
33              
34 0 0         $self = __PACKAGE__->new() unless blessed($self);
35              
36 0           $self->post('images/prune');
37              
38 0           return 1;
39             }
40              
41             1;
42              
43             __END__