Plugin/WWW/Cache/Google.pm

filter: Statementstmt 33.3% 14 / 42 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod n/a totaltotal 29.5% 18 / 61 CC 6 SCAR 20.8
CC
6
Cov
27%
_make_response_message
20.0
_make_response_event
6.0
_make_poco_call
6.0
CRAP 8.0
« Plugin/WWW/DoctypeGrabber.pm ↑ Summary Plugin/Syntax/Highlight/HTML.pm »
1 package POE::Component::IRC::Plugin::WWW::Cache::Google;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '2.001004'; # VERSION
7  
8 1 ▶use base 'POE::Component::IRC::Plugin::BasePoCoWrap';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use POE::Component::WWW::Cache::Google;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub _make_default_args {
Subroutine _make_default_args: not called CC=1 SCAR=6.9
12 return (
13 0 response_event => 'irc_google_cache',
14 trigger => qr/^cache\s+(?=\S)/i,
15 line_length => 350,
16 );
17 }
18  
19 0 ▶sub _make_poco {
Subroutine _make_poco: not called CC=1 SCAR=6.9
20 return POE::Component::WWW::Cache::Google->spawn(
21 debug => shift->{debug},
22 0 );
23 }
24  
25 0 ▶sub _make_response_message {
Subroutine _make_response_message: not called CC=4 SCAR=30.0
26 0 my $self = shift;
27 0 my $in_ref = shift;
28  
29 0 delete $in_ref->{content};
30  
31 0 my $out;
32 0 ▶ if ( defined $in_ref->{error} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $in_ref->{'error'}) { } 0 0 0
33 0 ▶ if ( $in_ref->{error} eq q|Doesn't look like cache exists| ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_ref->{'error'} eq q[Doesn't look like cache exists]) { } 0 0 0
34 0 $out = "No google cache found for $in_ref->{uri}";
35 }
36 else {
37 0 $out = "Error trying to fetch google cache: $in_ref->{error}";
38 }
39 }
40 else {
41 0 $out = $in_ref->{cache};
42 }
43 0 $out = substr $out, 0, $self->{line_length};
44 0 my ($nick) = split /!/, $in_ref->{_who};
45 0 ▶ if ( $in_ref->{_type} eq 'public' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_ref->{'_type'} eq 'public') { } 0 0 0
46 0 $in_ref->{out} = "$nick, $out";
47 }
48 else {
49 0 $in_ref->{out} = $out;
50 }
51 0 return [ $in_ref->{out} ];
52 }
53  
54 0 ▶sub _make_response_event {
Subroutine _make_response_event: not called CC=2 SCAR=17.9
55 0 my $self = shift;
56 0 my $in_ref = shift;
57  
58 return {
59 0 ▶ ( map { $_ => $in_ref->{$_} }
Branch: 1 branch
BranchTrueFalseTotal
exists $in_ref->{'error'} ? : 0 0 0
60 qw/out cache/,
61 ),
62 (
63 exists $in_ref->{error} ? ( error => $in_ref->{error} ) : (),
64 ),
65 0 map { $_ => $in_ref->{"_$_"} }
66 qw/ who channel message type what /,
67 }
68 }
69  
70 0 ▶sub _make_poco_call {
Subroutine _make_poco_call: not called CC=2 SCAR=17.9
71 0 my $self = shift;
72 0 my $data_ref = shift;
73 0 my $uri = $data_ref->{what};
74 0 ▶ unless ( $uri =~ m{^(?:ht|f)tps?:://} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($uri =~ m[^(?:ht|f)tps?:://]) 0 0 0
75 0 $uri = "http://$uri";
76 }
77 $self->{poco}->cache( {
78 event => '_poco_done',
79 uri => $uri,
80 fetch => 1,
81 max_size => 100,
82 0 map +( "_$_" => $data_ref->{$_} ),
83 keys %$data_ref,
84 }
85 );
86 }
87  
88  
89 1 1;
90 __END__
« Plugin/WWW/DoctypeGrabber.pm ↑ Summary Plugin/Syntax/Highlight/HTML.pm »