| 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::InlineStore; | ||||||||||||||||||||||||||||
| 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::InlineStore -- inline module template files | ||||||||||||||||||||||||||||
| 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::InlineStore | ||||||||||||||||||||||||||||
| 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. The C<InlineStore> plugin stores all the | ||||||||||||||||||||||||||||
| 34 | required templates in a single file, delimited with filenames between | ||||||||||||||||||||||||||||
| 35 | triple-underscores. In other words, a very simple template file might look | ||||||||||||||||||||||||||||
| 36 | like this: | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | ___Module.pm___ | ||||||||||||||||||||||||||||
| 39 | package {modulename}; | ||||||||||||||||||||||||||||
| 40 | 1; | ||||||||||||||||||||||||||||
| 41 | ___Makefile.PL___ | ||||||||||||||||||||||||||||
| 42 | die "lousy template" | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | Originally, this module was to use Inline::Files, or at least standard | ||||||||||||||||||||||||||||
| 45 | double-underscore indication of file names, but it's just simpler this way. | ||||||||||||||||||||||||||||
| 46 | Patches welcome. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =cut | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 METHODS | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head2 C<< templates >> | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | This method reads in the template file (described above) and populates the | ||||||||||||||||||||||||||||
| 55 | object's C<templates> attribute. The module template file is found by checking | ||||||||||||||||||||||||||||
| 56 | the MODULE_TEMPLATE_FILE environment variable and then the "template_file" | ||||||||||||||||||||||||||||
| 57 | config option. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =cut | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub _template_filehandle { | ||||||||||||||||||||||||||
|
Subroutine
_template_filehandle: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | my $template_filename = | ||||||||||||||||||||||||||||
| 65 | ($ENV{MODULE_TEMPLATE_FILE} || $self->{template_file}) | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | or Carp::croak "no template file defined"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{'MODULE_TEMPLATE_FILE'} || $self->{'template_file'}
MC/DC0%0/2
$ENV{'MODULE_TEMPLATE_FILE'} || $self->{'template_file'}
$ENV{'MODULE_TEMPLATE_FILE'}
$self->{'template_file'}
Truth table0%0/3
A || B
A= $ENV{'MODULE_TEMPLATE_FILE'}B= $self->{'template_file'}
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | open my $template_file, '<', $template_filename | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | or Carp::croak "couldn't open template file: $template_filename"; | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | return $template_file; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub templates { | ||||||||||||||||||||||||||
|
Subroutine
templates: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 75 | 0 | my %template; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my $template_file = $self->_template_filehandle; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | my $fn = '_'; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | while (<$template_file>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (/^___([-_.0-9A-Za-z]+)___$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | $fn = $1; | |||||||||||||||||||||||||||
| 83 | 0 | $template{$fn} = q{}; | |||||||||||||||||||||||||||
| 84 | 0 | next; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 0 | $template{$fn} .= $_; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | return %template; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Ricardo SIGNES, C<< <rjbs@cpan.org> >> | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head1 Bugs | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||
| 99 | C<bug-module-starter-plugin-inlinestore@rt.cpan.org>, or through the web | ||||||||||||||||||||||||||||
| 100 | interface at L<http://rt.cpan.org>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 101 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | Copyright 2004 Ricardo SIGNES, All Rights Reserved. | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 108 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =cut | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 2 | 1; | |||||||||||||||||||||||||||