diff --git a/dist.ini b/dist.ini index 28caba758..1113f0ef9 100644 --- a/dist.ini +++ b/dist.ini @@ -35,7 +35,7 @@ App::cpanminus = 0 PPI::XS = 0 [Prereqs] -perl = v5.20.0 +perl = v5.14.0 parent = 0 ; used by the AutoPrereq test corpus @@ -87,3 +87,13 @@ Dist::Zilla::Plugin::NameFromDirectory = <= 0.03 :version = 0.017 conflicts_module = Moose::Conflicts conflicts_module = Module::Runtime::Conflicts + +[Babble] +plugin = ::CoreSignatures +plugin = ::PostfixDeref + +[Substitute / Pragmas] +file = lib/Dist/Zilla/Pragmas.pm +mode = whole +code = s/use v5.20.0/use v5.14.0/; +code = s/^#begin babble.*?^#end babble\n//gsm; diff --git a/lib/Dist/Zilla.pm b/lib/Dist/Zilla.pm index 143134510..e2fc058a9 100644 --- a/lib/Dist/Zilla.pm +++ b/lib/Dist/Zilla.pm @@ -19,7 +19,7 @@ use Dist::Zilla::Path; use List::Util 1.33 qw(first none); use Software::License 0.104001; # ->program use String::RewritePrefix; -use Try::Tiny; +use Feature::Compat::Try; use Dist::Zilla::Prereqs; use Dist::Zilla::File::OnDisk; @@ -469,8 +469,10 @@ has authors => ( return $stash->authors; } - my $author = try { $self->copyright_holder }; - return [ $author ] if length $author; + try { + my $author = $self->copyright_holder; + return [ $author ] if length $author; + } catch ($e) { } $self->log_fatal( "No %User stash and no copyright holder;", diff --git a/lib/Dist/Zilla/App.pm b/lib/Dist/Zilla/App.pm index bb7cc8aca..f9a9fad1a 100644 --- a/lib/Dist/Zilla/App.pm +++ b/lib/Dist/Zilla/App.pm @@ -6,7 +6,8 @@ use Dist::Zilla::Pragmas; use App::Cmd::Setup 0.330 -app; # better compilation error detection use Carp (); -use Try::Tiny; +use Feature::Compat::Try; +use Scalar::Util 'blessed'; use namespace::autoclean; @@ -63,8 +64,7 @@ sub _build_global_stashes { }); my $seq = $reader->read_config($config_base, { assembler => $assembler }); - } catch { - my $e = $_; + } catch($e) { if (eval { $e->isa('Config::MVP::Error') and $e->ident eq 'package not installed' }) { my $package = $e->package; @@ -88,7 +88,7 @@ and deleting any [!new] stanza. You can also delete the existing file and run "dzil setup" END_DIE } - }; + } return $stash_registry; } @@ -141,11 +141,11 @@ sub zilla { chrome => $self->chrome, _global_stashes => $self->_build_global_stashes, }); - } catch { - die $_ unless try { $_->isa('Config::MVP::Error') } - && $_->ident =~ /no viable config/; + } catch($e) { + die $e unless blessed($e) && $e->isa('Config::MVP::Error') + && $e->ident =~ /no viable config/; $self->chrome->logger->log_fatal("no configuration (e.g, dist.ini) found"); - }; + } $zilla->logger->set_debug($verbose ? 1 : 0); diff --git a/lib/Dist/Zilla/Dist/Builder.pm b/lib/Dist/Zilla/Dist/Builder.pm index 15078bc88..06b2dae15 100644 --- a/lib/Dist/Zilla/Dist/Builder.pm +++ b/lib/Dist/Zilla/Dist/Builder.pm @@ -11,8 +11,9 @@ use Dist::Zilla::Types qw(Path); use File::pushd (); use Dist::Zilla::Path; # because more Path::* is better, eh? -use Try::Tiny; +use Feature::Compat::Try; use List::Util 1.45 'uniq'; +use Scalar::Util 'blessed'; use Module::Runtime 'require_module'; use namespace::autoclean; @@ -285,22 +286,20 @@ sub _load_config { if $arg->{_global_stashes}; } - my $seq; try { - $seq = $config_class->read_config( + return $config_class->read_config( $root->child('dist'), { assembler => $assembler }, ); - } catch { - die $_ unless try { - $_->isa('Config::MVP::Error') - and $_->ident eq 'package not installed' - }; + } catch($e) { + die $e unless + blessed($e) and $e->isa('Config::MVP::Error') + and $e->ident eq 'package not installed'; - my $package = $_->package; - my $bundle = $_->section_name =~ m{^@(?!.*/)} ? ' bundle' : ''; + my $package = $e->package; + my $bundle = $e->section_name =~ m{^@(?!.*/)} ? ' bundle' : ''; die <<"END_DIE"; Required plugin$bundle $package isn't installed. @@ -312,9 +311,7 @@ You can pipe the list to your CPAN client to install or update them: END_DIE - }; - - return $seq; + } } =method build_in diff --git a/lib/Dist/Zilla/Plugin/MetaYAML.pm b/lib/Dist/Zilla/Plugin/MetaYAML.pm index becd64a32..05da59a6e 100644 --- a/lib/Dist/Zilla/Plugin/MetaYAML.pm +++ b/lib/Dist/Zilla/Plugin/MetaYAML.pm @@ -6,7 +6,7 @@ with 'Dist::Zilla::Role::FileGatherer'; use Dist::Zilla::Pragmas; -use Try::Tiny; +use Feature::Compat::Try; use namespace::autoclean; =head1 DESCRIPTION @@ -59,13 +59,12 @@ sub gather_files { $output->{x_serialization_backend} = sprintf '%s version %s', 'YAML::Tiny', YAML::Tiny->VERSION; - my $yaml = try { - YAML::Tiny->new($output)->write_string; # text! + try { + return YAML::Tiny->new($output)->write_string; # text! } - catch { + catch($e) { $self->log_fatal("Could not create YAML string: " . YAML::Tiny->errstr) - }; - return $yaml; + } }, }); diff --git a/lib/Dist/Zilla/Plugin/UploadToCPAN.pm b/lib/Dist/Zilla/Plugin/UploadToCPAN.pm index c1e3f67ec..0219a42c8 100644 --- a/lib/Dist/Zilla/Plugin/UploadToCPAN.pm +++ b/lib/Dist/Zilla/Plugin/UploadToCPAN.pm @@ -11,7 +11,7 @@ use File::Spec; use Moose::Util::TypeConstraints; use Scalar::Util qw(weaken); use Dist::Zilla::Util; -use Try::Tiny; +use Feature::Compat::Try; use namespace::autoclean; @@ -188,13 +188,12 @@ has pause_cfg => ( $file = File::Spec->catfile($self->pause_cfg_dir, $file) unless File::Spec->file_name_is_absolute($file); return {} unless -e $file && -r _; - my $cfg = try { - CPAN::Uploader->read_config_file($file) - } catch { - $self->log("Couldn't load credentials from '$file': $_"); - {}; - }; - return $cfg; + try { + return CPAN::Uploader->read_config_file($file) + } catch($e) { + $self->log("Couldn't load credentials from '$file': $e"); + return {}; + } }, ); @@ -292,9 +291,9 @@ sub before_release { die unless length $self->$attr; } undef $problem; - }; - - $self->log_fatal(['You need to supply a %s', $problem]) if $problem; + } catch($e) { + $self->log_fatal(['You need to supply a %s', $problem]) if $problem; + } } sub release { diff --git a/lib/Dist/Zilla/Pragmas.pm b/lib/Dist/Zilla/Pragmas.pm index 3d3f80689..9eedd850d 100644 --- a/lib/Dist/Zilla/Pragmas.pm +++ b/lib/Dist/Zilla/Pragmas.pm @@ -15,12 +15,14 @@ sub import { feature->import(':5.20'); feature->unimport('switch'); +#begin babble experimental->import(qw( lexical_subs postderef postderef_qq signatures )); +#end babble feature->unimport('multidimensional') if $] >= 5.034; } diff --git a/lib/Dist/Zilla/Role/File.pm b/lib/Dist/Zilla/Role/File.pm index 2e1acad07..664121774 100644 --- a/lib/Dist/Zilla/Role/File.pm +++ b/lib/Dist/Zilla/Role/File.pm @@ -7,7 +7,7 @@ use Dist::Zilla::Pragmas; use Dist::Zilla::Types qw(_Filename); use Moose::Util::TypeConstraints; -use Try::Tiny; +use Feature::Compat::Try; use namespace::autoclean; @@ -128,10 +128,8 @@ sub _encode { } else { require Encode; - my $bytes = - try { Encode::encode($enc, $text, Encode::FB_CROAK()) } - catch { $self->_throw("encode $enc" => $_) }; - return $bytes; + try { return Encode::encode($enc, $text, Encode::FB_CROAK()) } + catch($e) { $self->_throw("encode $enc" => $e) } } } @@ -143,25 +141,27 @@ sub _decode { } else { require Encode; - my $text = - try { Encode::decode($enc, $bytes, Encode::FB_CROAK()) } - catch { $self->_throw("decode $enc" => $_) }; - - # Okay, look, buddy… If you're using a BOM on UTF-8, that's fine. You can - # use it. You're just not going to get it back. If we don't do this, the - # sequence of events will be: - # * read file from UTF-8-BOM file on disk - # * end up with FEFF as first character of file - # * pass file content to PPI - # * PPI blows up - # - # I'm not going to try to account for the BOM and add it back. It's awful! - # - # Meanwhile, if you're using UTF-16, you can get the BOM handled by picking - # the right encoding type, I think. -- rjbs, 2016-04-24 - $enc =~ /^utf-?8$/i && $text =~ s/\A\x{FEFF}//; - - return $text; + try { + my $text = Encode::decode($enc, $bytes, Encode::FB_CROAK()); + + # Okay, look, buddy… If you're using a BOM on UTF-8, that's fine. You can + # use it. You're just not going to get it back. If we don't do this, the + # sequence of events will be: + # * read file from UTF-8-BOM file on disk + # * end up with FEFF as first character of file + # * pass file content to PPI + # * PPI blows up + # + # I'm not going to try to account for the BOM and add it back. It's awful! + # + # Meanwhile, if you're using UTF-16, you can get the BOM handled by picking + # the right encoding type, I think. -- rjbs, 2016-04-24 + $enc =~ /^utf-?8$/i && $text =~ s/\A\x{FEFF}//; + + return $text; + } catch($e) { + $self->_throw("decode $enc" => $e) + } } } diff --git a/t/compile.t b/t/compile.t index 3b5a5fbc9..dfe8cdb0e 100644 --- a/t/compile.t +++ b/t/compile.t @@ -3,7 +3,6 @@ use warnings; use Test::More; use File::Find::Rule; -use Try::Tiny; my @files = File::Find::Rule->name('*.pm')->in('lib'); plan tests => @files - 1;