From adb108ba6cf891781b58e03df866280a14d47265 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 27 Oct 2017 20:22:53 +1300 Subject: Use warn/die properly, bump version number --- Changes | 4 ++++ Makefile.PL | 2 +- README.markdown | 2 +- bin/runcrypt | 15 +++++---------- lib/Mail/Run/Crypt.pm | 12 ++++++------ t/custom-name.t | 2 +- t/encrypt-explicit.t | 2 +- t/encrypt-sign.t | 2 +- t/encrypt.t | 2 +- t/require-key-data.t | 6 +++--- t/require-mailto.t | 4 ++-- 11 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Changes b/Changes index 8bc1f98..35fd3b0 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,10 @@ Revision history for Perl module Mail::Run::Crypt This project began life as a monolithic Perl script. It does much the same thing now but it's refactored out into an application and a module. +0.09 2017-10-27 + + - Use warn/die as appropriate, rather than carp/croak. + 0.08 2017-10-23 - Some more tests, but still no proper mockup behaviour. diff --git a/Makefile.PL b/Makefile.PL index 1a8e325..6d342cc 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -31,7 +31,7 @@ WriteMakefile( 'meta-spec' => { version => 2 }, provides => { 'Mail::Run::Crypt' => { - version => '0.08', + version => '0.09', file => 'lib/Mail/Run/Crypt.pm', }, }, diff --git a/README.markdown b/README.markdown index 2553ba2..d223126 100644 --- a/README.markdown +++ b/README.markdown @@ -4,7 +4,7 @@ Mail::Run::Crypt - Encrypt and mail output from command runs # VERSION -Version 0.08 +Version 0.09 # DESCRIPTION diff --git a/bin/runcrypt b/bin/runcrypt index 159bac5..43e7287 100755 --- a/bin/runcrypt +++ b/bin/runcrypt @@ -10,14 +10,13 @@ use utf8; use 5.008_001; # Import required modules -use Carp; use English '-no_match_vars'; use File::stat; use Getopt::Long::Descriptive; use Mail::Run::Crypt; # Specify package version -our $VERSION = '0.08'; +our $VERSION = '0.09'; # Name ourselves our $SELF = 'runcrypt'; @@ -69,14 +68,14 @@ my ( $opt, $usage ) = describe_options( # Print help if requested if ( $opt->help ) { print $usage->text - or carp 'failed stdout usage write'; + or warn "Failed stdout usage write\n"; exit 0; } # Bail if run without arguments if ( !@ARGV ) { printf {*STDERR} $usage->text - or carp 'failed stderr usage write'; + or warn "Failed stderr usage write\n"; exit 2; } @@ -97,10 +96,10 @@ if ( defined $opt->passfile ) { $opts{passphrase} = do { local $RS = undef; open my $fh, '<', $fn - or croak "passfile $fn open failed: $ERRNO"; + or die "Passphrase file $fn open failed: $ERRNO\n"; my $passphrase = <$fh>; close $fh - or carp "passfile $fn close failed: $ERRNO"; + or die "Passphrase file $fn close failed: $ERRNO\n"; chomp $passphrase; $passphrase; }; @@ -256,10 +255,6 @@ Perl v5.8.1 or newer =item * -L - -=item * - L =item * diff --git a/lib/Mail/Run/Crypt.pm b/lib/Mail/Run/Crypt.pm index 1855e91..270866c 100644 --- a/lib/Mail/Run/Crypt.pm +++ b/lib/Mail/Run/Crypt.pm @@ -16,7 +16,7 @@ use Mail::GnuPG; use MIME::Entity; # Specify package verson -our $VERSION = '0.08'; +our $VERSION = '0.09'; # Default exit value our $DEFAULT_EXIT = 127; ## no critic (ProhibitMagicNumbers) @@ -30,7 +30,7 @@ sub new { # We must have a recipient defined $self->{mailto} - or croak 'mailto required'; + or croak 'MAILTO required'; # Default the instance name to the package name if it wasn't given; # runcrypt(1) will pass it in @@ -43,9 +43,9 @@ sub new { # If signing, we need a key ID and a passphrase if ( $self->{sign} ) { defined $self->{keyid} - or croak 'keyid required for signing'; + or croak 'Key ID required for signing'; defined $self->{passphrase} - or croak 'passphrase required for signing'; + or croak 'Passphrase required for signing'; } # Return objectified self @@ -59,7 +59,7 @@ sub run { # Run the command and wait for it to finish; keep its exit value for later my ( @out, @err ); eval { run3 \@command, undef, \@out, \@err } - or carp "command failed: $EVAL_ERROR"; + or warn "Command failed: $EVAL_ERROR\n"; $self->{exit} = $CHILD_ERROR >> 8; # If there was output, mail it @@ -138,7 +138,7 @@ Mail::Run::Crypt - Encrypt and mail output from command runs =head1 VERSION -Version 0.08 +Version 0.09 =head1 DESCRIPTION diff --git a/t/custom-name.t b/t/custom-name.t index 865c26d..ba053e3 100644 --- a/t/custom-name.t +++ b/t/custom-name.t @@ -8,7 +8,7 @@ use Test::More tests => 2; use Mail::Run::Crypt; -our $VERSION = '0.08'; +our $VERSION = '0.09'; my $name = 'mrc_custom'; my %opts = ( diff --git a/t/encrypt-explicit.t b/t/encrypt-explicit.t index 27b2e4d..24bc591 100644 --- a/t/encrypt-explicit.t +++ b/t/encrypt-explicit.t @@ -8,7 +8,7 @@ use Test::More tests => 2; use Mail::Run::Crypt; -our $VERSION = '0.08'; +our $VERSION = '0.09'; my %opts = ( mailto => 'nobody@example.com', encrypt => 1 ); my $mrc = Mail::Run::Crypt->new(%opts); diff --git a/t/encrypt-sign.t b/t/encrypt-sign.t index 1535bef..aeac091 100644 --- a/t/encrypt-sign.t +++ b/t/encrypt-sign.t @@ -8,7 +8,7 @@ use Test::More tests => 10; use Mail::Run::Crypt; -our $VERSION = '0.08'; +our $VERSION = '0.09'; my %opts = ( mailto => 'nobody@example.com', diff --git a/t/encrypt.t b/t/encrypt.t index a3ddd7c..3accd9c 100644 --- a/t/encrypt.t +++ b/t/encrypt.t @@ -8,7 +8,7 @@ use Test::More tests => 10; use Mail::Run::Crypt; -our $VERSION = '0.08'; +our $VERSION = '0.09'; my %opts = ( mailto => 'nobody@example.com' ); my $mrc = Mail::Run::Crypt->new(%opts); diff --git a/t/require-key-data.t b/t/require-key-data.t index 03be100..797175e 100644 --- a/t/require-key-data.t +++ b/t/require-key-data.t @@ -9,7 +9,7 @@ use Test::More tests => 4; use Mail::Run::Crypt; -our $VERSION = '0.08'; +our $VERSION = '0.09'; { my $mrc; @@ -21,7 +21,7 @@ our $VERSION = '0.08'; ); eval { $mrc = Mail::Run::Crypt->new(%opts) } or $error = $EVAL_ERROR; ok( defined $error, 'no_keyid_failed' ); - ok( $error =~ m/^\Qkeyid required for signing/msx, 'no_keyid_errorstr' ); + ok( $error =~ m/^\QKey ID required for signing/msx, 'no_keyid_errorstr' ); } { @@ -34,6 +34,6 @@ our $VERSION = '0.08'; ); eval { $mrc = Mail::Run::Crypt->new(%opts) } or $error = $EVAL_ERROR; ok( defined $error, 'no_passphrase_failed' ); - ok( $error =~ m/^\Qpassphrase required for signing/msx, + ok( $error =~ m/^\QPassphrase required for signing/msx, 'no_passphrase_errorstr' ); } diff --git a/t/require-mailto.t b/t/require-mailto.t index 89f069f..d5d8293 100644 --- a/t/require-mailto.t +++ b/t/require-mailto.t @@ -9,11 +9,11 @@ use Test::More tests => 2; use Mail::Run::Crypt; -our $VERSION = '0.08'; +our $VERSION = '0.09'; my $mrc; my $error; eval { $mrc = Mail::Run::Crypt->new() } or $error = $EVAL_ERROR; ok( defined $error, 'no_mailto_failed' ); -ok( $error =~ m/^\Qmailto required/msx, 'no_mailto_errorstr' ); +ok( $error =~ m/^\QMAILTO required/msx, 'no_mailto_errorstr' ); -- cgit v1.2.3