File Coverage

blib/lib/Harriet.pm
Criterion Covered Total %
statement 9 23 39.1
branch 0 8 0.0
condition n/a
subroutine 3 6 50.0
pod 0 3 0.0
total 12 40 30.0


line stmt bran cond sub pod time code
1             package Harriet;
2 1     1   816 use 5.008005;
  1         4  
  1         39  
3 1     1   6 use strict;
  1         2  
  1         37  
4 1     1   15 use warnings;
  1         2  
  1         397  
5              
6             our $VERSION = "0.04";
7              
8             sub new {
9 0     0 0   my ($class, $dir) = @_;
10 0           bless {dir => $dir}, $class;
11             }
12              
13             sub load {
14 0     0 0   my ($self, $name) = @_;
15 0 0         return if $self->{loaded}->{$name}++;
16              
17 0           my $file = "$self->{dir}/${name}.pl";
18              
19 0           my $retval = do $file;
20 0 0         if ($@) {
21 0           die "[Harriet] Couldn't parse $file: $@\n";
22             }
23             }
24              
25             sub load_all {
26 0     0 0   my ($self) = @_;
27              
28 0 0         opendir my $dh, $self->{dir}
29             or die "[Harriet] Cannot open '$self->{dir}' as directory: $!\n";
30 0           while (my $file = readdir($dh)) {
31 0 0         next unless $file =~ /^(.*)\.pl$/;
32 0           my $name = $1;
33 0           $self->load($name);
34             }
35             }
36              
37             1;
38             __END__