line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IRC::Toolkit::Parser; |
2
|
|
|
|
|
|
|
$IRC::Toolkit::Parser::VERSION = '0.091001'; |
3
|
2
|
|
|
2
|
|
861
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
156
|
|
4
|
2
|
|
|
2
|
|
497
|
use strictures 2; |
|
2
|
|
|
|
|
1281
|
|
|
2
|
|
|
|
|
144
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1660
|
use parent 'Exporter::Tiny'; |
|
2
|
|
|
|
|
354
|
|
|
2
|
|
|
|
|
12
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw/ |
8
|
|
|
|
|
|
|
irc_ref_from_line |
9
|
|
|
|
|
|
|
irc_line_from_ref |
10
|
|
|
|
|
|
|
/; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
4571
|
use Scalar::Util 'blessed', 'reftype'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
166
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
780
|
use POE::Filter::IRCv3; |
|
2
|
|
|
|
|
2651
|
|
|
2
|
|
|
|
|
362
|
|
15
|
|
|
|
|
|
|
my $filter = 'POE::Filter::IRCv3'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub irc_ref_from_line { |
18
|
1
|
|
|
1
|
1
|
883
|
my $line = shift; |
19
|
1
|
50
|
|
|
|
4
|
confess "Expected a line and optional filter arguments" |
20
|
|
|
|
|
|
|
unless $line; |
21
|
1
|
|
|
|
|
12
|
$filter->new(@_)->get([$line])->[0] |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub irc_line_from_ref { |
25
|
2
|
|
|
2
|
1
|
1498
|
my $ref = shift; |
26
|
2
|
50
|
|
|
|
10
|
confess "Expected a HASH and optional filter arguments" |
27
|
|
|
|
|
|
|
unless reftype $ref eq 'HASH'; |
28
|
2
|
100
|
|
|
|
9
|
$filter->new(@_)->put([blessed $ref ? +{%$ref} : $ref])->[0] |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
IRC::Toolkit::Parser - Functional-style IRC filter interface |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use IRC::Toolkit::Parser; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $raw_irc_line = ':avenj PRIVMSG #channel :things'; |
42
|
|
|
|
|
|
|
my $ref = irc_ref_from_line( $raw_irc_line ); |
43
|
|
|
|
|
|
|
my $raw_line = irc_line_from_ref( $ref, colonify => 1 ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
A simple functional-style frontend to L. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This will be slower than using the filter directly, but it's convenient for |
50
|
|
|
|
|
|
|
one-offs. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
See L for details. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Also see L for a handy object-oriented interface to IRC |
55
|
|
|
|
|
|
|
event transformation. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 irc_ref_from_line |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Takes a raw IRC line and returns a HASH as described in the documentation for |
60
|
|
|
|
|
|
|
L. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 irc_line_from_ref |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Takes a HASH as described in L and returns a raw IRC line. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Jon Portnoy |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |