line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
772
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
131
|
|
2
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
185
|
|
3
|
|
|
|
|
|
|
package App::Nopaste; # git description: 1.012-12-g5acc073 |
4
|
|
|
|
|
|
|
# ABSTRACT: Easy access to any pastebin |
5
|
|
|
|
|
|
|
# KEYWORDS: application executable paste output pastebin debugging |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.013'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
75
|
use 5.008003; |
|
4
|
|
|
|
|
14
|
|
10
|
4
|
|
|
4
|
|
2058
|
use Module::Pluggable search_path => 'App::Nopaste::Service', sub_name => '_plugins'; |
|
4
|
|
|
|
|
37699
|
|
|
4
|
|
|
|
|
26
|
|
11
|
4
|
|
|
4
|
|
2235
|
use Class::Load 'load_class'; |
|
4
|
|
|
|
|
31520
|
|
|
4
|
|
|
|
|
247
|
|
12
|
4
|
|
|
4
|
|
1963
|
use namespace::clean 0.19; |
|
4
|
|
|
|
|
29506
|
|
|
4
|
|
|
|
|
26
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
2052
|
use parent 'Exporter'; |
|
4
|
|
|
|
|
582
|
|
|
4
|
|
|
|
|
32
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = 'nopaste'; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
0
|
128
|
sub plugins { goto \&_plugins }; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub nopaste { |
20
|
|
|
|
|
|
|
# process arguments |
21
|
|
|
|
|
|
|
# allow "nopaste($text)" |
22
|
2
|
50
|
|
2
|
1
|
10
|
unshift @_, 'text' if @_ == 1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# only look for $self if we have odd number of arguments |
25
|
2
|
|
|
|
|
4
|
my $self; |
26
|
2
|
50
|
|
|
|
12
|
$self = @_ % 2 ? shift : __PACKAGE__; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# everything else |
29
|
2
|
|
|
|
|
11
|
my %args = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$args{services} = defined($ENV{NOPASTE_SERVICES}) |
32
|
|
|
|
|
|
|
&& [split ' ', $ENV{NOPASTE_SERVICES}] |
33
|
2
|
50
|
0
|
|
|
8
|
if !defined($args{services}); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$args{nick} = $ENV{NOPASTE_NICK} || $ENV{USER} |
36
|
2
|
50
|
0
|
|
|
6
|
if !defined($args{nick}); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
5
|
my $using_default = 0; |
40
|
2
|
50
|
33
|
|
|
10
|
unless (ref($args{services}) eq 'ARRAY' && @{$args{services}}) { |
|
2
|
|
|
|
|
7
|
|
41
|
0
|
|
|
|
|
0
|
$using_default = 1; |
42
|
0
|
|
|
|
|
0
|
$args{services} = [ $self->plugins ]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
2
|
50
|
|
|
|
5
|
@{ $args{services} } |
|
2
|
|
|
|
|
12
|
|
46
|
|
|
|
|
|
|
or Carp::croak "No App::Nopaste::Service module found"; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
defined $args{text} |
49
|
2
|
50
|
|
|
|
9
|
or Carp::croak "You must specify the text to nopaste"; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$args{error_handler} ||= sub { |
52
|
0
|
|
|
0
|
|
0
|
my ($msg, $srv) = @_; |
53
|
0
|
|
|
|
|
0
|
$msg =~ s/\n*$/\n/; |
54
|
0
|
|
|
|
|
0
|
warn "$srv: $msg" |
55
|
2
|
|
50
|
|
|
22
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# try to paste to each service in order |
58
|
2
|
|
|
|
|
2
|
for my $service (@{ $args{services} }) { |
|
2
|
|
|
|
|
8
|
|
59
|
2
|
50
|
|
|
|
13
|
$service = "App::Nopaste::Service::$service" |
60
|
|
|
|
|
|
|
unless $service =~ /^App::Nopaste::Service/; |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
4
|
|
1500
|
no warnings 'exiting'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
1016
|
|
63
|
2
|
|
|
|
|
4
|
my @ret = eval { |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
66
|
0
|
|
|
0
|
|
0
|
$args{warn_handler}->($_[0], $service); |
67
|
2
|
50
|
|
|
|
7
|
} if $args{warn_handler}; |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
13
|
load_class($service); |
70
|
|
|
|
|
|
|
|
71
|
2
|
50
|
|
|
|
228
|
next unless $service->available(%args); |
72
|
2
|
50
|
33
|
|
|
12
|
next if $using_default && $service->forbid_in_default; |
73
|
2
|
|
|
|
|
17
|
$service->nopaste(%args); |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
2
|
50
|
|
|
|
97
|
@ret = (0, $@) if $@; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# success! |
79
|
2
|
50
|
|
|
|
20
|
return $ret[1] if $ret[0]; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# failure! |
82
|
0
|
|
|
|
|
|
$args{error_handler}->($ret[1], $service); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
Carp::croak "No available App::Nopaste::Service modules found"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |