Object/InsideOut/Metadata.pm

filter: Statementstmt 63.1% 84 / 133 Branchbran 37.5% 30 / 80 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 75.0% 3 / 4 totaltotal 55.9% 127 / 227 CC 49 SCAR 40.7
CC
49
Cov
54%
get_args
105.3
get_methods
78.6
add_meta
7.0
CRAP 58.3
« Object/InsideOut/Cumulative.pm ↑ Summary Object/InsideOut/Dynamic.pm »
1 package Object::InsideOut::Metadata; {
2  
3 44 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 44 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 45 our $VERSION = '4.05';
7 45 $VERSION = eval $VERSION;
8  
9 # Stores method metadata
10 # Initialized with our own metadata
11 45 my %METADATA = (
12 'Object::InsideOut::Metadata' => {
13 'add_meta' => {'hidden' => 1},
14 'AUTOLOAD' => {'hidden' => 1},
15 'new' => {'hidden' => 1},
16 'create_field' => {'hidden' => 1},
17 'add_class' => {'hidden' => 1},
18 'get_classes' => {'kind' => 'object'},
19 'get_methods' => {'kind' => 'object'},
20 'get_args' => {'kind' => 'object'},
21 },
22 );
23  
24  
25 ### Exported Subroutines ###
26  
27 sub import
28 89 ▶{
Subroutine import: called CC=1 SCAR=0.0
29 # Export 'add_meta' call
30 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 89 my $caller = caller();
32 89 *{$caller.'::add_meta'} = \&add_meta;
33 89 $METADATA{$caller}{'add_meta'}{'hidden'} = 1;
34 }
35  
36  
37 # Stores metadata for later use
38 sub add_meta
39 360 ▶{
Subroutine add_meta: called CC=7 SCAR=19.5
Pod undocumented
40 360 my ($class, $name, $meta, $value) = @_;
41  
42 360 ▶ if (@_ == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 4) { } 42 318 360
43 42 $METADATA{$class}{$name}{$meta} = $value;
44 } else {
45 318 my $data;
46 318 ▶ if (@_ == 3) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 3) { } 0 318 318
elsif (@_ == 2) { } 178 140 318
47 0 $$data{$class}{$name} = $meta;
48 } elsif (@_ == 2) {
49 178 $$data{$class} = $name;
50 } else {
51 140 $data = $class;
52 }
53 318 ▶ while (my ($c, $mn) = each(%$data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$data) 395 318 713
54 395 ▶ while (my ($n, $md) = each(%$mn)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$mn) 2947 395 3342
55 2947 ▶ while (my ($m, $v) = each(%$md)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$md) 4684 2947 7631
56 4684 $METADATA{$c}{$n}{$m} = $v;
57 }
58 }
59 }
60 }
61 }
62  
63  
64 # This will load the OO option of our code.
65 # It's done this way because of circular dependencies with OIO.
66 sub AUTOLOAD
67 1 ▶{
Subroutine AUTOLOAD: called CC=4 SCAR=19.3
68 # Need 5.8.0 or later
69 1 ▶ if ($] < 5.008) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.008") 0 1 1
70 0 OIO::Code->die('message' => q/Introspection API requires Perl 5.8.0 or later/,
71 'ignore_package' => 'Object::InsideOut::Metadata');
72 }
73  
74 # It's a bug if not invoked by ->new()
75 # This should only ever happen once
76 1 ▶ if (our $AUTOLOAD ne 'Object::InsideOut::Metadata::new') {
Branch: 1 branch
BranchTrueFalseTotal
if (our $AUTOLOAD ne "Object::InsideOut::Metadata::new") 0 1 1
77 0 OIO::Method->die('message' => "Object::InsideOut::Metadata does not support AUTOLOAD of $AUTOLOAD",
78 'ignore_package' => 'Object::InsideOut::Metadata');
79 }
80  
81 # Workaround to get %METADATA into our scope
82 1 my $meta = \%METADATA;
83  
84 # Load the rest of our code
85 1 my $text = do { local $/; <DATA> };
86 1 close(DATA);
87 0 ▶ eval $text;
Subroutine BEGIN: called CC=1 SCAR=1.9
Subroutine BEGIN: called CC=1 SCAR=1.9
Subroutine BEGIN: called CC=1 SCAR=1.9
Subroutine _init: called CC=3 SCAR=15.9
Pod documented
Pod documented
Pod documented
Branch: 31 branches
BranchTrueFalseTotal
if (exists $herit->{$pkg}) 0 2 2
unless (builtin::blessed($self)) 0 0 0
if (my $ia = $GBL->{"args"}{$pkg}) 0 0 0
if $arg eq " " 0 0 0
if (ref $hash eq "HASH") 0 0 0
if ($hash->{"_F"}) 0 0 0
if ($hash->{"_M"}) 0 0 0
if (defined(my $def = $hash->{"_D"})) 0 0 0
if (my $pre = $hash->{"_P"}) 0 0 0
if (my $type = $hash->{"_T"}) 0 0 0
unless (ref $type) 0 0 0
if ($type =~ /^(.*)\((.+)\)$/i) 0 0 0
if ($subtype =~ /^num(?:ber|eric)?$/i) 0 0 0
if ($type =~ /^num(?:ber|eric)?$/i) { } 0 0 0
elsif ($type =~ /^(?:list|array)$/i) { } 0 0 0
elsif ($type =~ /^(array|hash)(?:_?ref)?$/i) { } 0 0 0
if ($subtype) 0 0 0
wantarray ? : 0 0 0
unless (builtin::blessed($self)) 0 0 0
wantarray ? : 0 0 0
unless (builtin::blessed($self)) 0 2 2
unless *{$pkg . '::' . $sym;}{"CODE"} 30 133 163
if $sym =~ /^[(_]/ 6 127 133
if $sym =~ /^(?:CLONE(?:_SKIP)?|DESTROY|import)$/ 10 117 127
if ($foreign) 0 117 117
if ($METADATA{$pkg}) 4 0 4
if ($METADATA{$pkg}{$meth}{"hidden"}) 82 26 108
if ($GBL->{"sub"}{"auto"}{$pkg}) 0 4 4
if $meth eq "AUTOLOAD" 0 35 35
if ($METADATA{$pkg}) 35 0 35
wantarray ? : 0 2 2
88 1 ▶ die if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
89  
90 # Continue on
91 1 goto &Object::InsideOut::new;
92 }
93  
94 } # End of package's lexical scope
95  
96 45 1;
97  
98 __DATA__
« Object/InsideOut/Cumulative.pm ↑ Summary Object/InsideOut/Dynamic.pm »