r73614 - in /branches/upstream/libproc-invokeeditor-perl/current: Changes META.yml lib/Proc/InvokeEditor.pm
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Tue Apr 26 21:08:34 UTC 2011
Author: periapt-guest
Date: Tue Apr 26 21:06:17 2011
New Revision: 73614
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=73614
Log:
[svn-upgrade] new version libproc-invokeeditor-perl (1.06)
Modified:
branches/upstream/libproc-invokeeditor-perl/current/Changes
branches/upstream/libproc-invokeeditor-perl/current/META.yml
branches/upstream/libproc-invokeeditor-perl/current/lib/Proc/InvokeEditor.pm
Modified: branches/upstream/libproc-invokeeditor-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-invokeeditor-perl/current/Changes?rev=73614&op=diff
==============================================================================
--- branches/upstream/libproc-invokeeditor-perl/current/Changes (original)
+++ branches/upstream/libproc-invokeeditor-perl/current/Changes Tue Apr 26 21:06:17 2011
@@ -21,3 +21,6 @@
1.05 19 Feb 2011
- Fix README
+
+1.06 25 Apr 2011
+ - Apply patch from Jesse Luehrs to optionally reuse temp file names.
Modified: branches/upstream/libproc-invokeeditor-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-invokeeditor-perl/current/META.yml?rev=73614&op=diff
==============================================================================
--- branches/upstream/libproc-invokeeditor-perl/current/META.yml (original)
+++ branches/upstream/libproc-invokeeditor-perl/current/META.yml Tue Apr 26 21:06:17 2011
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Proc-InvokeEditor
-version: 1.05
+version: 1.06
abstract: Interface to external editor from perl
author:
- Michael Stevens <mstevens at etla.org>
@@ -19,7 +19,7 @@
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.55_02
+generated_by: ExtUtils::MakeMaker version 6.56
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: branches/upstream/libproc-invokeeditor-perl/current/lib/Proc/InvokeEditor.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-invokeeditor-perl/current/lib/Proc/InvokeEditor.pm?rev=73614&op=diff
==============================================================================
--- branches/upstream/libproc-invokeeditor-perl/current/lib/Proc/InvokeEditor.pm (original)
+++ branches/upstream/libproc-invokeeditor-perl/current/lib/Proc/InvokeEditor.pm Tue Apr 26 21:06:17 2011
@@ -32,7 +32,7 @@
@EXPORT = qw(
);
-$VERSION = '1.05';
+$VERSION = '1.06';
@DEFAULT_EDITORS = ( $ENV{'VISUAL'}, $ENV{'EDITOR'}, '/usr/bin/vi',
'/bin/vi', '/bin/ed'
@@ -44,10 +44,11 @@
my $self = {
'editors' => \@DEFAULT_EDITORS,
'cleanup' => 1,
+ 'keep_file' => 0,
};
croak("$class requires an even number of parameters") if @_ % 2;
my %args = @_;
- foreach my $param (qw(editors cleanup)) {
+ foreach my $param (qw(editors cleanup keep_file)) {
if ($args{$param}) {
$self->{$param} = $args{$param};
}
@@ -100,6 +101,13 @@
return $self->{'cleanup'};
}
+sub keep_file {
+ my $self = shift;
+ my $keep_file = shift;
+ $self->{'keep_file'} = $keep_file if defined $keep_file;
+ return $self->{'keep_file'};
+}
+
sub edit {
my $self = shift;
my $arg = shift;
@@ -111,9 +119,16 @@
}
my $result;
if (ref($self)) {
- $result = _edit($arg, $self->{'editors'}, $self->{'cleanup'}, $suff);
+ ($result, $self->{'filename'}) = _edit(
+ $arg,
+ $self->{'editors'},
+ $self->{'cleanup'},
+ $self->{'keep_file'},
+ $self->{'filename'},
+ $suff,
+ );
} else {
- $result = _edit($arg, \@DEFAULT_EDITORS, 1, $suff);
+ ($result) = _edit($arg, \@DEFAULT_EDITORS, 1, 0, undef, $suff);
}
if (wantarray) {
my @result = split m|$/|, $result;
@@ -167,6 +182,8 @@
my $string = shift;
my $er = shift;
my $unlink = shift;
+ my $keep_file = shift;
+ my $filename = shift;
my $suff = shift;
assert(ref($er) eq 'ARRAY');
@@ -180,9 +197,17 @@
@suff = (SUFFIX => $suff) if $suff;
# get a temp file, and write the text to it
- my ($fh, $filename) = tempfile(UNLINK => $unlink, @suff);
- print $fh $string;
- close $fh or die "Couldn't close tempfile [$filename]; $!";
+ if (defined($filename) && $keep_file) {
+ open my $fh, '>', $filename or die "Couldn't open tempfile [$filename]; $!";
+ print $fh $string;
+ close $fh or die "Couldn't close tempfile [$filename]; $!";
+ }
+ else {
+ my $fh;
+ ($fh, $filename) = tempfile(UNLINK => $unlink, @suff);
+ print $fh $string;
+ close $fh or die "Couldn't close tempfile [$filename]; $!";
+ }
# start the editor
my $rc = system @$chosen_editor, $filename;
# check what happened - die if it all went wrong.
@@ -200,7 +225,12 @@
{ local $/; $result = <FH>; }
close FH or die "Couldn't close [$filename]: $!";
# return as string
- return $result;
+ if ($keep_file) {
+ return ($result, $filename);
+ }
+ else {
+ return ($result);
+ }
}
1;
@@ -254,6 +284,12 @@
This specifies whether the temporary file created should be unlinked
when the program exits. The default is to unlink the file.
+=item C<keep_file>
+
+This specifies whether to reuse the same temporary file between invocations
+of C<edit> on the same Proc::InvokeEditor object. The default is to use a
+new file each time.
+
=back
=head2 editors()
@@ -283,6 +319,13 @@
from the object. If an argument is supplied, it changes the value and
returns the new object. The argument should be any true or false value.
+=head2 keep_file()
+
+This method gets or sets whether to reuse temporary files. If no
+argument is supplied, it returns the current value from the object. If
+an argument is supplied, it changes the value and returns the new
+object. The argument should be any true or false value.
+
=head2 first_usable()
This method can be called either as a class method, in which it
More information about the Pkg-perl-cvs-commits
mailing list