Last active
April 4, 2017 13:48
-
-
Save akzhan/61e30eb96266845137a4ca9e2c69533c to your computer and use it in GitHub Desktop.
YourCompany Perl Prologue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include = BuiltinFunctions::ProhibitBooleanGrep BuiltinFunctions::ProhibitStringyEval BuiltinFunctions::ProhibitStringySplit BuiltinFunctions::ProhibitUniversalCan BuiltinFunctions::ProhibitUniversalIsa ClassHierarchies::ProhibitExplicitISA CodeLayout::ProhibitHardTabs ControlStructures::ProhibitMutatingListFunctions ControlStructures::ProhibitUnreachableCode ErrorHandling::RequireCarping InputOutput::ProhibitBarewordFileHandles InputOutput::RequireCheckedClose InputOutput::RequireCheckedOpen InputOutput::RequireCheckedSyscalls InputOutput::ProhibitInteractiveTest InputOutput::ProhibitOneArgSelect InputOutput::ProhibitTwoArgOpen Miscellanea::ProhibitFormats Modules::ProhibitEvilModules Modules::RequireEndWithOne Objects::ProhibitIndirectSyntax Policy::TestingAndDebugging::RequireUseStrict Policy::TestingAndDebugging::RequireUseWarnings RegularExpressions::ProhibitCaptureWithoutTest Subroutines::ProhibitBuiltinHomonyms Subroutines::ProhibitReturnSort Subroutines::ProhibitSubroutinePrototypes Subroutines::ProhibitUnusedPrivateSubroutines Subroutines::ProtectPrivateSubs TestingAndDebugging::ProhibitNoStrict TestingAndDebugging::ProhibitProlongedStrictureOverride TestingAndDebugging::RequireUseStrict TestingAndDebugging:;ProhibitNoWarnings ValuesAndExpressions::ProhibitCommaSeparatedStatements ValuesAndExpressions::ProhibitLeadingZeros ValuesAndExpressions::ProhibitMagicNumbers ValuesAndExpressions::ProhibitMismatchedOperators ValuesAndExpressions::ProhibitMixedBooleanOperators Variables::ProhibitPerl4PackageNames Variables::ProhibitUnusedVariables Variables::ProtectPrivateVars Variables::RequireInitializationForLocalVars Variables::RequireLexicalLoopIterators Variables::RequireLocalizedPunctuationVars | |
[TestingAndDebugging::RequireUseStrict] | |
equivalent_modules = YourCompany::Perl::UTF8 YourCompany::Test::UTF8 | |
[TestingAndDebugging::RequireUseWarnings] | |
equivalent_modules = YourCompany::Perl::UTF8 YourCompany::Test::UTF8 | |
[ValuesAndExpressions::ProhibitMagicNumbers] | |
allowed_values = 0 1 | |
[-Subroutines::ProhibitExplicitReturnUndef] | |
[-Subroutines::RequireFinalReturn] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-I lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=encoding utf-8 | |
=head1 NAME | |
YourCompany::Perl::UTF8 | |
=head1 DESCRIPTION | |
Common project rules. | |
Inspired by L<Modern::Perl> but should be extended our own way. | |
=head1 FEATURES | |
Features enabled by module usage: say, state, switch, unicode_strings, array_base. | |
=head1 POLICY | |
Sets 'c3' method resolution order. | |
Includes strict, warnings and utf8 pragmata. | |
=cut | |
package YourCompany::Perl::UTF8; | |
use 5.020_003; | |
use strict; | |
use warnings; | |
use mro (); | |
use feature (); | |
use utf8 (); | |
# enable methods on filehandles; unnecessary when 5.14 autoloads them | |
use IO::File (); | |
use IO::Handle (); | |
sub import { | |
my ($class) = @_; | |
strict->import; | |
warnings->import( FATAL => 'all' ); | |
feature->import(':5.20'); | |
utf8->import; | |
mro::set_mro( scalar caller(), 'c3' ); | |
} | |
## no critic (Subroutines::ProhibitBuiltinHomonyms) | |
sub unimport { | |
utf8->unimport; | |
feature->unimport; | |
warnings->unimport; | |
strict->unimport; | |
} | |
## use critic | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package YourCompany::Test::UTF8; | |
use mro (); | |
use YourCompany::Perl::UTF8; | |
require Test::More; | |
require Test::Spec; | |
require Test::Exception; | |
my $builder = Test::More->builder; | |
binmode $builder->output, ":encoding(UTF-8)"; | |
binmode $builder->failure_output, ":encoding(UTF-8)"; | |
binmode $builder->todo_output, ":encoding(UTF-8)"; | |
sub import { | |
my $class = shift; | |
my $callpkg = caller; | |
YourCompany::Perl::UTF8->import; | |
mro::set_mro( scalar caller(), 'c3' ); | |
eval qq{ | |
package $callpkg; | |
use parent 'Test::Spec'; | |
# allow Test::Spec usage errors to be reported via Carp | |
our \@CARP_NOT = qw($callpkg); | |
}; | |
die $@ if $@; | |
Test::Spec::ExportProxy->export_to_level( 1, $callpkg ); | |
Test::Spec->export_to_level( 1, $callpkg ); | |
Test::Exception->export_to_level( 1, $callpkg ); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment