parent
9468d4c196
commit
5d1a6fccb0
@ -0,0 +1,41 @@
|
||||
RCS
|
||||
CVS
|
||||
SCCS
|
||||
,v
|
||||
.svn
|
||||
.git
|
||||
_darcs
|
||||
.cvsignore
|
||||
Descrip.MMS
|
||||
DESCRIP.MMS
|
||||
descrip.mms
|
||||
MANIFEST
|
||||
MANIFEST.bak
|
||||
Makefile
|
||||
blib
|
||||
MakeMaker-*
|
||||
pm_to_blib.ts
|
||||
pm_to_blib
|
||||
blibdirs.ts
|
||||
Build
|
||||
_build
|
||||
Build.bat
|
||||
Build.COM
|
||||
BUILD.COM
|
||||
build.com
|
||||
*~
|
||||
*.old
|
||||
*#
|
||||
*.#
|
||||
*.bak
|
||||
*.tmp
|
||||
*.rej
|
||||
*.swp
|
||||
.DS_Store
|
||||
._*
|
||||
cover_db
|
||||
covered
|
||||
META.*
|
||||
MYMETA.*
|
||||
SIGNATURE
|
||||
Sipwise-Base-*
|
@ -0,0 +1,24 @@
|
||||
use Module::Build qw();
|
||||
my $builder = Module::Build->new(
|
||||
module_name => 'Sipwise-Base',
|
||||
license => 'restrictive',
|
||||
dist_author => 'Lars Dieckow <ldieckow@sipwise.com>',
|
||||
dist_version_from => 'lib/Sipwise/Base.pm',
|
||||
build_requires => {
|
||||
'Test::More' => '0.88',
|
||||
},
|
||||
requires => {
|
||||
'autodie' => 0,
|
||||
'lambda' => 0,
|
||||
'Module::Runtime' => 0,
|
||||
'Moose' => 2,
|
||||
'MooseX::Method::Signatures' => 0,
|
||||
'parent' => 0,
|
||||
'perl5i::2' => 0,
|
||||
'strictures' => 1,
|
||||
'TryCatch' => 0,
|
||||
'utf8' => 0,
|
||||
},
|
||||
add_to_cleanup => ['Sipwise-Base-*'],
|
||||
);
|
||||
$builder->create_build_script;
|
@ -0,0 +1,9 @@
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Changes - Revision history for Sipwise-Base
|
||||
|
||||
=head2 1.000 2013-03-21
|
||||
|
||||
Initial release.
|
@ -0,0 +1,63 @@
|
||||
# Avoid version control files.
|
||||
\bRCS(?!\.pm)\b
|
||||
\bCVS(?!\.pm)\b
|
||||
\bSCCS(?!\.pm)\b
|
||||
,v$
|
||||
\B\.svn\b
|
||||
\B\.git\b
|
||||
\B\.gitignore\b
|
||||
\b_darcs\b
|
||||
\B\.cvsignore$
|
||||
|
||||
# Avoid VMS specific MakeMaker generated files
|
||||
\bDescrip.MMS$
|
||||
\bDESCRIP.MMS$
|
||||
\bdescrip.mms$
|
||||
|
||||
# Avoid Makemaker generated and utility files.
|
||||
\bMANIFEST\.bak
|
||||
\bMakefile$
|
||||
\bblib/
|
||||
\bMakeMaker-\d
|
||||
\bpm_to_blib\.ts$
|
||||
\bpm_to_blib$
|
||||
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
|
||||
|
||||
# Avoid Module::Build generated and utility files.
|
||||
\bBuild$
|
||||
\b_build/
|
||||
\bBuild.bat$
|
||||
\bBuild.COM$
|
||||
\bBUILD.COM$
|
||||
\bbuild.com$
|
||||
^MANIFEST\.SKIP
|
||||
|
||||
# Avoid temp and backup files.
|
||||
~$
|
||||
\.old$
|
||||
\#$
|
||||
\b\.#
|
||||
\.bak$
|
||||
\.tmp$
|
||||
\.#
|
||||
\.rej$
|
||||
\..*\.sw.?$
|
||||
|
||||
# Avoid OS-specific files/dirs
|
||||
# Mac OSX metadata
|
||||
\B\.DS_Store
|
||||
# Mac OSX SMB mount metadata files
|
||||
\B\._
|
||||
|
||||
# Avoid Devel::Cover and Devel::CoverX::Covered files.
|
||||
\bcover_db\b
|
||||
\bcovered\b
|
||||
|
||||
# Avoid prove files
|
||||
\B\.prove$
|
||||
|
||||
# Avoid configuration metadata file
|
||||
^MYMETA\.
|
||||
|
||||
# Avoid archives of this distribution
|
||||
\bSipwise-Base-[\d\.\_]+
|
@ -0,0 +1,19 @@
|
||||
=encoding UTF-8
|
||||
|
||||
Sipwise-Base version 1.000
|
||||
|
||||
=head1 NAME
|
||||
|
||||
README - basic information for users prior to downloading
|
||||
|
||||
=head1 INSTALLATION
|
||||
|
||||
See L<http://www.cpan.org/modules/INSTALL.html>.
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
See distribution meta file.
|
||||
|
||||
=head1 LICENCE
|
||||
|
||||
restricted
|
@ -0,0 +1,98 @@
|
||||
package Sipwise::Base;
|
||||
use utf8;
|
||||
use Module::Runtime qw(require_module);
|
||||
use parent 'autodie';
|
||||
our $VERSION = '1.000';
|
||||
|
||||
sub import {
|
||||
my ($class) = @_;
|
||||
my $caller = caller;
|
||||
|
||||
require_module('strictures');
|
||||
strictures->import(1);
|
||||
|
||||
require_module('perl5i::2');
|
||||
perl5i::2->import(-skip => [qw(Signatures Try::Tiny)]);
|
||||
|
||||
eval <<"";
|
||||
package $caller;
|
||||
use lambda 'λ';
|
||||
use perl5i::2 -skip => [qw(Signatures Try::Tiny)];
|
||||
use Moose qw(extends has with);
|
||||
use MooseX::Method::Signatures;
|
||||
use TryCatch;
|
||||
|
||||
@_ = ($class, ':all');
|
||||
goto &autodie::import;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Sipwise::Base - import boilerplate code
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
This document describes Sipwise::Base version 1.000
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Sipwise::Base;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The purpose of this module is to reduce the amount of boilerplate code and to enable some Perl features that are not
|
||||
available by default. This is in the spirit of
|
||||
L<http://modernperlbooks.com/mt/2009/10/remove-the-little-pessimizations.html|eliminating pessimisations>.
|
||||
|
||||
Switches on the functionality of the pragmatic modules L<strictures>, L<lambda>, L<perl5i>, L<Moose>,
|
||||
L<MooseX::Method::Signatures>, L<TryCatch>.
|
||||
|
||||
=head1 INTERFACE
|
||||
|
||||
=head2 C<import>
|
||||
|
||||
See L<perlfunc/import>.
|
||||
|
||||
=head2 Exports
|
||||
|
||||
=head1 DIAGNOSTICS
|
||||
|
||||
None.
|
||||
|
||||
=head1 CONFIGURATION AND ENVIRONMENT
|
||||
|
||||
Sipwise::Base requires no configuration files or environment variables.
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
See meta file in the source distribution.
|
||||
|
||||
=head1 INCOMPATIBILITIES
|
||||
|
||||
None reported.
|
||||
|
||||
=head1 BUGS AND LIMITATIONS
|
||||
|
||||
L<https://bugtracker.sipwise.com>
|
||||
|
||||
=head1 TO DO
|
||||
|
||||
different profiles for command-line applications
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<ToolSet>, L<Toolkit>, Ingy's L<perl5>, L<Syntax::Collector>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Lars Dieckow C<< <ldieckow@sipwise.com> >>
|
||||
|
||||
=head1 LICENCE
|
||||
|
||||
restricted
|
@ -0,0 +1,193 @@
|
||||
package Sipwise::Boilerplate;
|
||||
use Sipwise::Base;
|
||||
our $VERSION = '1.000';
|
||||
|
||||
__END__
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Sipwise::Boilerplate - a template for new code
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Copy the following text, outdent it, save to a new file, then fill it in. Delete the C<=for author> POD sections after
|
||||
you are done with them.
|
||||
|
||||
package Something::Or::Other;
|
||||
use Sipwise::Base;
|
||||
use namespace::sweep;
|
||||
|
||||
our $VERSION = '1.000';
|
||||
|
||||
… # attributes, methods, package-level code go here
|
||||
|
||||
$CLASS->meta->make_immutable;
|
||||
|
||||
__END__
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Something::Or::Other - [One line description of module's purpose here]
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
This document describes Something::Or::Other version 1.000
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Something::Or::Other qw();
|
||||
|
||||
=for author to fill in:
|
||||
Brief code example(s) here showing commonest usage(s).
|
||||
This section will be as far as many users bother reading
|
||||
so make it as educational and exeplary as possible.
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=for author to fill in:
|
||||
Write a full description of the module and its features here.
|
||||
Use subsections (=head2, =head3) as appropriate.
|
||||
|
||||
=head1 INTERFACE
|
||||
|
||||
=for author to fill in:
|
||||
Write a separate section listing the public components of the modules
|
||||
interface. These normally consist of either subroutines that may be
|
||||
exported, or methods that may be called on objects belonging to the
|
||||
classes provided by the module.
|
||||
|
||||
=head2 Composition
|
||||
|
||||
Something::Or::Other
|
||||
ISA Something
|
||||
DOES OtherRole
|
||||
|
||||
All methods and attributes not mentioned here are
|
||||
inherited from L<Something> or mixed in from L<OtherRole>.
|
||||
|
||||
=head2 Attributes
|
||||
|
||||
=head3 C<foo>
|
||||
|
||||
Type C<Str>, B<required> attribute, designates the fnarg fnord.
|
||||
|
||||
=head3 C<feh>
|
||||
|
||||
Type C<Bool>, whether foo is encoded into fnord.
|
||||
|
||||
=head2 Methods
|
||||
|
||||
=head3 C<bar>
|
||||
|
||||
Returns the bar fnord as string.
|
||||
|
||||
=head3 C<mogrify>
|
||||
|
||||
$soo->mogrify; # use defaults
|
||||
$soo->mogrify({blah => 42, harbl => 23});
|
||||
|
||||
Uses the supplied arguments to blah blah.
|
||||
|
||||
=head4 C<mogrify> argument keys
|
||||
|
||||
…
|
||||
|
||||
=head2 Exports
|
||||
|
||||
=head3 C<quux>
|
||||
|
||||
Exported on demand, same as calling the default constructor followed by the L</bar> method.
|
||||
|
||||
=head1 DIAGNOSTICS
|
||||
|
||||
None.
|
||||
|
||||
=for author to fill in:
|
||||
List every single error and warning message that the module can
|
||||
generate (even the ones that will "never happen"), with a full
|
||||
explanation of each problem, one or more likely causes, and any
|
||||
suggested remedies.
|
||||
|
||||
=over
|
||||
|
||||
=item C<< Error message here, perhaps with %s placeholders >>
|
||||
|
||||
[Description of error here]
|
||||
|
||||
=item C<< Another error message here >>
|
||||
|
||||
[Description of error here]
|
||||
|
||||
[Et cetera, et cetera]
|
||||
|
||||
=back
|
||||
|
||||
=head1 CONFIGURATION AND ENVIRONMENT
|
||||
|
||||
Something::Or::Other requires no configuration files or environment variables.
|
||||
|
||||
=for author to fill in:
|
||||
A full explanation of any configuration system(s) used by the
|
||||
module, including the names and locations of any configuration
|
||||
files, and the meaning of any environment variables or properties
|
||||
that can be set. These descriptions must also include details of any
|
||||
configuration language used.
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
See meta file in the source distribution.
|
||||
|
||||
=for author to fill in:
|
||||
A list of all the other modules that this module relies upon,
|
||||
including any restrictions on versions, and an indication whether
|
||||
the module is part of the standard Perl distribution, part of the
|
||||
module's distribution, or must be installed separately.
|
||||
|
||||
=head1 INCOMPATIBILITIES
|
||||
|
||||
None reported.
|
||||
|
||||
=for author to fill in:
|
||||
A list of any modules that this module cannot be used in conjunction
|
||||
with. This may be due to name conflicts in the interface, or
|
||||
competition for system or program resources, or due to internal
|
||||
limitations of Perl (for example, many modules that use source code
|
||||
filters are mutually incompatible).
|
||||
|
||||
=head1 BUGS AND LIMITATIONS
|
||||
|
||||
L<https://bugtracker.sipwise.com>
|
||||
|
||||
No known limitations.
|
||||
|
||||
=for author to fill in:
|
||||
A list of known problems with the module, together with some
|
||||
indication whether they are likely to be fixed in an upcoming
|
||||
release. Also a list of restrictions on the features the module
|
||||
does provide: data types that cannot be handled, performance issues
|
||||
and the circumstances in which they may arise, practical
|
||||
limitations on the size of data sets, special cases that are not
|
||||
(yet) handled, etc.
|
||||
|
||||
=head1 TO DO
|
||||
|
||||
=for author to fill in:
|
||||
future plans and ideas
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
=for author to fill in:
|
||||
related work and modules, perhaps with some prose describing the
|
||||
different advantages of each under which circumstances
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Your Name C<< <yname@sipwise.com> >>
|
||||
|
||||
=head1 LICENCE
|
||||
|
||||
restricted
|
@ -0,0 +1,54 @@
|
||||
colour-severity-5 = dark magenta
|
||||
colour-severity-4 = dark red
|
||||
colour-severity-3 = dark yellow
|
||||
colour-severity-2 = dark blue
|
||||
colour-severity-1 = black
|
||||
verbose = %f line %l col %c\n [%s] %p (%e) = %m\n %r\n
|
||||
|
||||
[-ValuesAndExpressions::ProhibitAccessOfPrivateData]
|
||||
# see bug http://rt.cpan.org/Public/Bug/Display.html?id=35440
|
||||
|
||||
[-Editor::RequireEmacsFileVariables]
|
||||
# no one uses Emacs here
|
||||
|
||||
# next policy is gone in 1.118
|
||||
# [-Miscellanea::RequireRcsKeywords]
|
||||
# git says rcs keywords are a stupid idea:
|
||||
# http://git.or.cz/gitwiki/GitFaq#head-4a0afe71a2bb7734777a8b0b345e0308aefdbd40
|
||||
|
||||
[-Lax::ProhibitStringyEval::ExceptForRequire]
|
||||
# already covered through BuiltinFunctions::ProhibitStringyEval::allow_includes
|
||||
|
||||
[Documentation::RequirePodSections]
|
||||
lib_sections = NAME | VERSION | SYNOPSIS | DESCRIPTION | INTERFACE | Composition | Attributes | Methods | Exports | DIAGNOSTICS | CONFIGURATION AND ENVIRONMENT | DEPENDENCIES | INCOMPATIBILITIES | BUGS AND LIMITATIONS | TO DO | AUTHOR | SEE ALSO
|
||||
|
||||
[Bangs::ProhibitCommentedOutCode]
|
||||
commentedcoderegex = \$(?!Id)[A-Za-z_].*=/
|
||||
# should not trigger on the RCS variable
|
||||
|
||||
[Perl::Critic::Policy::Tics::ProhibitLongLines]
|
||||
hard_max = 140
|
||||
# terminal width
|
||||
|
||||
[InputOutput::RequireCheckedSyscalls]
|
||||
functions = :builtins
|
||||
exclude_functions = print
|
||||
|
||||
[Documentation::PodSpelling]
|
||||
spell_command = aspell list -l en
|
||||
|
||||
[Modules::RequireExplicitInclusion]
|
||||
exempt_packages = /XML::LibXML::.*/
|
||||
|
||||
[BuiltinFunctions::ProhibitStringyEval]
|
||||
allow_includes = 0
|
||||
# use Module::Runtime for includes
|
||||
|
||||
[-CodeLayout::ProhibitHashBarewords]
|
||||
# meh, it's super annoying
|
||||
|
||||
[TestingAndDebugging::RequireUseStrict]
|
||||
equivalent_modules = strictures
|
||||
|
||||
[TestingAndDebugging::RequireUseWarnings]
|
||||
equivalent_modules = strictures
|
@ -0,0 +1,15 @@
|
||||
--block-brace-tightness=2
|
||||
--brace-tightness=2
|
||||
--break-before-all-operators
|
||||
--cuddled-else
|
||||
--maximum-line-length=140
|
||||
--no-opening-sub-brace-on-new-line
|
||||
--no-outdent-long-quotes
|
||||
--no-space-for-semicolon
|
||||
--opening-brace-always-on-right
|
||||
--outdent-long-comments
|
||||
--paren-tightness=2
|
||||
--square-bracket-tightness=2
|
||||
--stack-closing-tokens
|
||||
--stack-opening-tokens
|
||||
--standard-error-output
|
@ -0,0 +1,7 @@
|
||||
package MethodSignatures;
|
||||
use Sipwise::Base;
|
||||
use t::Types 'Place';
|
||||
|
||||
method greet(Place $who) {
|
||||
return "Hello, $who!";
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
package StrictSubs;
|
||||
use Sipwise::Base;
|
||||
fnord;
|
@ -0,0 +1,3 @@
|
||||
package StrictVars;
|
||||
use Sipwise::Base;
|
||||
$fnord;
|
@ -0,0 +1,5 @@
|
||||
package Types;
|
||||
use Sipwise::Base;
|
||||
use Moose::Util::TypeConstraints qw(subtype as where);
|
||||
|
||||
subtype 'Place', as 'Str', where { /world/ };
|
@ -0,0 +1,5 @@
|
||||
use Sipwise::Base;
|
||||
use Test::More import => [qw(done_testing pass)];
|
||||
|
||||
pass 'Testing Sipwise::Base ' . Sipwise::Base->VERSION;
|
||||
done_testing;
|
@ -0,0 +1,50 @@
|
||||
use Sipwise::Base;
|
||||
use Test::More import => [qw(done_testing ok)];
|
||||
|
||||
eval 'use t::StrictVars';
|
||||
ok $@, 'strict vars';
|
||||
|
||||
eval 'use t::StrictSubs';
|
||||
ok $@, 'strict subs';
|
||||
|
||||
eval '$$foobar';
|
||||
ok $@, 'strict refs';
|
||||
|
||||
eval { my $foo = 1 + undef };
|
||||
ok $@, 'fatal warnings';
|
||||
|
||||
ok say(''), 'say syntax is available';
|
||||
|
||||
ok state $foobar = 1, 'state syntax is available';
|
||||
|
||||
eval {
|
||||
given (1) {
|
||||
when (1) {}
|
||||
default {1}
|
||||
}
|
||||
};
|
||||
ok !$@, 'switch syntax is available';
|
||||
|
||||
ok(__PACKAGE__->can($_), "$_ function name is available") for qw(λ extends with has method list);
|
||||
|
||||
eval 'use t::MethodSignatures';
|
||||
try {
|
||||
MethodSignatures->new->greet(123);
|
||||
} catch($e) {
|
||||
ok $e =~ /^Validation failed/;
|
||||
}
|
||||
|
||||
ok MethodSignatures->new->greet('world') eq 'Hello, world!', 'method signatures';
|
||||
|
||||
eval { unlink '/tmp/doesnotexist' };
|
||||
ok $@, 'autodie is in effect';
|
||||
|
||||
ok 2->pow(8), 'autobox is in effect';
|
||||
|
||||
try {
|
||||
die bless { fnord => 42 } => 'Foobar';
|
||||
} catch (Foobar $e) {
|
||||
ok $e->isa('Foobar'), 'TryCatch works';
|
||||
}
|
||||
|
||||
done_testing;
|
Loading…
Reference in new issue