| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: Utility class for authoring commit messages |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Pinto::Editor; |
|
4
|
|
|
|
|
|
|
|
|
5
|
57
|
|
|
57
|
|
407
|
use Moose; |
|
|
57
|
|
|
|
|
131
|
|
|
|
57
|
|
|
|
|
367
|
|
|
6
|
57
|
|
|
57
|
|
340713
|
use File::Temp; |
|
|
57
|
|
|
|
|
40862
|
|
|
|
57
|
|
|
|
|
4192
|
|
|
7
|
57
|
|
|
57
|
|
19364
|
use Pinto::Editor::Edit; |
|
|
57
|
|
|
|
|
226
|
|
|
|
57
|
|
|
|
|
19587
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.13'; # VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub EDITOR { |
|
16
|
0
|
|
0
|
0
|
0
|
|
return $ENV{VISUAL} || $ENV{EDITOR}; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $__singleton__; |
|
22
|
|
|
|
|
|
|
sub __singleton__ { |
|
23
|
0
|
|
0
|
0
|
|
|
return $__singleton__ ||=__PACKAGE__->new; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub edit_file { |
|
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
30
|
0
|
|
|
|
|
|
my $file = shift; |
|
31
|
0
|
0
|
|
|
|
|
die "*** Missing editor (No \$VISUAL or \$EDITOR)\n" unless my $editor = $self->EDITOR; |
|
32
|
0
|
|
|
|
|
|
my $rc = system $editor, $file; |
|
33
|
0
|
0
|
|
|
|
|
unless ( $rc == 0 ) { |
|
34
|
0
|
|
|
|
|
|
my ($exit_value, $signal, $core_dump); |
|
35
|
0
|
|
|
|
|
|
$exit_value = $? >> 8; |
|
36
|
0
|
|
|
|
|
|
$signal = $? & 127; |
|
37
|
0
|
|
|
|
|
|
$core_dump = $? & 128; |
|
38
|
0
|
|
|
|
|
|
die "Error during edit ($editor): exit value($exit_value), signal($signal), core_dump($core_dump): $!"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub edit { |
|
45
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
46
|
0
|
0
|
|
|
|
|
$self = $self->__singleton__ unless blessed $self; |
|
47
|
0
|
|
|
|
|
|
my %given = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $document = delete $given{document}; |
|
50
|
0
|
0
|
|
|
|
|
$document = '' unless defined $document; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $file = delete $given{file}; |
|
53
|
0
|
0
|
|
|
|
|
$file = $self->tmp unless defined $file; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $edit = Pinto::Editor::Edit->new( |
|
56
|
|
|
|
|
|
|
editor => $self, |
|
57
|
|
|
|
|
|
|
file => $file, |
|
58
|
|
|
|
|
|
|
document => $document, |
|
59
|
|
|
|
|
|
|
%given, # process, split, ... |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $edit->edit; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
0
|
|
sub tmp { return File::Temp->new( unlink => 1 ) } |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
70
|
|
|
|
|
|
|
1; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=for :stopwords Jeffrey Ryan Thalhammer |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Pinto::Editor - Utility class for authoring commit messages |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.13 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is a forked version of L<Term::EditorEdit> which does not use the deprecated |
|
89
|
|
|
|
|
|
|
module L<Any::Moose>. My thanks to Robert Krimen for authoring the original. |
|
90
|
|
|
|
|
|
|
No user-servicable parts in here. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@stratopan.com> |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
101
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
108
|
|
|
|
|
|
|
|