Merge pull request #121 from heytrav/master

package declaration and pod snippets
This commit is contained in:
Honza Pokorny 2012-11-15 10:36:00 -08:00
commit ae7945c115

View File

@ -79,45 +79,51 @@ snippet for
snippet fore
${1:expression} foreach @${2:array};${3}
# Package
snippet cl
package ${1:ClassName};
snippet package
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`};
use base qw(${2:ParentClass});
${2}
sub new {
my $class = shift;
$class = ref $class if ref $class;
my $self = bless {}, $class;
$self;
}
1;
1;${3}
__END__
# Package syntax perl >= 5.14
snippet packagev514
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99};
${3}
1;
__END__
#moose
snippet moose
use Moose;
use namespace::autoclean;
${1:#}BEGIN {extends '${2:ParentClass}'};
${3}
# parent
snippet parent
use parent qw(${1:Parent Class});
# Read File
snippet slurp
my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> };
${3}
# strict warnings
snippet strwar
use strict;
use warnings;
# standard versioning with perlcritic bypass
# older versioning with perlcritic bypass
snippet vers
## no critic
our $VERSION = '${1:version}';
eval $VERSION;
## use critic
# new 'switch' like feature
snippet switch
use feature 'switch';
# Anonymous subroutine
snippet asub
sub {
@ -176,7 +182,6 @@ snippet hslice
@{ ${1:hash} }{ ${2:array} }
# map
snippet map
map { ${2: body } } ${1: @array } ;
@ -223,8 +228,17 @@ snippet psubi
=cut
# inline documented subroutine
snippet subpod
=head2 $1
Summary of $1
=cut
sub ${1:subroutine_name} {
${2:# body...}
}
# Subroutine signature
snippet parg
=over 2
@ -257,45 +271,19 @@ snippet parg
=back
=back
# Moose package
snippet moosecl
package ${1:ClassName};
use Moose;
#extends '${2:# ParentClass}';
${6:# body of class}
1;
__END__
=head1 NAME
$1 - ${3:ShortDesc}
=head1 SYNOPSIS
${4:# synopsis...}
=head1 DESCRIPTION
${5:# longer description...}
# Moose has
snippet has
has ${1:attribute} => (
is => '${2:ro|rw}',
is => '${2:ro|rw}',
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
default => ${4:defaultvalue}
,${5:# other attributes}
default => sub {
${4:defaultvalue}
},
${5:# other attributes}
);
@ -303,14 +291,14 @@ snippet has
snippet override
override ${1:attribute} => sub {
${2:# my $self = shift;};
${3:# my ($self,$args) = @_;};
${3:# my ($self, $args) = @_;};
};
# use test classes
snippet tuse
use Test::More;
use Test::Deep ();
use Test::Deep; # (); # uncomment to stop prototype errors
use Test::Exception;
# local test lib
@ -347,6 +335,7 @@ snippet tprep
my $self = shift;
${4:# body}
}
# cause failures to print stack trace
snippet debug_trace
use Carp; # 'verbose';