Merge pull request #121 from heytrav/master
package declaration and pod snippets
This commit is contained in:
commit
ae7945c115
@ -79,45 +79,51 @@ snippet for
|
|||||||
snippet fore
|
snippet fore
|
||||||
${1:expression} foreach @${2:array};${3}
|
${1:expression} foreach @${2:array};${3}
|
||||||
# Package
|
# Package
|
||||||
snippet cl
|
snippet package
|
||||||
package ${1:ClassName};
|
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`};
|
||||||
|
|
||||||
use base qw(${2:ParentClass});
|
${2}
|
||||||
|
|
||||||
sub new {
|
1;
|
||||||
my $class = shift;
|
|
||||||
$class = ref $class if ref $class;
|
|
||||||
my $self = bless {}, $class;
|
|
||||||
$self;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
# Read File
|
||||||
snippet slurp
|
snippet slurp
|
||||||
my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> };
|
my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> };
|
||||||
${3}
|
${3}
|
||||||
|
|
||||||
|
|
||||||
# strict warnings
|
# strict warnings
|
||||||
snippet strwar
|
snippet strwar
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
# older versioning with perlcritic bypass
|
||||||
|
|
||||||
# standard versioning with perlcritic bypass
|
|
||||||
snippet vers
|
snippet vers
|
||||||
## no critic
|
## no critic
|
||||||
our $VERSION = '${1:version}';
|
our $VERSION = '${1:version}';
|
||||||
eval $VERSION;
|
eval $VERSION;
|
||||||
## use critic
|
## use critic
|
||||||
|
|
||||||
|
|
||||||
# new 'switch' like feature
|
# new 'switch' like feature
|
||||||
snippet switch
|
snippet switch
|
||||||
use feature 'switch';
|
use feature 'switch';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Anonymous subroutine
|
# Anonymous subroutine
|
||||||
snippet asub
|
snippet asub
|
||||||
sub {
|
sub {
|
||||||
@ -176,7 +182,6 @@ snippet hslice
|
|||||||
@{ ${1:hash} }{ ${2:array} }
|
@{ ${1:hash} }{ ${2:array} }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# map
|
# map
|
||||||
snippet map
|
snippet map
|
||||||
map { ${2: body } } ${1: @array } ;
|
map { ${2: body } } ${1: @array } ;
|
||||||
@ -223,8 +228,17 @@ snippet psubi
|
|||||||
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
# inline documented subroutine
|
||||||
|
snippet subpod
|
||||||
|
=head2 $1
|
||||||
|
|
||||||
|
Summary of $1
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub ${1:subroutine_name} {
|
||||||
|
${2:# body...}
|
||||||
|
}
|
||||||
# Subroutine signature
|
# Subroutine signature
|
||||||
snippet parg
|
snippet parg
|
||||||
=over 2
|
=over 2
|
||||||
@ -257,45 +271,19 @@ snippet parg
|
|||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=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
|
# Moose has
|
||||||
snippet has
|
snippet has
|
||||||
has ${1:attribute} => (
|
has ${1:attribute} => (
|
||||||
is => '${2:ro|rw}',
|
is => '${2:ro|rw}',
|
||||||
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
|
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
|
||||||
default => ${4:defaultvalue}
|
default => sub {
|
||||||
,${5:# other attributes}
|
${4:defaultvalue}
|
||||||
|
},
|
||||||
|
${5:# other attributes}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -303,14 +291,14 @@ snippet has
|
|||||||
snippet override
|
snippet override
|
||||||
override ${1:attribute} => sub {
|
override ${1:attribute} => sub {
|
||||||
${2:# my $self = shift;};
|
${2:# my $self = shift;};
|
||||||
${3:# my ($self,$args) = @_;};
|
${3:# my ($self, $args) = @_;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
# use test classes
|
# use test classes
|
||||||
snippet tuse
|
snippet tuse
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Test::Deep ();
|
use Test::Deep; # (); # uncomment to stop prototype errors
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
|
|
||||||
# local test lib
|
# local test lib
|
||||||
@ -347,6 +335,7 @@ snippet tprep
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
${4:# body}
|
${4:# body}
|
||||||
}
|
}
|
||||||
|
|
||||||
# cause failures to print stack trace
|
# cause failures to print stack trace
|
||||||
snippet debug_trace
|
snippet debug_trace
|
||||||
use Carp; # 'verbose';
|
use Carp; # 'verbose';
|
||||||
|
Loading…
Reference in New Issue
Block a user