File Coverage

blib/lib/Algorithm/Dependency/Item.pm
Criterion Covered Total %
statement 19 19 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 8 8 100.0
pod 3 3 100.0
total 32 35 91.4


line stmt bran cond sub pod time code
1             package Algorithm::Dependency::Item;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Algorithm::Dependency::Item - Implements an item in a dependency heirachy.
8              
9             =head1 DESCRIPTION
10              
11             The Algorithm::Dependency::Item class implements a single item within the
12             dependency heirachy. It's quite simple, usually created from within a source,
13             and not typically created directly. This is provided for those implementing
14             their own source. ( See L for details ).
15              
16             =head1 METHODS
17              
18             =cut
19              
20 8     8   143 use 5.005;
  8         26  
  8         14575  
21 8     8   47 use strict;
  8         16  
  8         238  
22 8     8   43 use Algorithm::Dependency ();
  8         17  
  8         158  
23              
24 8     8   51 use vars qw{$VERSION};
  8         60  
  8         440  
25             BEGIN {
26 8     8   1648 $VERSION = '1.110';
27             }
28              
29              
30              
31              
32              
33             #####################################################################
34             # Constructor
35              
36             =pod
37              
38             =head2 new $id, @depends
39              
40             The C constructor takes as its first argument the id ( name ) of the
41             item, and any further arguments are assumed to be the ids of other items that
42             this one depends on.
43              
44             Returns a new C on success, or C
45             on error.
46              
47             =cut
48              
49             sub new {
50 100     100 1 112 my $class = shift;
51 100 50 33     581 my $id = (defined $_[0] and ! ref $_[0] and $_[0] ne '') ? shift : return undef;
52 100         677 bless { id => $id, depends => [ @_ ] }, $class;
53             }
54              
55             =pod
56              
57             =head2 id
58              
59             The C method returns the id of the item.
60              
61             =cut
62              
63 111     111 1 1543 sub id { $_[0]->{id} }
64              
65             =pod
66              
67             =head2 depends
68              
69             The C method returns, as a list, the names of the other items that
70             this item depends on.
71              
72             =cut
73              
74 867     867 1 847 sub depends { @{$_[0]->{depends}} }
  867         2855  
75              
76             1;
77              
78             =pod
79              
80             =head1 SUPPORT
81              
82             For general comments, contact the author.
83              
84             To file a bug against this module, in a way you can keep track of, see the
85             CPAN bug tracking system.
86              
87             L
88              
89             =head1 AUTHOR
90              
91             Adam Kennedy Eadamk@cpan.orgE
92              
93             =head1 SEE ALSO
94              
95             L
96              
97             =head1 COPYRIGHT
98              
99             Copyright 2003 - 2009 Adam Kennedy.
100              
101             This program is free software; you can redistribute
102             it and/or modify it under the same terms as Perl itself.
103              
104             The full text of the license can be found in the
105             LICENSE file included with this module.
106              
107             =cut