blib/lib/Pinto/Target.pm

filter: Statementstmt 87.5% 21 / 24 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 78.9% 30 / 38 CC 5 SCAR 14.9
CC
5
Cov
75%
new
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
« blib/lib/Pinto/Server/Responder/File.pm ↑ Summary blib/lib/Pinto/Target/Package.pm »
1 # ABSTRACT: Create Spec objects from strings
2  
3 package Pinto::Target;
4  
5 153 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 153 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 153 ▶use Class::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 153 ▶use Pinto::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #-------------------------------------------------------------------------------
13  
14 153 our $VERSION = '0.14'; # VERSION
15  
16 #-------------------------------------------------------------------------------
17  
18  
19 15 ▶sub new {
Subroutine new: called CC=5 SCAR=19.7
Pod documented
20 15 my ( $class, $arg ) = @_;
21  
22 15 my $type = ref $arg;
23 15 my $target_class;
24  
25 15 ▶ if ( not $type ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $type) { } 15 0 15
elsif (ref $arg eq 'HASH') { } 0 0 0
26  
27 15 ▶ $target_class =
Branch: 1 branch
BranchTrueFalseTotal
$arg =~ m[/]x ? : 3 12 15
28 ( $arg =~ m{/}x )
29 ? 'Pinto::Target::Distribution'
30 : 'Pinto::Target::Package';
31 }
32 elsif ( ref $arg eq 'HASH' ) {
33  
34 $target_class =
35 ( exists $arg->{author} )
36 0 ▶ ? 'Pinto::Target::Distribution'
Branch: 1 branch
BranchTrueFalseTotal
exists $arg->{'author'} ? : 0 0 0
37 : 'Pinto::Target::Package';
38 }
39 else {
40  
41 # I would just use throw() here, but I need to avoid
42 # creating a circular dependency between this package,
43 # Pinto::Types and Pinto::Util.
44  
45 0 my $message = "Don't know how to make target from $arg";
46 0 Pinto::Exception->throw( message => $message );
47  
48 }
49  
50 15 Class::Load::load_class($target_class);
51 15 return $target_class->new($arg);
52 }
53  
54 #-------------------------------------------------------------------------------
55 153 1;
56  
57 __END__
« blib/lib/Pinto/Server/Responder/File.pm ↑ Summary blib/lib/Pinto/Target/Package.pm »