Base.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Virtual.pm ↑ Summary
1 #
2 # This file is part of PackageManager-Virtual
3 #
4 # This software is copyright (c) 2019 by Daniel Maurice Davis.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # ABSTRACT: PackageManager::Virtual compositions with input validation.
13  
14  
15 package PackageManager::Base;
16 $PackageManager::Base::VERSION = '0.191250';
17 1 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Params::Check qw/check/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 0 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=2.6
20  
21 around 'list' => sub {
22 my ( $orig, $self, %args ) = @_;
23  
24 my $verbose;
25 my $template = {
26 verbose => {
27 default => 0,
28 store => \$verbose,
29 allow => [ 0, 1 ],
30 }
31 };
32 check( $template, \%args )
33 or confess( Params::Check->last_error );
34  
35 return $self->$orig($verbose);
36 };
37  
38 around 'install' => sub {
39 my ( $orig, $self, %args ) = @_;
40  
41 my ( $verbose, $name, $version );
42 my $template = {
43 verbose => {
44 default => 0,
45 store => \$verbose,
46 allow => [ 0, 1 ]
47 },
48 name => {
49 required => 1,
50 store => \$name,
51 allow => sub {
52 return length( $_[0] ) > 0;
53 }
54 },
55 version => {
56 store => \$version,
57 allow => sub {
58 return length( $_[0] ) > 0;
59 }
60 }
61 };
62 check( $template, \%args )
63 or confess( Params::Check->last_error );
64  
65 return $self->$orig( $name, $version, $verbose );
66 };
67  
68 around 'remove' => sub {
69 my ( $orig, $self, %args ) = @_;
70  
71 my ( $verbose, $name );
72 my $template = {
73 verbose => {
74 default => 0,
75 store => \$verbose,
76 allow => [ 0, 1 ]
77 },
78 name => {
79 required => 1,
80 store => \$name,
81 allow => sub {
82 return length( $_[0] ) > 0;
83 }
84 }
85 };
86 check( $template, \%args )
87 or confess( Params::Check->last_error );
88  
89 return $self->$orig( $name, $verbose );
90 };
91  
92 with 'PackageManager::Virtual';
93  
94 1;
95  
96 __END__
« Virtual.pm ↑ Summary