Merge pull request #121 from heytrav/master
package declaration and pod snippets
This commit is contained in:
commit
ae7945c115
@ -79,48 +79,54 @@ 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 {
|
||||||
${1:# body }
|
${1:# body }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,19 +139,19 @@ snippet begin
|
|||||||
}
|
}
|
||||||
|
|
||||||
# call package function with some parameter
|
# call package function with some parameter
|
||||||
snippet pkgmv
|
snippet pkgmv
|
||||||
__PACKAGE__->${1:package_method}(${2:var})
|
__PACKAGE__->${1:package_method}(${2:var})
|
||||||
|
|
||||||
# call package function without a parameter
|
# call package function without a parameter
|
||||||
snippet pkgm
|
snippet pkgm
|
||||||
__PACKAGE__->${1:package_method}()
|
__PACKAGE__->${1:package_method}()
|
||||||
|
|
||||||
# call package "get_" function without a parameter
|
# call package "get_" function without a parameter
|
||||||
snippet pkget
|
snippet pkget
|
||||||
__PACKAGE__->get_${1:package_method}()
|
__PACKAGE__->get_${1:package_method}()
|
||||||
|
|
||||||
# call package function with a parameter
|
# call package function with a parameter
|
||||||
snippet pkgetv
|
snippet pkgetv
|
||||||
__PACKAGE__->get_${1:package_method}(${2:var})
|
__PACKAGE__->get_${1:package_method}(${2:var})
|
||||||
|
|
||||||
# complex regex
|
# complex regex
|
||||||
@ -160,10 +166,10 @@ snippet qr/
|
|||||||
|
|
||||||
#given
|
#given
|
||||||
snippet given
|
snippet given
|
||||||
given ($${1:var}) {
|
given ($${1:var}) {
|
||||||
${2:# cases}
|
${2:# cases}
|
||||||
${3:# default}
|
${3:# default}
|
||||||
}
|
}
|
||||||
|
|
||||||
# switch-like case
|
# switch-like case
|
||||||
snippet when
|
snippet when
|
||||||
@ -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 } ;
|
||||||
@ -190,7 +195,7 @@ snippet ppod
|
|||||||
${1:ClassName} - ${2:ShortDesc}
|
${1:ClassName} - ${2:ShortDesc}
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
use $1;
|
use $1;
|
||||||
|
|
||||||
${3:# synopsis...}
|
${3:# synopsis...}
|
||||||
@ -202,7 +207,7 @@ snippet ppod
|
|||||||
|
|
||||||
=head1 INTERFACE
|
=head1 INTERFACE
|
||||||
|
|
||||||
|
|
||||||
=head1 DEPENDENCIES
|
=head1 DEPENDENCIES
|
||||||
|
|
||||||
|
|
||||||
@ -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
|
||||||
@ -232,7 +246,7 @@ snippet parg
|
|||||||
=item
|
=item
|
||||||
Arguments
|
Arguments
|
||||||
|
|
||||||
|
|
||||||
=over 3
|
=over 3
|
||||||
|
|
||||||
=item
|
=item
|
||||||
@ -255,47 +269,21 @@ 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
|
||||||
@ -331,7 +319,7 @@ snippet tsub
|
|||||||
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
|
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
${4:# body}
|
${4:# body}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test::Routine-style test
|
# Test::Routine-style test
|
||||||
@ -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