| 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<Algorithm::Dependency::Source> for details ). | ||||||||||||||||||||||||||||||||||||||||||
| 12 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 13 | #pod =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 14 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 15 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use 5.005; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | use Algorithm::Dependency (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | our $VERSION = '1.112'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # Constructor | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | #pod =pod | ||||||||||||||||||||||||||||||||||||||||||
| 28 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 29 | #pod =head2 new $id, @depends | ||||||||||||||||||||||||||||||||||||||||||
| 30 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 31 | #pod The C<new> 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<Algorithm::Dependency::Item> on success, or C<undef> | ||||||||||||||||||||||||||||||||||||||||||
| 36 | #pod on error. | ||||||||||||||||||||||||||||||||||||||||||
| 37 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 38 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 100 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 100 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 100 | ▶ | my $id = (defined $_[0] and ! ref $_[0] and $_[0] ne '') ? shift : return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $_[0] and not ref $_[0] and $_[0] ne ""
defined $_[0] and not ref $_[0]
MC/DC0%0/3
defined $_[0] and not ref $_[0] and $_[0] ne ""
defined $_[0]
not ref $_[0]
$_[0] ne ""
Truth table25%1/4
A and not(B) and C
A= defined $_[0]B= not ref $_[0]C= $_[0] ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 100 | bless { id => $id, depends => [ @_ ] }, $class; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | #pod =pod | ||||||||||||||||||||||||||||||||||||||||||
| 47 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 48 | #pod =head2 id | ||||||||||||||||||||||||||||||||||||||||||
| 49 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 50 | #pod The C<id> method returns the id of the item. | ||||||||||||||||||||||||||||||||||||||||||
| 51 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 52 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 111 | ▶ | sub id { $_[0]->{id} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | #pod =pod | ||||||||||||||||||||||||||||||||||||||||||
| 57 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 58 | #pod =head2 depends | ||||||||||||||||||||||||||||||||||||||||||
| 59 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 60 | #pod The C<depends> 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 | ▶ | sub depends { @{$_[0]->{depends}} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
depends: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||||||||||||||||