line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Pastebin::Many::Retrieve; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
115957
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
7
|
1
|
|
|
1
|
|
10
|
use Carp; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
66
|
|
8
|
1
|
|
|
1
|
|
354
|
use WWW::Pastebin::NoMorePastingCom::Retrieve; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use WWW::Pastebin::PastebinCa::Retrieve; |
10
|
|
|
|
|
|
|
use WWW::Pastebin::PastebinCom::Retrieve; |
11
|
|
|
|
|
|
|
use WWW::Pastebin::PastieCabooSe::Retrieve; |
12
|
|
|
|
|
|
|
use WWW::Pastebin::PhpfiCom::Retrieve; |
13
|
|
|
|
|
|
|
use WWW::Pastebin::RafbNet::Retrieve; |
14
|
|
|
|
|
|
|
use WWW::Pastebin::UbuntuNlOrg::Retrieve; |
15
|
|
|
|
|
|
|
use base 'Class::Data::Accessor'; |
16
|
|
|
|
|
|
|
__PACKAGE__->mk_classaccessors qw( |
17
|
|
|
|
|
|
|
_res |
18
|
|
|
|
|
|
|
_objs |
19
|
|
|
|
|
|
|
content |
20
|
|
|
|
|
|
|
response |
21
|
|
|
|
|
|
|
error |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use overload q|""| => sub { shift->content }; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
|
|
|
|
|
|
my $self = bless {}, shift; |
28
|
|
|
|
|
|
|
croak "Must have even number of arguments to new()" |
29
|
|
|
|
|
|
|
if @_ & 1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my %args = @_; |
32
|
|
|
|
|
|
|
$args{ +lc } = delete $args{ $_ } for keys %args; |
33
|
|
|
|
|
|
|
$args{timeout} ||= 30; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my %objs = ( |
36
|
|
|
|
|
|
|
no_more_pasting => WWW::Pastebin::NoMorePastingCom::Retrieve->new( |
37
|
|
|
|
|
|
|
timeout => $args{timeout}, |
38
|
|
|
|
|
|
|
), |
39
|
|
|
|
|
|
|
pastebin_ca => WWW::Pastebin::PastebinCa::Retrieve->new( |
40
|
|
|
|
|
|
|
timeout => $args{timeout}, |
41
|
|
|
|
|
|
|
), |
42
|
|
|
|
|
|
|
pastebin_com => WWW::Pastebin::PastebinCom::Retrieve->new( |
43
|
|
|
|
|
|
|
timeout => $args{timeout}, |
44
|
|
|
|
|
|
|
), |
45
|
|
|
|
|
|
|
pastie_caboo_se => WWW::Pastebin::PastieCabooSe::Retrieve->new( |
46
|
|
|
|
|
|
|
timeout => $args{timeout}, |
47
|
|
|
|
|
|
|
), |
48
|
|
|
|
|
|
|
phpfi_com => WWW::Pastebin::PhpfiCom::Retrieve->new( |
49
|
|
|
|
|
|
|
timeout => $args{timeout}, |
50
|
|
|
|
|
|
|
), |
51
|
|
|
|
|
|
|
rafb_net => WWW::Pastebin::RafbNet::Retrieve->new( |
52
|
|
|
|
|
|
|
timeout => $args{timeout}, |
53
|
|
|
|
|
|
|
), |
54
|
|
|
|
|
|
|
ubuntu_nl_org => WWW::Pastebin::UbuntuNlOrg::Retrieve->new( |
55
|
|
|
|
|
|
|
timeout => $args{timeout}, |
56
|
|
|
|
|
|
|
), |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my %res = ( |
60
|
|
|
|
|
|
|
no_more_pasting => qr{^ |
61
|
|
|
|
|
|
|
(?:http://)? |
62
|
|
|
|
|
|
|
(?:www\.)? |
63
|
|
|
|
|
|
|
\Qnomorepasting.com/getpaste.php?\E |
64
|
|
|
|
|
|
|
}xi, |
65
|
|
|
|
|
|
|
pastebin_ca => qr{(?:http://)? (?:www\.)? \S*? pastebin\.ca/}xi, |
66
|
|
|
|
|
|
|
pastebin_com => qr{(?:http://)? (?:www\.)?\S*? pastebin\.com/}xi, |
67
|
|
|
|
|
|
|
pastie_caboo_se => qr{ |
68
|
|
|
|
|
|
|
(?:http://)? (?:www\.)? |
69
|
|
|
|
|
|
|
\Qpastie.caboo.se/\E |
70
|
|
|
|
|
|
|
(\d+) |
71
|
|
|
|
|
|
|
/? |
72
|
|
|
|
|
|
|
}xi, |
73
|
|
|
|
|
|
|
phpfi_com => qr{(?:http://)? (?:www\.)? phpfi\.com/(?=\d+)}xi, |
74
|
|
|
|
|
|
|
rafb_net => qr{ |
75
|
|
|
|
|
|
|
(?:http://)? (?:www\.)? rafb.net/p/ (\S+?) \.html |
76
|
|
|
|
|
|
|
}ix, |
77
|
|
|
|
|
|
|
ubuntu_nl_org => qr{ |
78
|
|
|
|
|
|
|
(?:http://)? (?:www\.)? paste\.ubuntu-nl\.org/ (\d+) /? |
79
|
|
|
|
|
|
|
}xi, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$self->_objs( \%objs ); |
83
|
|
|
|
|
|
|
$self->_res( \%res ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub retrieve { |
89
|
|
|
|
|
|
|
my ( $self, $uri ) = @_; |
90
|
|
|
|
|
|
|
my $res_ref = $self->_res; |
91
|
|
|
|
|
|
|
my $objs_ref = $self->_objs; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$self->$_(undef) for qw(error content response); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
keys %$res_ref; |
96
|
|
|
|
|
|
|
while ( my ( $pastebin, $re ) = each %$res_ref ) { |
97
|
|
|
|
|
|
|
if ( $uri =~ $re ) { |
98
|
|
|
|
|
|
|
my $obj = $objs_ref->{$pastebin}; |
99
|
|
|
|
|
|
|
my $response_ref = $obj->retrieve( $uri ) |
100
|
|
|
|
|
|
|
or return $self->_set_error( $obj->error ); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$self->content( $obj->content ); |
103
|
|
|
|
|
|
|
return $self->response( $response_ref ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
return $self->_set_error( |
107
|
|
|
|
|
|
|
'Your URI did not match any pastebin I can handle' |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _set_error { |
112
|
|
|
|
|
|
|
my ( $self, $error ) = @_; |
113
|
|
|
|
|
|
|
$self->error( $error ); |
114
|
|
|
|
|
|
|
return; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
__END__ |