Gungho/Component/RobotsMETA.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 42 CC 3 SCAR 17.5
CC
3
Cov
0%
handle_response
12.0
setup
2.0
BEGIN
2.0
CRAP 5.8
1 # $Id: /mirror/gungho/lib/Gungho/Component/RobotsMETA.pm 31095 2007-11-26T00:05:40.329716Z lestrrat $
2 #
3 # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
4 # All rights reserved.
5  
6 package Gungho::Component::RobotsMETA;
7 use strict;
8 use warnings;
9 use base qw(Gungho::Component);
10 use HTML::RobotsMETA;
11  
12 __PACKAGE__->mk_classdata($_) for qw(robots_meta);
13  
14 sub setup
15 {
16 my $self = shift;
17 $self->next::method(@_);
18 $self->robots_meta( HTML::RobotsMETA->new );
19 }
20  
21 sub handle_response
22 {
23 my ($self, $req, $res) = @_;
24  
25 if ($res->is_success && $res->content_type =~ m{^text/html}i) {
26 eval {
27 my $rules = $self->robots_meta->parse_rules( $res->content );
28 $res->notes( robots_meta => $rules );
29 };
30 if ($@) {
31 $self->log->debug("Failed to parse " . $res->request->uri . " for robots META information: $@");
32 }
33 }
34 $self->next::method($req, $res);
35 }
36  
37 1;
38  
39 __END__