lib/JTM/Boilerplate.pm

filter: Statementstmt 93.8% 76 / 81 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod n/a totaltotal 91.5% 97 / 106 CC 8 SCAR 13.6
CC
8
Cov
90%
import
8.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« lib/JCM/Boilerplate.pm ↑ Summary
1 #
2 # Copyright (C) 2015-2021 Joelle Maslak
3 # All Rights Reserved - See License
4 #
5  
6 package JTM::Boilerplate;
7 # ABSTRACT: Default Boilerplate for Joelle Maslak's Code
8 2 $JTM::Boilerplate::VERSION = '2.211420';
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 2 ▶use v5.22;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 2 ▶no warnings 'experimental::re_strict';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use re 'strict';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use Import::Into;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use Smart::Comments;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use re;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 11 ▶sub import ( $self, $type = 'script' ) {
Subroutine import: called CC=8 SCAR=21.1
28 11 ▶ ### assert: ($type =~ m/^(?:class|role|script)$/ms)
Branch: 1 branch
BranchTrueFalseTotal
unless ($type =~ /^(?:class|role|script)$/msu) 0 11 11
29  
30 11 my $target = caller;
31  
32 11 strict->import::into($target);
33 11 warnings->import::into($target);
34 11 autodie->import::into($target);
35  
36 11 feature->import::into( $target, ':5.22' );
37  
38 11 utf8->import::into($target); # Allow UTF-8 Source
39  
40 11 ▶ if ( $type eq 'class' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'class') { } 1 10 11
elsif ($type eq 'role') { } 1 9 10
41 1 Moose->import::into($target);
42 1 Moose::Util::TypeConstraints->import::into($target);
43 1 MooseX::StrictConstructor->import::into($target);
44 1 namespace::autoclean->import::into($target);
45 } elsif ( $type eq 'role' ) {
46 1 Moose::Role->import::into($target);
47 1 Moose::Util::TypeConstraints->import::into($target);
48 1 MooseX::StrictConstructor->import::into($target);
49 1 namespace::autoclean->import::into($target);
50 }
51  
52 11 Carp->import::into($target);
53 11 English->import::into($target);
54 11 Smart::Comments->import::into( $target, '-ENV', '###' );
55  
56 11 feature->import::into( $target, 'postderef' ); # Not needed if feature bundle >= 5.23.1
57  
58 # We haven't been using this
59 # feature->import::into($target, 'refaliasing');
60 11 feature->import::into( $target, 'signatures' );
61  
62 11 feature->import::into( $target, 'switch' );
63 11 feature->import::into( $target, 'unicode_strings' );
64 # warnings->unimport::out_of($target, 'experimental::refaliasing');
65 11 warnings->unimport::out_of( $target, 'experimental::signatures' );
66  
67 11 ▶ if ( $PERL_VERSION lt v5.24.0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($JTM::Boilerplate::PERL_VERSION lt v5.24.0) 0 11 11
68 0 warnings->unimport::out_of( $target, 'experimental::postderef' );
69 }
70  
71 # For "switch" feature
72 11 warnings->unimport::out_of( $target, 'experimental::smartmatch' );
73  
74 # For "re 'strict'" feature
75 11 warnings->unimport::out_of( $target, 'experimental::re_strict' );
76 11 re->import( 'strict' );
77  
78 11 ▶ if ( $PERL_VERSION ge v5.32.0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($JTM::Boilerplate::PERL_VERSION ge v5.32.0) 11 0 11
79 # Turn off indirect syntax
80 11 feature->unimport::out_of( $target, 'indirect' );
81  
82 # Turn on isa
83 11 feature->import::into( $target, 'isa' );
84 11 warnings->unimport::out_of( $target, 'experimental::isa' );
85 }
86  
87 11 ▶ if ( $PERL_VERSION ge v5.34.0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($JTM::Boilerplate::PERL_VERSION ge v5.34.0) 11 0 11
88 # Turn off multidimensional "array" emulation
89 11 feature->unimport::out_of( $target, 'multidimensional' );
90  
91 # Turn off bareword filehandles
92 11 feature->unimport::out_of( $target, 'bareword_filehandles' );
93  
94 # Turn on Try/Catch
95 11 feature->import::into( $target, 'try' );
96 11 warnings->unimport::out_of( $target, 'experimental::try' );
97 }
98  
99 11 return;
100 }
101  
102 2 1;
103  
104 __END__
105  
106 =pod
107  
108 =encoding UTF-8
109  
110 =head1 NAME
111  
112 JTM::Boilerplate - Default Boilerplate for Joelle Maslak's Code
113  
114 =head1 VERSION
115  
116 version 2.211420
117  
118 =head1 SYNOPSIS
119  
120 use JTM::Boilerplate 'script';
121  
122 =head1 DESCRIPTION
123  
124 This module serves two purposes. First, it sets some default imports,
125 and turns on the strictures I've come to rely upon. Secondly, it depends
126 on a number of other modules to aid in setting up new environments (I can
127 just do a "cpan JTM-Boilerplate" to install everything I need).
128  
129 This module optionally takes one of two parameters, 'script', 'class',
130 or 'role'. If 'script' is specified, the module assumes that you do not
131 need Moose or MooseX modules.
132  
133 =head1 WARNINGS
134  
135 This module makes significant changes in the calling package!
136  
137 In addition, this module should be incorporated into any project by
138 copying it into the project's library tree. This protects the project from
139 outside dependencies that may be undesired.
140  
141 =head1 AUTHOR
142  
143 Joelle Maslak <jmaslak@antelope.net>
144  
145 =head1 COPYRIGHT AND LICENSE
146  
147 This software is copyright (c) 2015-2020 by Joelle Maslak.
148  
149 This is free software; you can redistribute it and/or modify it under
150 the same terms as the Perl 5 programming language system itself.
151  
152 =cut
« lib/JCM/Boilerplate.pm ↑ Summary