MOP/Method/Attribute.pm

filter: Statementstmt 97.7% 44 / 45 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 93.3% 14 / 15 Podpod 100% 6 / 6 totaltotal 80.4% 70 / 87 CC 7 SCAR 7.6
CC
7
Cov
83%
args
4.3
BUILDARGS
3.5
__ANON__
2.0
CRAP 2.1
« MOP/Method.pm ↑ Summary MOP/Slot/Initializer.pm »
1 package MOP::Method::Attribute;
2 # ABSTRACT: The Method Attribute object
3  
4 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 33 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 33 ▶use UNIVERSAL::Object::Immutable;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 33 our $VERSION = '0.11';
12 33 our $AUTHORITY = 'cpan:STEVAN';
13  
14 33 ▶our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object::Immutable') }
Subroutine BEGIN: called CC=1 SCAR=0.0
15 33 our %HAS; BEGIN {
16 %HAS = (
17 0 ▶ original => sub { die '`original` is required' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 )
19 33 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # NOTE:
22 # we are not terribly sophisticated, but
23 # we accept `foo` calls (no-parens) and
24 # we accept `foo(1, 2, 3)` calls (parens
25 # with comma seperated args).
26  
27 sub BUILDARGS {
28 2 ▶ my $class = shift;
Subroutine BUILDARGS: called CC=3 SCAR=12.5
Pod documented
29 2 ▶ Carp::confess('You must pass only a simple string')
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @_ == 1 and not ref $_[0] 0 2 2
Condition33%1/3
scalar @_ == 1 and not ref $_[0]
!ll&&!rl&&r
002
MC/DC0%0/2
scalar @_ == 1 and not ref $_[0]
scalar @_ == 1 not ref $_[0]
Truth table33%1/3
A and not(B)
A= scalar @_ == 1B= not ref $_[0]
ABresult
0X0
100
111
30 unless scalar(@_) == 1 && not ref $_[0];
31 2 return +{ original => $_[0] };
32 }
33  
34 2 ▶sub REPR { \(my $x) }
Subroutine REPR: called CC=1 SCAR=0.0
Pod documented
35  
36 sub CREATE {
37 2 ▶ my ($class, $proto) = @_;
Subroutine CREATE: called CC=1 SCAR=0.0
Pod documented
38 2 my $self = $class->REPR;
39 2 $$self = $proto->{original};
40 2 $self;
41 }
42  
43 1 ▶sub original { ${ $_[0] } }
Subroutine original: called CC=1 SCAR=0.0
Pod documented
44  
45 sub name {
46 2 ▶ my ($self) = @_;
Subroutine name: called CC=1 SCAR=0.0
Pod documented
47 2 my ($name) = ($$self =~ m/^([a-zA-Z_]*)/);
48 2 return $name;
49 }
50  
51 sub args {
52 1 ▶ my ($self, $arg_splitter, $arg_processor) = @_;
Subroutine args: called CC=4 SCAR=14.6
Pod documented
53 1 my ($args) = ($$self =~ m/^[a-zA-Z_]*\(\s*(.*)\)/ms);
54 1 ▶ return unless $args;
Branch: 1 branch
BranchTrueFalseTotal
unless $args 0 1 1
55  
56 # NOTE:
57 # These parses arguments badly,
58 # but they are just the defaults.
59 # it makes no attempt to enforce
60 # anything, just splits on the
61 # comma, both skinny and fat,
62 # then strips away any quotes
63 # and treats everything as a
64 # simple string.
65 1 ▶ $arg_splitter ||= sub { split /\s*(?:\,|\=\>)\s*/ => $_[0] };
Subroutine __ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$arg_splitter ||= sub { split(/\s*(?:\,|\=\>)\s*/, $_[0], 0); }
l!l&&r!l&&!r
010
MC/DC0%0/2
$arg_splitter ||= sub { split(/\s*(?:\,|\=\>)\s*/, $_[0], 0); }
$arg_splitter sub { split(/\s*(?:\,|\=\>)\s*/, $_[0], 0); }
Truth table33%1/3
A ||= B
A= $arg_splitterB= sub { split(/\s*(?:\,|\=\>)\s*/, $_[0], 0); }
ABresult
1X1
011
000
66 $arg_processor ||= sub {
67 # NOTE:
68 # None of the args are eval-ed and they are
69 # basically just a list of strings, with the
70 # one exception of the string "undef", which
71 # will be turned into undef
72 2 ▶ my $arg = $_[0];
Subroutine __ANON__: called CC=2 SCAR=7.0
73 2 $arg =~ s/\s*$//;
74 2 $arg =~ s/^['"]//;
75 2 $arg =~ s/['"]$//;
76 2 ▶ $arg eq 'undef' ? undef : $arg;
Branch: 1 branch
BranchTrueFalseTotal
$arg eq 'undef' ? : 0 2 2
77 1 ▶ };
Condition33%1/3
$arg_processor ||= sub { my $arg = $_[0]; $arg =~ s/\s*$//; $arg =~ s/^['"]//; $arg =~ s/['"]$//; $arg eq "undef" ? undef : $arg; }
l!l&&r!l&&!r
010
MC/DC0%0/2
$arg_processor ||= sub { my $arg = $_[0]; $arg =~ s/\s*$//; $arg =~ s/^['"]//; $arg =~ s/['"]$//; $arg eq "undef" ? undef : $arg; }
$arg_processor sub { my $arg = $_[0]; $arg =~ s/\s*$//; $arg =~ s/^['"]//; $arg =~ s/['"]$//; $arg eq "undef" ? undef : $arg; }
Truth table33%1/3
A ||= B
A= $arg_processorB= sub { my $arg = $_[0]; $arg =~ s/\s*$//; $arg =~ s/^['"]//; $arg =~ s/['"]$//; $arg eq "undef" ? undef : $arg; }
ABresult
1X1
011
000
78  
79 1 return [ map $arg_processor->( $_ ), $arg_splitter->( $args ) ];
80 }
81  
82 33 1;
83  
84 __END__
« MOP/Method.pm ↑ Summary MOP/Slot/Initializer.pm »