DirStore.pm

filter: Statementstmt 58.6% 17 / 29 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 42.5% 23 / 54 CC 8 SCAR 35.2
CC
8
Cov
40%
templates
54.1
BEGIN
1.0
BEGIN
1.0
CRAP 33.7
↑ Summary InlineStore.pm »
1 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Module::Starter::Plugin::DirStore;
5  
6 2 our $VERSION = '0.144';
7  
8 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 Module::Starter::Plugin::DirStore -- module template files in a directory
14  
15 =head1 VERSION
16  
17 version 0.144
18  
19 =head1 SYNOPSIS
20  
21 use Module::Starter qw(
22 Module::Starter::Simple
23 Module::Starter::Plugin::Template
24 Module::Starter::Plugin::DirStore
25 ...
26 );
27  
28 Module::Starter->create_distro( ... );
29  
30 =head1 DESCRIPTION
31  
32 This Module::Starter plugin is intended to be loaded after
33 Module::Starter::Plugin::Template. It implements the C<templates> method,
34 required by the Template plugin. The C<DirStore> plugin stores all the
35 required templates as files in a directory.
36  
37 =cut
38  
39 =head1 METHODS
40  
41 =head2 C<< templates >>
42  
43 This method reads in the template files and populates the object's C<templates>
44 attribute. The module template directory is found by checking the
45 MODULE_TEMPLATE_DIR environment variable and then the config option
46 "template_dir".
47  
48 =cut
49  
50 0 ▶sub templates {
Subroutine templates: not called CC=8 SCAR=39.9
Pod documented
51 0 my $self = shift;
52 0 my %template;
53  
54 my $template_dir = ($ENV{MODULE_TEMPLATE_DIR} || $self->{template_dir})
55 0 ▶ or Carp::croak "template dir not defined";
Branch: 1 branch
BranchTrueFalseTotal
my $template_dir = $ENV{"MODULE_TEMPLATE_DIR"} || $self->{"template_dir"} or Carp::croak("template dir not defined") 0 0 0
Condition0%0/3
$ENV{'MODULE_TEMPLATE_DIR'} || $self->{'template_dir'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'MODULE_TEMPLATE_DIR'} || $self->{'template_dir'}
$ENV{'MODULE_TEMPLATE_DIR'} $self->{'template_dir'}
Truth table0%0/3
A || B
A= $ENV{'MODULE_TEMPLATE_DIR'}B= $self->{'template_dir'}
ABresult
1X1
011
000
56 0 ▶ Carp::croak "template dir does not exist: $template_dir"
Branch: 1 branch
BranchTrueFalseTotal
unless -d $template_dir 0 0 0
57 unless -d $template_dir;
58  
59 0 ▶ foreach (glob "$template_dir/*") {
Subroutine BEGIN: called CC=1 SCAR=0.2
60 0 my $basename = basename $_;
61 0 ▶ next if (not -f $_) or ($basename =~ /^\./);
Branch: 1 branch
BranchTrueFalseTotal
if not -f $_ or $basename =~ /^\./ 0 0 0
Condition0%0/3
not -f $_ or $basename =~ /^\./
l!l&&r!l&&!r
000
MC/DC0%0/2
not -f $_ or $basename =~ /^\./
not -f $_ $basename =~ /^\./
Truth table0%0/3
not(A) or B
A= not -f $_B= $basename =~ /^\./
ABresult
1X1
011
000
62 0 ▶ open my $template_file, '<', $_
Branch: 1 branch
BranchTrueFalseTotal
open my $template_file, "<", $_ or Carp::croak("couldn't open template: $_") 0 0 0
63 or Carp::croak "couldn't open template: $_";
64 0 $template{$basename} = do {
65 0 local $/ = undef;
66 0 <$template_file>;
67 };
68 }
69  
70 0 return %template;
71 }
72  
73 =head1 AUTHOR
74  
75 Ricardo SIGNES, C<< <rjbs@cpan.org> >>
76  
77 =head1 Bugs
78  
79 Please report any bugs or feature requests to
80 C<bug-module-starter-plugin-inlinestore@rt.cpan.org>, or through the web
81 interface at L<http://rt.cpan.org>. I will be notified, and then you'll
82 automatically be notified of progress on your bug as I make changes.
83  
84 =head1 COPYRIGHT
85  
86 Copyright 2004 Ricardo SIGNES, All Rights Reserved.
87  
88 This program is free software; you can redistribute it and/or modify it
89 under the same terms as Perl itself.
90  
91 =cut
92  
93 2 1;
↑ Summary InlineStore.pm »