| line | stmt | bran | cond | sub | pod | time | code | 
| 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 implements a | 
| 21 |  |  |  |  |  |  | #pod L where the items names are provided | 
| 22 |  |  |  |  |  |  | #pod in the most simple form, a reference to a C of C references. | 
| 23 |  |  |  |  |  |  | #pod | 
| 24 |  |  |  |  |  |  | #pod =head1 METHODS | 
| 25 |  |  |  |  |  |  | #pod | 
| 26 |  |  |  |  |  |  | #pod This documents the methods differing from the ordinary | 
| 27 |  |  |  |  |  |  | #pod L methods. | 
| 28 |  |  |  |  |  |  | #pod | 
| 29 |  |  |  |  |  |  | #pod =cut | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 3 |  |  | 3 |  | 1795 | use 5.005; | 
|  | 3 |  |  |  |  | 10 |  | 
| 32 | 3 |  |  | 3 |  | 17 | use strict; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 58 |  | 
| 33 | 3 |  |  | 3 |  | 15 | use Algorithm::Dependency::Source (); | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 52 |  | 
| 34 | 3 |  |  | 3 |  | 23 | use Params::Util qw{_HASH _ARRAY0}; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 834 |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | our $VERSION = '1.111'; | 
| 37 |  |  |  |  |  |  | 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 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 if the structure is not correct. | 
| 52 |  |  |  |  |  |  | #pod | 
| 53 |  |  |  |  |  |  | #pod =cut | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | sub new { | 
| 56 | 1 |  |  | 1 | 1 | 123 | my $class = shift; | 
| 57 | 1 | 50 |  |  |  | 8 | my $hash  = _HASH(shift) or return undef; | 
| 58 | 1 |  |  |  |  | 5 | foreach my $deps ( values %$hash ) { | 
| 59 | 6 | 50 |  |  |  | 15 | _ARRAY0($deps) or return undef; | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | # Get the basic source object | 
| 63 | 1 | 50 |  |  |  | 8 | my $self = $class->SUPER::new() or return undef; | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | # Add our arguments | 
| 66 | 1 |  |  |  |  | 3 | $self->{hash} = $hash; | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 1 |  |  |  |  | 3 | $self; | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | ##################################################################### | 
| 76 |  |  |  |  |  |  | # Private Methods | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | sub _load_item_list { | 
| 79 | 1 |  |  | 1 |  | 2 | my $self = shift; | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | # Build the item objects from the data | 
| 82 | 1 |  |  |  |  | 2 | my $hash  = $self->{hash}; | 
| 83 |  |  |  |  |  |  | my @items = map { | 
| 84 | 1 | 50 |  |  |  | 4 | Algorithm::Dependency::Item->new( $_, @{$hash->{$_}} ) | 
|  | 6 |  |  |  |  | 10 |  | 
|  | 6 |  |  |  |  | 20 |  | 
| 85 |  |  |  |  |  |  | or return undef; | 
| 86 |  |  |  |  |  |  | } keys %$hash; | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 1 |  |  |  |  | 4 | \@items; | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | 1; | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | __END__ |