ModuleStore.pm

filter: Statementstmt 46.6% 14 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 39.5% 19 / 48 CC 5 SCAR 18.1
CC
5
Cov
36%
templates
12.0
_template_filehandle
7.1
BEGIN
1.0
CRAP 6.1
« InlineStore.pm ↑ Summary
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::ModuleStore;
5  
6 2 our $VERSION = '0.144';
7  
8 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Module::Starter::Plugin::ModuleStore -- store inline templates in modules
13  
14 =head1 VERSION
15  
16 version 0.144
17  
18 =head1 SYNOPSIS
19  
20 use Module::Starter qw(
21 Module::Starter::Simple
22 Module::Starter::Plugin::Template
23 Module::Starter::Plugin::ModuleStore
24 ...
25 );
26  
27 Module::Starter->create_distro( ... );
28  
29 =head1 DESCRIPTION
30  
31 This Module::Starter plugin is intended to be loaded after
32 Module::Starter::Plugin::Template. It implements the C<templates> method,
33 required by the Template plugin. It works like InlineStore, but instead of
34 loading a physical file, loads the DATA section of a Perl module.
35  
36 =cut
37  
38 =head1 METHODS
39  
40 =head2 C<< templates >>
41  
42 This method reads in the template module (described above) and populates the
43 object's C<templates> attribute. The module template module is found by
44 checking the MODULE_TEMPLATE_MODULE environment variable and then the
45 "template_module" config option.
46  
47 =cut
48  
49 0 ▶sub _template_filehandle {
Subroutine _template_filehandle: not called CC=3 SCAR=19.6
50 0 my $self = shift;
51  
52 my $template_module =
53 0 ▶ ($ENV{MODULE_TEMPLATE_MODULE} || $self->{template_module});
Condition0%0/3
$ENV{'MODULE_TEMPLATE_MODULE'} || $self->{'template_module'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'MODULE_TEMPLATE_MODULE'} || $self->{'template_module'}
$ENV{'MODULE_TEMPLATE_MODULE'} $self->{'template_module'}
Truth table0%0/3
A || B
A= $ENV{'MODULE_TEMPLATE_MODULE'}B= $self->{'template_module'}
ABresult
1X1
011
000
54 0 ▶ eval "require $template_module"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $template_module" or Carp::croak("couldn't load template store module ${template_module}: $@") 0 0 0
55 or Carp::croak "couldn't load template store module $template_module: $@";
56  
57 2 ▶ no strict 'refs'; ## no critic NoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
58 0 return \*{"$template_module\::DATA"};
59 }
60  
61 0 ▶sub templates {
Subroutine templates: not called CC=3 SCAR=24.8
Pod documented
62 0 my $self = shift;
63 0 my %template;
64
65 0 my $template_file = $self->_template_filehandle;
66  
67 0 my $fn = q{_};
68 0 ▶ while (<$template_file>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $template_file)) 0 0 0
69 0 ▶ if (/^___([-_.0-9A-Za-z]+)___$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^___([-_.0-9A-Za-z]+)___$/) 0 0 0
70 0 $fn = $1;
71 0 $template{$fn} = q{};
72 0 next;
73 }
74 0 $template{$fn} .= $_;
75 }
76  
77 0 return %template;
78 }
79  
80 =head1 AUTHOR
81  
82 Ricardo SIGNES, C<< <rjbs@cpan.org> >>
83  
84 =head1 Bugs
85  
86 Please report any bugs or feature requests to
87 C<bug-module-starter-plugin-inlinestore@rt.cpan.org>, or through the web
88 interface at L<http://rt.cpan.org>. I will be notified, and then you'll
89 automatically be notified of progress on your bug as I make changes.
90  
91 =head1 COPYRIGHT
92  
93 Copyright 2004 Ricardo SIGNES, All Rights Reserved.
94  
95 This program is free software; you can redistribute it and/or modify it
96 under the same terms as Perl itself.
97  
98 =cut
99  
100 2 1;
« InlineStore.pm ↑ Summary