Dependency/Source/HoA.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 88.3% 38 / 43 CC 6 SCAR 11.4
CC
6
Cov
89%
new
5.3
_load_item_list
2.0
BEGIN
1.0
CRAP 3.1
« Dependency.pm ↑ Summary Dependency/Weight.pm »
1 package Algorithm::Dependency::Source::HoA;
2 # ABSTRACT: Source for a HASH of ARRAYs
3  
4 #pod =pod
5 #pod
6 #pod =head1 SYNOPSIS
7 #pod
8 #pod # The basic data structure
9 #pod my $deps = {
10 #pod foo => [ 'bar', 'baz' ],
11 #pod bar => [],
12 #pod baz => [ 'bar' ],
13 #pod };
14 #pod
15 #pod # Create the source from it
16 #pod my $Source = Algorithm::Dependency::Source::HoA->new( $deps );
17 #pod
18 #pod =head1 DESCRIPTION
19 #pod
20 #pod C<Algorithm::Dependency::Source::HoA> implements a
21 #pod L<source|Algorithm::Dependency::Source> where the items names are provided
22 #pod in the most simple form, a reference to a C<HASH> of C<ARRAY> references.
23 #pod
24 #pod =head1 METHODS
25 #pod
26 #pod This documents the methods differing from the ordinary
27 #pod L<Algorithm::Dependency::Source> methods.
28 #pod
29 #pod =cut
30  
31 3 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 3 ▶use Algorithm::Dependency::Source ();
Subroutine BEGIN: called CC=1 SCAR=0.0
34 3 ▶use Params::Util qw{_HASH _ARRAY0};
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 3 our $VERSION = '1.112';
37 3 our @ISA = 'Algorithm::Dependency::Source';
38  
39  
40 #####################################################################
41 # Constructor
42  
43 #pod =pod
44 #pod
45 #pod =head2 new $filename
46 #pod
47 #pod When constructing a new C<Algorithm::Dependency::Source::HoA> object, an
48 #pod argument should be provided of a reference to a HASH of ARRAY references,
49 #pod containing the names of other HASH elements.
50 #pod
51 #pod Returns the object, or C<undef> if the structure is not correct.
52 #pod
53 #pod =cut
54  
55 1 ▶sub new {
Subroutine new: called CC=5 SCAR=16.7
Pod documented
56 1 my $class = shift;
57 1 ▶ my $hash = _HASH(shift) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $hash = &_HASH(shift()) or return undef 1 0 1
58 1 foreach my $deps ( values %$hash ) {
59 6 ▶ _ARRAY0($deps) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
&_ARRAY0($deps) or return undef 6 0 6
60 }
61  
62 # Get the basic source object
63 1 ▶ my $self = $class->SUPER::new() or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = $class->SUPER::new or return undef 1 0 1
64  
65 # Add our arguments
66 1 $self->{hash} = $hash;
67  
68 1 $self;
69 }
70  
71  
72  
73  
74  
75 #####################################################################
76 # Private Methods
77  
78 1 ▶sub _load_item_list {
Subroutine _load_item_list: called CC=2 SCAR=7.0
79 1 my $self = shift;
80  
81 # Build the item objects from the data
82 1 my $hash = $self->{hash};
83 my @items = map {
84 1 ▶ Algorithm::Dependency::Item->new( $_, @{$hash->{$_}} )
Condition50%1/2
'Algorithm::Dependency::Item'->new($_, @{$$hash{$_};}) || (return undef)
l!l
60
MC/DC0%0/1
'Algorithm::Dependency::Item'->new($_, @{$$hash{$_};}) || (return undef)
'Algorithm::Dependency::Item'->new($_, @{$$hash{$_};})
Truth table50%1/2
A
A= 'Algorithm::Dependency::Item'->new($_, @{$$hash{$_};})
Aresult
11
00
85 or return undef;
86 } keys %$hash;
87  
88 1 \@items;
89 }
90  
91 3 1;
92  
93 __END__
« Dependency.pm ↑ Summary Dependency/Weight.pm »