File Coverage

blib/lib/Algorithm/Dependency/Item.pm
Criterion Covered Total %
statement 14 14 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 3 3 100.0
total 25 28 89.2


line stmt bran cond sub pod time code
1             package Algorithm::Dependency::Item;
2             # ABSTRACT: Implements an item in a dependency hierarchy.
3              
4             #pod =pod
5             #pod
6             #pod =head1 DESCRIPTION
7             #pod
8             #pod The Algorithm::Dependency::Item class implements a single item within the
9             #pod dependency hierarchy. It's quite simple, usually created from within a source,
10             #pod and not typically created directly. This is provided for those implementing
11             #pod their own source. ( See L for details ).
12             #pod
13             #pod =head1 METHODS
14             #pod
15             #pod =cut
16              
17 8     8   143 use 5.005;
  8         30  
18 8     8   42 use strict;
  8         16  
  8         165  
19 8     8   39 use Algorithm::Dependency ();
  8         28  
  8         1308  
20              
21             our $VERSION = '1.111';
22              
23              
24             #####################################################################
25             # Constructor
26              
27             #pod =pod
28             #pod
29             #pod =head2 new $id, @depends
30             #pod
31             #pod The C constructor takes as its first argument the id ( name ) of the
32             #pod item, and any further arguments are assumed to be the ids of other items that
33             #pod this one depends on.
34             #pod
35             #pod Returns a new C on success, or C
36             #pod on error.
37             #pod
38             #pod =cut
39              
40             sub new {
41 100     100 1 160 my $class = shift;
42 100 50 33     447 my $id = (defined $_[0] and ! ref $_[0] and $_[0] ne '') ? shift : return undef;
43 100         456 bless { id => $id, depends => [ @_ ] }, $class;
44             }
45              
46             #pod =pod
47             #pod
48             #pod =head2 id
49             #pod
50             #pod The C method returns the id of the item.
51             #pod
52             #pod =cut
53              
54 111     111 1 1578 sub id { $_[0]->{id} }
55              
56             #pod =pod
57             #pod
58             #pod =head2 depends
59             #pod
60             #pod The C method returns, as a list, the names of the other items that
61             #pod this item depends on.
62             #pod
63             #pod =cut
64              
65 867     867 1 1246 sub depends { @{$_[0]->{depends}} }
  867         2194  
66              
67             1;
68              
69             __END__