File Coverage

blib/lib/Algorithm/Dependency/Item.pm
Criterion Covered Total %
statement 19 19 100.0
branch 1 2 50.0
condition 2 6 33.3
subroutine 8 8 100.0
pod 3 3 100.0
total 33 38 86.8


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<Algorithm::Dependency::Source> for details ).
15            
16             =head1 METHODS
17            
18             =cut
19              
20 8     8   153 use 5.005;
  8         74  
  8         72  
21 8     8   389 use strict;
  8         74  
  8         283  
22 8     8   120 use Algorithm::Dependency ();
  8         74  
  8         76  
23              
24 8     8   226 use vars qw{$VERSION};
  8         102  
  8         122  
25             BEGIN {
26 8     8   108 $VERSION = '1.102';
27             }
28              
29              
30              
31              
32              
33             #####################################################################
34             # Constructor
35              
36             =pod
37            
38             =head2 new $id, @depends
39            
40             The C<new> 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<Algorithm::Dependency::Item> on success, or C<undef>
45             on error.
46            
47             =cut
48              
49             sub new {
50 100     100 1 3537 my $class = shift;
51 100 50 33     1539 my $id = (defined $_[0] and ! ref $_[0] and $_[0] ne '') ? shift : return undef;
      33        
52 100         2518 bless { id => $id, depends => [ @_ ] }, $class;
53             }
54              
55             =pod
56            
57             =head2 id
58            
59             The C<id> method returns the id of the item.
60            
61             =cut
62              
63 111     111 1 1793 sub id { $_[0]->{id} }
64              
65             =pod
66            
67             =head2 depends
68            
69             The C<depends> 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 9256 sub depends { @{$_[0]->{depends}} }
  867         12432  
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<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Dependency>
88            
89             =head1 AUTHOR
90            
91             Adam Kennedy E<lt>cpan@ali.asE<gt>, L<http://ali.as/>
92            
93             =head1 SEE ALSO
94            
95             L<Algorithm::Dependency>
96            
97             =head1 COPYRIGHT
98            
99             Copyright (c) 2003 - 2005 Adam Kennedy. All rights reserved.
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
108