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