Skip to content

Commit

Permalink
April 2018 update
Browse files Browse the repository at this point in the history
  • Loading branch information
thoughtstream committed Apr 26, 2018
1 parent 3576826 commit cbe1fb5
Show file tree
Hide file tree
Showing 28 changed files with 1,924 additions and 655 deletions.
966 changes: 533 additions & 433 deletions .vimrc

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions bin/file_template
Expand Up @@ -27,13 +27,6 @@ for ($INFO{'MODULE NAME'}) {
s{^lib::}{}g;
}

for ($INFO{'MODULE NAME'}) {
s{$SUFFIX}{};
s{/}{::}g;
s{^.*::lib::}{}g;
s{^lib::}{}g;
}

for ($INFO{'RT NAME'}) {
s{$SUFFIX}{};
s{/}{-}g;
Expand Down
4 changes: 2 additions & 2 deletions bin/install
Expand Up @@ -88,13 +88,13 @@ sub install {
return
if !$f
&& !prompt(-yn1r, -default=>'y',
"A version of $from is already installed in $destdir.\nReplace it? [y]:"
"A version of $from is already installed in\n$destdir.\nReplace it? [y]:"
);
say 'Replacing it.';
system("/bin/rm -f $to");
}
else {
print "This version of $from is already installed in $destdir.\n";
print "This version of $from is already installed in\n$destdir.\n";
return;
}
}
Expand Down
20 changes: 11 additions & 9 deletions bin/pd
Expand Up @@ -7,17 +7,19 @@ use experimental 'smartmatch';
my $SINGLE_PAGE = `tput lines`;

my @CANDIDATES = (
'perldoc -f',
'perldoc',
'metapd',
'perldoc -q',
'man',
"perldoc -f @ARGV ",
"perldoc -v @ARGV ",
"perldoc @ARGV ",
"metapd @ARGV ",
"perldoc -q @ARGV ",
"man @ARGV ",
);

for my $command (@CANDIDATES) {
given (qx{ $command @ARGV 2>/dev/null }) {
when (/.*: nothing appropriate$/) { page( "Nothing found for '@ARGV'"); }
when (/\S/) { page( $_ ); }
@ARGV = map {qq{'$_'}} @ARGV;
for my $command (@CANDIDATES, q{}) {
given (qx{ $command 2>/dev/null }) {
when (/.*: nothing appropriate$/) { }
when (/\S/) { page( $_ ); }
}
}

Expand Down
29 changes: 25 additions & 4 deletions bin/perltests
@@ -1,12 +1,28 @@
#! /usr/bin/env perl
use 5.010;
use warnings;
use Time::HiRes 'time';

if (-e '.perltests') {
my $checks = do{ local (@ARGV,$/) = '.perltests'; readline };
if (!defined eval $checks . ';1;') {
my $error = $@;
$error =~ s{\A(.*) at .*}{$1}ms;
require Test::More;
Test::More::diag("Result: SKIP");
Test::More::diag("Reason: $error");
Test::More::diag('Tested under Perl '
. sprintf("%d.%d.%d in %0.2f sec\n", $]=~/(\d+)[.](\d\d\d)(\d*)/, 0)
);
exit;
}
}

my %opt;
@ARGV =
grep { /^-s\S*$/ ? do{ $opt{verbosity} = -2; () } : $_ }
grep { /^-v\S*$/ ? do{ $opt{verbosity} = 1; () } : $_ }
@ARGV;
@ARGV;

{
package TAP::Formatter::Console::NoTimeStamp;
Expand All @@ -22,8 +38,8 @@ my %opt;
}

# Locate Perl 5 tests, unless explicitly specified...
@ARGV = glob("*.t") unless @ARGV;
@ARGV = glob("t/*.t devt/*.t dt/*.t") unless @ARGV;
@ARGV = glob("*.t") unless @ARGV;
@ARGV = "test.pl" unless @ARGV || !-r "test.pl";

@ARGV = map { -d $_ ? glob("$_/*.t") : $_ } @ARGV;
Expand All @@ -39,7 +55,10 @@ my $harness = TAP::Harness->new({

require Test::More;
Test::More::diag('Testing under Perl ' . sprintf "%d.%d.%d\n", $]=~/(\d+)[.](\d\d\d)(\d*)/);
$harness->runtests( fix_6tests(@ARGV) ) if @ARGV;
my @fixed_tests = fix_6tests(@ARGV);
my $start = time;
$harness->runtests( @fixed_tests ) if @ARGV;
my $duration = time - $start;
say "Couldn't find any tests to run" if !@ARGV;


Expand All @@ -62,4 +81,6 @@ sub fix_6tests {
return @tests;
}

Test::More::diag('Tested under Perl ' . sprintf "%d.%d.%d\n", $]=~/(\d+)[.](\d\d\d)(\d*)/);
Test::More::diag('Tested under Perl '
. sprintf("%d.%d.%d in %0.2f sec\n", $]=~/(\d+)[.](\d\d\d)(\d*)/, $duration)
);
52 changes: 39 additions & 13 deletions bin/polyperl
Expand Up @@ -28,14 +28,20 @@ my $source_file;
my %config;
ARG:
while (my $arg = shift @ARGV) {
if ($arg =~ /^ -d $/x) { $config{debug} = 1; next ARG; }
if ($arg =~ /^ -m $/x) { $config{pager} = 1; next ARG; }
if ($arg =~ /^ -vc $/x) { $config{vim_compile} = 1; next ARG; }
if ($arg =~ /^ -p $/x) { $config{pause_after} = 1; next ARG; }
if ($arg eq '-d' ) { $config{debug} = 1; next ARG; }
if ($arg eq '-m' ) { $config{pager} = 1; next ARG; }
if ($arg eq '-c') { $config{vim_compile} = 1; next ARG; }
if ($arg eq '-p' ) { $config{pause_after} = 1; next ARG; }
if ($arg eq '-s' ) { $config{getopt} = 1; next ARG; }
if ($arg =~ /^-/ ) { $config{extraargs} .= " $arg "; next ARG; }

$source_file = $arg;
last ARG;
}
$config{extraargs} //= '';

