| 1 | # | ||||||||||||||
| 2 | # Copyright (C) 2015-2025 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.253341'; | |||||||||||||
| 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 | 0 | ▶ | ### assert: ($type =~ m/^(?:class|role|script)$/ms) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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 | my ($ver) = "$PERL_VERSION" =~ m/^v(\d+\.\d+)\..*$/; | |||||||||||||
| 37 | 11 | feature->import::into( $target, ":$ver" ); | |||||||||||||
| 38 | |||||||||||||||
| 39 | 11 | utf8->import::into($target); # Allow UTF-8 Source | |||||||||||||
| 40 | |||||||||||||||
| 41 | 11 | ▶ | if ( $type eq 'class' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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 | 9 | Feature::Compat::Class->import::into($target); | |||||||||||||
| 53 | } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 11 | Carp->import::into($target); | |||||||||||||
| 56 | 11 | English->import::into($target); | |||||||||||||
| 57 | 11 | Smart::Comments->import::into( $target, '-ENV', '###' ); | |||||||||||||
| 58 | |||||||||||||||
| 59 | 11 | feature->import::into( $target, 'postderef' ); # Not needed if feature bundle >= 5.23.1 | |||||||||||||
| 60 | |||||||||||||||
| 61 | 11 | Feature::Compat::Defer->import::into($target); | |||||||||||||
| 62 | 11 | Feature::Compat::Try->import::into($target); | |||||||||||||
| 63 | |||||||||||||||
| 64 | # We haven't been using this | ||||||||||||||
| 65 | # feature->import::into($target, 'refaliasing'); | ||||||||||||||
| 66 | 11 | feature->import::into( $target, 'signatures' ); | |||||||||||||
| 67 | |||||||||||||||
| 68 | 11 | feature->import::into( $target, 'unicode_strings' ); | |||||||||||||
| 69 | # warnings->unimport::out_of($target, 'experimental::refaliasing'); | ||||||||||||||
| 70 | 11 | warnings->unimport::out_of( $target, 'experimental::signatures' ); | |||||||||||||
| 71 | |||||||||||||||
| 72 | 11 | ▶ | if ( $PERL_VERSION lt v5.24.0 ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 73 | 0 | warnings->unimport::out_of( $target, 'experimental::postderef' ); | |||||||||||||
| 74 | } | ||||||||||||||
| 75 | |||||||||||||||
| 76 | # For "re 'strict'" feature | ||||||||||||||
| 77 | 11 | warnings->unimport::out_of( $target, 'experimental::re_strict' ); | |||||||||||||
| 78 | 11 | re->import('strict'); | |||||||||||||
| 79 | |||||||||||||||
| 80 | 11 | ▶ | if ( $PERL_VERSION ge v5.32.0 ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 81 | # Turn off indirect syntax | ||||||||||||||
| 82 | 11 | feature->unimport::out_of( $target, 'indirect' ); | |||||||||||||
| 83 | |||||||||||||||
| 84 | # Turn on isa | ||||||||||||||
| 85 | 11 | feature->import::into( $target, 'isa' ); | |||||||||||||
| 86 | 11 | warnings->unimport::out_of( $target, 'experimental::isa' ); | |||||||||||||
| 87 | } | ||||||||||||||
| 88 | |||||||||||||||
| 89 | 11 | ▶ | if ( $PERL_VERSION ge v5.34.0 ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 90 | # Turn off multidimensional "array" emulation | ||||||||||||||
| 91 | 11 | feature->unimport::out_of( $target, 'multidimensional' ); | |||||||||||||
| 92 | |||||||||||||||
| 93 | # Turn off bareword filehandles | ||||||||||||||
| 94 | 11 | feature->unimport::out_of( $target, 'bareword_filehandles' ); | |||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | 11 | return; | |||||||||||||
| 98 | } | ||||||||||||||
| 99 | |||||||||||||||
| 100 | 2 | 1; | |||||||||||||
| 101 | |||||||||||||||
| 102 | __END__ | ||||||||||||||