File Coverage

blib/lib/App/Module/Template/Initialize.pm
Criterion Covered Total %
statement 55 55 100.0
branch 20 20 100.0
condition 6 6 100.0
subroutine 13 13 100.0
pod 1 1 100.0
total 95 95 100.0


line stmt bran cond sub pod time code
1             package App::Module::Template::Initialize;
2              
3 25     25   7296 use strict;
  25         46  
  25         844  
4 25     25   123 use warnings;
  25         48  
  25         1146  
5              
6             our $VERSION = '0.11';
7              
8 25     25   128 use base qw(Exporter);
  25         42  
  25         1904  
9              
10 25     25   737 use Carp;
  25         63  
  25         4998  
11 25     25   141 use File::Path qw/make_path/;
  25         45  
  25         1513  
12 25     25   97730 use File::HomeDir;
  25         172472  
  25         1689  
13 25     25   896 use File::Spec;
  25         646  
  25         27197  
14              
15             our (@EXPORT_OK, %EXPORT_TAGS);
16              
17             @EXPORT_OK = qw(
18             module_template
19             _get_tmpl_body
20             _get_tmpl_file
21             _get_tmpl_path
22             _make_tmpl_path
23             _write_tmpl_file
24             ); # on demand
25             %EXPORT_TAGS = (
26             ALL => [ @EXPORT_OK ],
27             );
28              
29             =pod
30              
31             =head1 NAME
32              
33             App::Module::Template::Initialize - Templates to pre-populate template directory
34              
35             =head1 VERSION
36              
37             This documentation refers to App::Module::Template::Initialize version 0.11.
38              
39             =head1 SYNOPSIS
40              
41             use App::Module::Template::Initialize qw/module_template/;
42              
43             module_template($path);
44              
45             =head1 DESCRIPTION
46              
47             App::Module::Template::Initialize contains the templates and method to initialize the .module-templates/templates directory for use by module-template.
48              
49             See module-template for configuration and usage.
50              
51             =head1 SUBROUTINES/METHODS
52              
53             =over
54              
55             =item C
56              
57             This subroutine iterates the templates and creates files and directories in $HOME/.module-template.
58              
59             =back
60              
61             =head1 DIAGNOSTICS
62              
63             None.
64              
65             =head1 CONFIGURATION AND ENVIRONMENT
66              
67             None.
68              
69             =head1 DEPENDENCIES
70              
71             =over
72              
73             =item * Carp
74              
75             =item * File::Path
76              
77             =item * File::HomeDir
78              
79             =item * File::Spec
80              
81             =back
82              
83             =head1 INCOMPATIBILITIES
84              
85             None reported.
86              
87             =head1 BUGS AND LIMITATIONS
88              
89             No bugs have been reported.
90              
91             Please report any issues or feature requests to L. Patches are welcome.
92              
93             =head1 AUTHOR
94              
95             Trevor S. Cornpropst
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             Copyright (c) 2014 Trevor S. Cornpropst . All rights reserved.
100              
101             This program is free software; you can redistribute it and/or modify it
102             under the terms of the the Artistic License (2.0). You may obtain a
103             copy of the full license at:
104              
105             L
106              
107             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
108             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
109             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
110             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
111             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
112             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
113             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
114             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115              
116             =cut
117              
118              
119             our $TEMPLATES = {
120             config => {
121             file => 'config',
122             path => '.module-template',
123             body => <<'END_OF_BODY',
124             author = Default Author
125             email = author@example.com
126             support_address = support@example.com
127             min_perl_version = 5.016
128             eumm_version = 6.63
129             license_type = artistic_2
130             license_body =<
131             This program is free software; you can redistribute it and/or modify it
132             under the terms of the the Artistic License (2.0). You may obtain a
133             copy of the full license at:
134              
135             L
136              
137             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
138             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
139             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
140             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
141             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
142             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
143             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
144             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145             END_OF_LICENSE
146              
147            
148             PRE_CHOMP = 0
149             POST_CHOMP = 0
150             ENCODING = utf8
151             ABSOLUTE = 1
152             RELATIVE = 1
153            
154             END_OF_BODY
155             },
156             gitignore => {
157             file => '.gitignore',
158             path => '.module-template/templates',
159             body => <<'END_OF_BODY',
160             /blib/
161             /.build/
162             _build/
163             cover_db/
164             inc/
165             Build
166             !Build/
167             Build.bat
168             .last_cover_stats
169             /Makefile
170             /Makefile.old
171             /MANIFEST.bak
172             /META.yml
173             /META.json
174             /MYMETA.*
175             nytprof.out
176             /pm_to_blib
177             *.o
178             *.bs
179             *.swp
180             END_OF_BODY
181             },
182             travis_yml => {
183             file => '.travis.yml',
184             path => '.module-template/templates',
185             body => <<'END_OF_BODY',
186             language: perl
187             perl:
188             - "5.20"
189             - "5.18"
190             - "5.16"
191              
192             before_install:
193             - cpanm --quiet --notest Devel::Cover::Report::Coveralls
194              
195             install:
196             - cpanm --quiet --notest --installdeps .
197              
198             script:
199             - PERL5OPT=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine prove -l t
200             - cover
201              
202             after_success:
203             - cover -report coveralls
204             END_OF_BODY
205             },
206             makefile_pl => {
207             file => 'Makefile.PL',
208             path => '.module-template/templates',
209             body => <<'END_OF_BODY',
210             use strict;
211             use warnings;
212              
213             use [% min_perl_version %];
214              
215             use ExtUtils::MakeMaker [% eumm_version %];
216              
217             my %WriteMakefileArgs = (
218             NAME => '[% module %]',
219             AUTHOR => '[% author %] <[% email %]>',
220             VERSION_FROM => '[% module_path %]',
221             ABSTRACT_FROM => '[% module_path %]',
222             LICENSE => '[% license_type %]',
223             DISTNAME => '[% dist %]',
224             MIN_PERL_VERSION => [% min_perl_version %],
225             BUILD_REQUIRES => {
226             'ExtUtils::MakeMaker' => [% eumm_version %],
227             },
228             CONFIGURE_REQUIRES => {
229             'ExtUtils::MakeMaker' => [% eumm_version %],
230             },
231             PREREQ_PM => {
232             'Carp' => 0,
233             'POSIX' => 0,
234             #'Some::Module' => 1.23,
235             },
236             TEST_REQUIRES => {
237             'Test::More' => 0,
238             'Test::Exception' => 0,
239             },
240             test => { "TESTS" => "t/*.t", },
241             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
242             clean => { FILES => '-*' },
243             );
244              
245             my %FallbackPrereqs = (
246             'Carp' => 0,
247             'POSIX' => 0,
248             );
249              
250             unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
251             delete $WriteMakefileArgs{TEST_REQUIRES};
252             delete $WriteMakefileArgs{BUILD_REQUIRES};
253             $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
254             }
255              
256             delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
257             unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
258              
259             WriteMakefile(%WriteMakefileArgs);
260             END_OF_BODY
261             },
262             license => {
263             file => 'LICENSE',
264             path => '.module-template/templates',
265             body => <<'END_OF_BODY',
266             The Artistic License 2.0
267              
268             Copyright (c) [% year %] [% author %]
269              
270             Everyone is permitted to copy and distribute verbatim copies
271             of this license document, but changing it is not allowed.
272              
273             Preamble
274              
275             This license establishes the terms under which a given free software
276             Package may be copied, modified, distributed, and/or redistributed.
277             The intent is that the Copyright Holder maintains some artistic
278             control over the development of that Package while still keeping the
279             Package available as open source and free software.
280              
281             You are always permitted to make arrangements wholly outside of this
282             license directly with the Copyright Holder of a given Package. If the
283             terms of this license do not permit the full use that you propose to
284             make of the Package, you should contact the Copyright Holder and seek
285             a different licensing arrangement.
286              
287             Definitions
288              
289             "Copyright Holder" means the individual(s) or organization(s)
290             named in the copyright notice for the entire Package.
291              
292             "Contributor" means any party that has contributed code or other
293             material to the Package, in accordance with the Copyright Holder's
294             procedures.
295              
296             "You" and "your" means any person who would like to copy,
297             distribute, or modify the Package.
298              
299             "Package" means the collection of files distributed by the
300             Copyright Holder, and derivatives of that collection and/or of
301             those files. A given Package may consist of either the Standard
302             Version, or a Modified Version.
303              
304             "Distribute" means providing a copy of the Package or making it
305             accessible to anyone else, or in the case of a company or
306             organization, to others outside of your company or organization.
307              
308             "Distributor Fee" means any fee that you charge for Distributing
309             this Package or providing support for this Package to another
310             party. It does not mean licensing fees.
311              
312             "Standard Version" refers to the Package if it has not been
313             modified, or has been modified only in ways explicitly requested
314             by the Copyright Holder.
315              
316             "Modified Version" means the Package, if it has been changed, and
317             such changes were not explicitly requested by the Copyright
318             Holder.
319              
320             "Original License" means this Artistic License as Distributed with
321             the Standard Version of the Package, in its current version or as
322             it may be modified by The Perl Foundation in the future.
323              
324             "Source" form means the source code, documentation source, and
325             configuration files for the Package.
326              
327             "Compiled" form means the compiled bytecode, object code, binary,
328             or any other form resulting from mechanical transformation or
329             translation of the Source form.
330              
331              
332             Permission for Use and Modification Without Distribution
333              
334             (1) You are permitted to use the Standard Version and create and use
335             Modified Versions for any purpose without restriction, provided that
336             you do not Distribute the Modified Version.
337              
338              
339             Permissions for Redistribution of the Standard Version
340              
341             (2) You may Distribute verbatim copies of the Source form of the
342             Standard Version of this Package in any medium without restriction,
343             either gratis or for a Distributor Fee, provided that you duplicate
344             all of the original copyright notices and associated disclaimers. At
345             your discretion, such verbatim copies may or may not include a
346             Compiled form of the Package.
347              
348             (3) You may apply any bug fixes, portability changes, and other
349             modifications made available from the Copyright Holder. The resulting
350             Package will still be considered the Standard Version, and as such
351             will be subject to the Original License.
352              
353              
354             Distribution of Modified Versions of the Package as Source
355              
356             (4) You may Distribute your Modified Version as Source (either gratis
357             or for a Distributor Fee, and with or without a Compiled form of the
358             Modified Version) provided that you clearly document how it differs
359             from the Standard Version, including, but not limited to, documenting
360             any non-standard features, executables, or modules, and provided that
361             you do at least ONE of the following:
362              
363             (a) make the Modified Version available to the Copyright Holder
364             of the Standard Version, under the Original License, so that the
365             Copyright Holder may include your modifications in the Standard
366             Version.
367              
368             (b) ensure that installation of your Modified Version does not
369             prevent the user installing or running the Standard Version. In
370             addition, the Modified Version must bear a name that is different
371             from the name of the Standard Version.
372              
373             (c) allow anyone who receives a copy of the Modified Version to
374             make the Source form of the Modified Version available to others
375             under
376              
377             (i) the Original License or
378              
379             (ii) a license that permits the licensee to freely copy,
380             modify and redistribute the Modified Version using the same
381             licensing terms that apply to the copy that the licensee
382             received, and requires that the Source form of the Modified
383             Version, and of any works derived from it, be made freely
384             available in that license fees are prohibited but Distributor
385             Fees are allowed.
386              
387              
388             Distribution of Compiled Forms of the Standard Version
389             or Modified Versions without the Source
390              
391             (5) You may Distribute Compiled forms of the Standard Version without
392             the Source, provided that you include complete instructions on how to
393             get the Source of the Standard Version. Such instructions must be
394             valid at the time of your distribution. If these instructions, at any
395             time while you are carrying out such distribution, become invalid, you
396             must provide new instructions on demand or cease further distribution.
397             If you provide valid instructions or cease distribution within thirty
398             days after you become aware that the instructions are invalid, then
399             you do not forfeit any of your rights under this license.
400              
401             (6) You may Distribute a Modified Version in Compiled form without
402             the Source, provided that you comply with Section 4 with respect to
403             the Source of the Modified Version.
404              
405              
406             Aggregating or Linking the Package
407              
408             (7) You may aggregate the Package (either the Standard Version or
409             Modified Version) with other packages and Distribute the resulting
410             aggregation provided that you do not charge a licensing fee for the
411             Package. Distributor Fees are permitted, and licensing fees for other
412             components in the aggregation are permitted. The terms of this license
413             apply to the use and Distribution of the Standard or Modified Versions
414             as included in the aggregation.
415              
416             (8) You are permitted to link Modified and Standard Versions with
417             other works, to embed the Package in a larger work of your own, or to
418             build stand-alone binary or bytecode versions of applications that
419             include the Package, and Distribute the result without restriction,
420             provided the result does not expose a direct interface to the Package.
421              
422              
423             Items That are Not Considered Part of a Modified Version
424              
425             (9) Works (including, but not limited to, modules and scripts) that
426             merely extend or make use of the Package, do not, by themselves, cause
427             the Package to be a Modified Version. In addition, such works are not
428             considered parts of the Package itself, and are not subject to the
429             terms of this license.
430              
431              
432             General Provisions
433              
434             (10) Any use, modification, and distribution of the Standard or
435             Modified Versions is governed by this Artistic License. By using,
436             modifying or distributing the Package, you accept this license. Do not
437             use, modify, or distribute the Package, if you do not accept this
438             license.
439              
440             (11) If your Modified Version has been derived from a Modified
441             Version made by someone other than you, you are nevertheless required
442             to ensure that your Modified Version complies with the requirements of
443             this license.
444              
445             (12) This license does not grant you the right to use any trademark,
446             service mark, tradename, or logo of the Copyright Holder.
447              
448             (13) This license includes the non-exclusive, worldwide,
449             free-of-charge patent license to make, have made, use, offer to sell,
450             sell, import and otherwise transfer the Package with respect to any
451             patent claims licensable by the Copyright Holder that are necessarily
452             infringed by the Package. If you institute patent litigation
453             (including a cross-claim or counterclaim) against any party alleging
454             that the Package constitutes direct or contributory patent
455             infringement, then this Artistic License to you shall terminate on the
456             date that such litigation is filed.
457              
458             (14) Disclaimer of Warranty:
459             THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
460             IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
461             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
462             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL
463             LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL
464             BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
465             DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF
466             ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
467             END_OF_BODY
468             },
469             changes => {
470             file => 'Changes',
471             path => '.module-template/templates',
472             body => <<'END_OF_BODY',
473             Revision history for [% module %]
474              
475             Author [% author %]
476             Email [% email %]
477              
478             0.01 [% today %]
479             [% module %] created
480              
481             END_OF_BODY
482             },
483             readme => {
484             file => 'README',
485             path => '.module-template/templates',
486             body => <<'END_OF_BODY',
487             [% module %] is Copyright (C) [% year %], [% author %].
488              
489             INSTALLATION
490              
491             To install this module, run the following commands:
492              
493             perl Makefile.PL
494             make
495             make test
496             make install
497              
498             SUPPORT AND DOCUMENTATION
499              
500             After install, you can find documentation for this module with the
501             perldoc command.
502              
503             perldoc [% module %]
504              
505             LICENSE INFORMATION
506              
507             This [library|program|code|module] is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license in the file LICENSE.
508             END_OF_BODY
509             },
510             script => {
511             file => 'script.pl',
512             path => '.module-template/templates/bin',
513             body => <<'END_OF_BODY',
514             #!/usr/bin/perl
515             #
516             # AUTHOR: [% author %], [% email %]
517             # CREATED: [% today %]
518              
519             use [% min_perl_version %];
520              
521             use strict;
522             use warnings;
523              
524             our $VERSION = '0.01';
525              
526             use Carp;
527             use POSIX qw(strftime);
528              
529             __END__