| 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.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 | 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
| |||||||||||||||
| 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__ | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =pod | ||||||||||||||
| 105 | |||||||||||||||
| 106 | =encoding UTF-8 | ||||||||||||||
| 107 | |||||||||||||||
| 108 | =head1 NAME | ||||||||||||||
| 109 | |||||||||||||||
| 110 | JTM::Boilerplate - Default Boilerplate for Joelle Maslak's Code | ||||||||||||||
| 111 | |||||||||||||||
| 112 | =head1 VERSION | ||||||||||||||
| 113 | |||||||||||||||
| 114 | version 2.231980 | ||||||||||||||
| 115 | |||||||||||||||
| 116 | =head1 SYNOPSIS | ||||||||||||||
| 117 | |||||||||||||||
| 118 | use JTM::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 JTM-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 | ||||||||||||||