| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Padre::Plugin::Nopaste::Task; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
98437
|
use v5.10; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
48
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
70
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
41
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Carp qw( croak ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
84
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
499
|
use Padre::Task (); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Padre::Unload (); |
|
12
|
|
|
|
|
|
|
use App::Nopaste 'nopaste'; |
|
13
|
|
|
|
|
|
|
use parent qw{ Padre::Task }; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
####### |
|
17
|
|
|
|
|
|
|
# Default Constructor from Padre::Task POD |
|
18
|
|
|
|
|
|
|
####### |
|
19
|
|
|
|
|
|
|
sub new { |
|
20
|
|
|
|
|
|
|
my $class = shift; |
|
21
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Assert required command parameter |
|
24
|
|
|
|
|
|
|
if ( not defined $self->{text} ) { |
|
25
|
|
|
|
|
|
|
croak "Failed to provide any text to the Nopaste task\n"; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return $self; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
####### |
|
32
|
|
|
|
|
|
|
# Default run re: Padre::Task POD |
|
33
|
|
|
|
|
|
|
####### |
|
34
|
|
|
|
|
|
|
sub run { |
|
35
|
|
|
|
|
|
|
my $self = shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $url = nopaste( |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# text => "Full text to paste (the only mandatory argument)", |
|
40
|
|
|
|
|
|
|
text => $self->{text}, |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# desc => "This is a test no-paste", |
|
43
|
|
|
|
|
|
|
nick => $self->{nick}, |
|
44
|
|
|
|
|
|
|
lang => 'perl', |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# chan => '#padre', |
|
47
|
|
|
|
|
|
|
chan => $self->{channel}, |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# private => 1, # default: 0 |
|
50
|
|
|
|
|
|
|
# # this is the default, but maybe you want to do something different |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
error_handler => sub { |
|
53
|
|
|
|
|
|
|
my ( $error, $service ) = @_; |
|
54
|
|
|
|
|
|
|
$self->{error} = 1; |
|
55
|
|
|
|
|
|
|
$self->{message} = "$service: $error"; |
|
56
|
|
|
|
|
|
|
}, |
|
57
|
|
|
|
|
|
|
warn_handler => sub { |
|
58
|
|
|
|
|
|
|
my ( $warning, $service ) = @_; |
|
59
|
|
|
|
|
|
|
$self->{error} = 1; |
|
60
|
|
|
|
|
|
|
$self->{message} = "$service: $warning"; |
|
61
|
|
|
|
|
|
|
}, |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# you may specify the services to use - but you don't have to |
|
64
|
|
|
|
|
|
|
services => [ $self->{services}, ], |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# show result in output section |
|
68
|
|
|
|
|
|
|
if ( defined $url ) { |
|
69
|
|
|
|
|
|
|
my $text_output = "Text successfully nopasted at: $url\n"; |
|
70
|
|
|
|
|
|
|
$self->{error} = 0; |
|
71
|
|
|
|
|
|
|
$self->{message} = $text_output; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |