File Coverage

blib/lib/JavaScript/Librarian/Book.pm
Criterion Covered Total %
statement 10 21 47.6
branch 0 10 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 1 2 50.0
total 15 42 35.7


line stmt bran cond sub pod time code
1             package JavaScript::Librarian::Book;
2              
3             # A fairly trivial subclass of Algorithm::Dependency::Item, which is also
4             # required to implement the ->path method, which returns the relative
5             # path of the actual .js file within the base path.
6              
7 1     1   5 use strict;
  1         2  
  1         32  
8 1     1   4 use base 'Algorithm::Dependency::Item';
  1         1  
  1         83  
9              
10 1     1   5 use vars qw{$VERSION};
  1         2  
  1         31  
11             BEGIN {
12 1     1   135 $VERSION = '1.00';
13             }
14              
15              
16              
17              
18              
19             #####################################################################
20             # Constructor and Accessors
21              
22             # Implement a more complex constructor that will allow the use of ANY
23             # hash of values, as long as after creation, ->id, ->depends and ->path
24             # all return correctly.
25             sub new {
26 0     0 1   my $class = shift;
27 0 0         my %hash = ref $_[0] eq 'HASH' ? %{shift()} : return undef;
  0            
28              
29             # Create the object
30 0           my $self = bless \%hash, $class;
31              
32             # Do our methods all behave correctly
33 0 0         $self->id or return undef;
34 0 0         $self->path or return undef;
35 0 0 0       if ( grep { ! defined $_ or ref $_ or $_ eq '' } $self->depends ) {
  0 0          
36 0           return undef;
37             }
38              
39 0           $self;
40             }
41              
42 0     0 0   sub path { $_[0]->{path} }
43              
44             1;