line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# SOAP::Lite style Hoobot |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Hoobot; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
97808
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
163
|
|
6
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
114
|
|
7
|
4
|
|
|
4
|
|
1645
|
use Hoobot::Page; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
537
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.5.0'; # semi sane |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @_objs; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
END { |
14
|
1
|
|
|
1
|
|
1146
|
require Data::Dumper; |
15
|
|
|
|
|
|
|
# print STDERR Data::Dumper->Dump([\@_objs],['*_objs']); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
20
|
0
|
|
0
|
|
|
|
my $class = ref $proto || $proto; |
21
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
local %_ = @_; |
24
|
0
|
|
|
|
|
|
for (keys %_) { |
25
|
0
|
|
|
|
|
|
$self->$_($_{$_}); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
push @_objs, $self; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# method (construct a linked Hoobot::Page) |
34
|
|
|
|
|
|
|
sub page { |
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
36
|
0
|
0
|
|
|
|
|
$self = $self->new unless ref $self; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return Hoobot::Page->new( |
39
|
|
|
|
|
|
|
hoobot => $self, |
40
|
|
|
|
|
|
|
page => shift, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# accessor |
45
|
|
|
|
|
|
|
sub hoobot { |
46
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
0
|
0
|
|
|
|
|
$self = $self->new unless ref $self; |
48
|
0
|
0
|
|
|
|
|
return $self->{hoobot} unless @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$self->{hoobot} = shift; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# recursing accessor |
56
|
|
|
|
|
|
|
sub ua { |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
0
|
0
|
|
|
|
|
$self = $self->new unless ref $self; |
59
|
0
|
0
|
|
|
|
|
unless (@_) { |
60
|
|
|
|
|
|
|
# we know the value |
61
|
0
|
0
|
|
|
|
|
return $self->{ua} if defined $self->{ua}; |
62
|
|
|
|
|
|
|
# our parent knows the value? |
63
|
0
|
0
|
|
|
|
|
return $self->hoobot->ua if defined $self->hoobot; |
64
|
|
|
|
|
|
|
# otherwise create our own |
65
|
0
|
|
|
|
|
|
require LWP::UserAgent; |
66
|
0
|
|
|
|
|
|
return $self->{ua} = LWP::UserAgent->new; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# TODO: check interface |
70
|
0
|
|
|
|
|
|
$self->{ua} = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $self; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# recursing accessor |
76
|
|
|
|
|
|
|
sub host { |
77
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
78
|
0
|
0
|
|
|
|
|
$self = $self->new unless ref $self; |
79
|
0
|
0
|
|
|
|
|
unless (@_) { |
80
|
0
|
0
|
|
|
|
|
return $self->{host} if defined $self->{host}; |
81
|
0
|
0
|
|
|
|
|
return $self->hoobot->host if defined $self->hoobot; |
82
|
0
|
|
0
|
|
|
|
return $self->{host} = $ENV{HOOBOT_HOST} || 'http://www.bbc.co.uk'; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->{host} = shift; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return $self; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |