Config/Type.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 2 totaltotal 82.0% 41 / 50 CC 3 SCAR 3.9
CC
3
Cov
89%
new
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Config/Object.pm ↑ Summary
1 =head1 NAME
2  
3 Synapse::CLI::Config::Type
4  
5 =head1 SYNOPSIS
6  
7 my $type = Synapse::CLI::Config::Type->new ("Some::Package");
8 my $res = $type->some_class_method();
9  
10 =head1 SUMMARY
11  
12 This package is a proxy which allows manipulating package methods using an
13 object. It is used to be able to call class methods on the command line by
14 instantiating an object representing the class / package.
15  
16 For instance:
17  
18 myapp-cli type sometype some_method
19  
20  
21 =head1 EXPORTS
22  
23 none.
24  
25  
26 =head1 BUGS
27  
28 Please report them to me. Patches always welcome...
29  
30  
31 =head1 AUTHOR
32  
33 Jean-Michel Hiver, jhiver (at) synapse (dash) telecom (dot) com
34  
35 This library is free software; you can redistribute it and/or modify
36 it under the same terms as Perl itself.
37  
38 =cut
39 package Synapse::CLI::Config::Type;
40 4 ▶use Synapse::CLI::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 3 our $AUTOLOAD;
45  
46  
47 6 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod undocumented
48 6 my $class = shift;
49 6 ▶ if (ref $class) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $class) { } 0 6 6
50 0 return $class->{package}->new (@_);
51 }
52 else {
53 6 my $type = shift;
54 6 ▶ my $package = $Synapse::CLI::Config::ALIAS->{$type} || $type;
Condition33%1/3
$Synapse::CLI::Config::ALIAS->{$type} || $type
l!l&&r!l&&!r
600
MC/DC0%0/2
$Synapse::CLI::Config::ALIAS->{$type} || $type
$Synapse::CLI::Config::ALIAS->{$type} $type
Truth table33%1/3
A || B
A= $Synapse::CLI::Config::ALIAS->{$type}B= $type
ABresult
1X1
011
000
55 6 ▶ eval "use $package";
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
56 6 return bless { type => $type, package => $package }, $class;
57 }
58 }
59  
60  
61 15 ▶sub can {
Subroutine can: called CC=1 SCAR=0.0
Pod undocumented
62 15 my $self = shift;
63 15 my $meth = shift;
64 15 return $self->{package}->can ($meth);
65 }
66  
67  
68 5 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
69 5 my $self = shift;
70 5 my $type = $self->{type};
71 5 my $meth = $AUTOLOAD;
72 5 $meth =~ s/.*:://;
73 5 return $self->{package}->$meth (@_);
74 }
75  
76  
77 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=0.0
78 }
79  
80  
81 3 1;
« Config/Object.pm ↑ Summary