# Grab the source...
my $source_code = slurp($source_file) // exit;

# Set up pager, if requested...
if ($config{pause_after}) {
Expand All @@ -47,8 +53,8 @@ if ($config{pager}) {
require IO::Page;
}

# Grab the source...
my $source_code = slurp($source_file) // exit;
# Is there to be regex debugging...
my $rxrx = $source_code =~ /^\s*use\s*Regexp::Debugger/m;

# Is there a shebang line???
my $shebang = $source_code =~ m{ \A \s* [#]! \s* ([^\n]+) }xms ? $1 : q{};
Expand Down Expand Up @@ -125,10 +131,13 @@ sub call_via_perlbrew {
}

# Which form of Perl???
my $perl = 'perl';
my $perl = 'perl' . $config_ref->{extraargs};
if ($config_ref->{debug}) {
$perl .= ' -d';
}
if ($config_ref->{getopt}) {
$perl .= ' -s';
}

# This will be a sub-shell usage of perlbrew...
$ENV{PERLBREW_SKIP_INIT} = 1;
Expand All @@ -150,41 +159,56 @@ sub call_via_perlbrew {

# Execute it...
if ($config_ref->{vim_compile}) {
_convert_to_vim_errors(`$ENV{SHELL} -c '$perl -c $command' >& /dev/stdout`);
my @errors = `$ENV{SHELL} -c '$perl -cw $command' >& /dev/stdout`;
if (@errors) {
print @errors;
}
else {
say q{No errors};
}
}
elsif (!$rxrx && $version =~ /^5\.\d\d/ && $shebang !~ /^\s*$|polyperl/ && $0 =~ m{\b motleyperl \Z}xms) {
system qq{$ENV{SHELL} -c '$perl $config_ref->{extraargs} -MTerm::Tint $command'};
}
else {
system qq{$ENV{SHELL} -c '$perl $command'};
system qq{$ENV{SHELL} -c '$perl $config_ref->{extraargs} $command'};
}
}

# Support :make error format in vim...
sub _convert_to_vim_errors {
my $warning = shift;
my $errors = 0;
my $messages;
for my $line (@_) {
chomp $line;
next if $line !~ m{\A (.*) \s at \s (.*) \s line \s (\d+) (.*) \Z}xms;
my ($message, $file, $lineno, $rest) = ($1, $2, $3, $4);
$message .= $rest if $rest =~ s/^,//;
say "$file:$lineno:$message";
$messages .= "$file:$lineno$warning:$message\n";
$errors++;
}
if (!$errors) {
open my $terminal, '>', '/dev/tty';
say $terminal q{No errors}
return "";
}
else {
return $messages;
}
}

# Use most appropriate perlbrew'd perl...
sub call_with_best_perl {
my ($source_code) = @_;
my ($source_code) = @_;

# Is there a specific Perl version specified???
my @version = get_version($source_code, qr{^ \s* use \s+}xms);
@version = get_version($DEFAULT_VERSION, q{}) if ! @version;

if ($version[0] == 6) {
if ($config{debug}) {
my $old_profile = quotemeta `terminal_profile grey report`;
system qq{$ENV{SHELL} -c '$PERL6-debug-m $source_file @ARGV'};
system qq{terminal_profile $old_profile};
}
else {
system qq{$ENV{SHELL} -c '$PERL6 $source_file @ARGV'};
Expand Down Expand Up @@ -233,3 +257,5 @@ sub call_with_best_perl {
# Normalize a X.Y.Z version number to XXXYYYZZZ...
sub normalize { @_ ? sprintf("%03d%03d%03d", split /[.]/, shift) : undef }

# Strip duplicates
sub unique { my %seen; grep {!$seen{$_}} @_ }

0 comments on commit cbe1fb5

Please sign in to comment.