Plugin/CSS/SelectorTools.pm

filter: Statementstmt 36.1% 17 / 47 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod n/a totaltotal 29.7% 22 / 74 CC 9 SCAR 28.0
CC
9
Cov
27%
_make_response_message
42.0
_prepare_output
12.0
_command_multi
6.0
CRAP 16.4
« Plugin/WWW/Lipsum.pm ↑ Summary Plugin/CSS/PropertyInfo.pm »
1 package POE::Component::IRC::Plugin::CSS::SelectorTools;
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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use base 'POE::Component::IRC::Plugin::BaseWrap';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub _make_default_args {
Subroutine _make_default_args: not called CC=1 SCAR=6.9
13 return (
14 0 trigger => qr/^sel(?:ector)?\s+(?=\S+)/i,
15 ztriggers => {
16 link => qr/^link\s+(?=\S+)/i,
17 multi => qr/^multi\s+(?=\S+)/i,
18 },
19 response_event => 'irc_css_selector_tools',
20 line_length => 350,
21 max_length => 695,
22 );
23 }
24  
25 0 ▶sub _message_into_response_event { 'out' };
Subroutine _message_into_response_event: not called CC=1 SCAR=6.9
26  
27 0 ▶sub _make_response_message {
Subroutine _make_response_message: not called CC=6 SCAR=37.4
28 0 my ( $self, $in_ref ) = @_;
29  
30 0 my $in = $in_ref->{what};
31 $self->{debug}
32 0 ▶ and carp "CSS SelectorTools: ($in)";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"debug"} and carp("CSS SelectorTools: ($in)") 0 0 0
33  
34 0 my $trig_ref = $self->{ztriggers};
35 0 ▶ if ( $in =~ s/$trig_ref->{link}// ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($in =~ s/$trig_ref->{'link'}//) { } 0 0 0
elsif ($in =~ s/$trig_ref->{'multi'}//) { } 0 0 0
36 $self->{debug}
37 0 ▶ and carp "CSS SelectorTools [LINK]: ($in)";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"debug"} and carp("CSS SelectorTools [LINK]: ($in)") 0 0 0
38  
39 0 return $self->_prepare_output( $self->_command_link( $in ) );
40 }
41 elsif ( $in =~ s/$trig_ref->{multi}// ) {
42 $self->{debug}
43 0 ▶ and carp "CSS SelectorTools [MULTI]: ($in)";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"debug"} and carp("CSS SelectorTools [MULTI]: ($in)") 0 0 0
44  
45 0 return $self->_prepare_output( $self->_command_multi( $in ) );
46 }
47 else {
48 0 return [ "Invalid command in CSS::SelectorTools plugin" ];
49 }
50 }
51  
52 0 ▶sub _command_multi {
Subroutine _command_multi: not called CC=2 SCAR=17.9
53 0 my ( $self, $in ) = @_;
54 0 $in =~ s/^\s+|\s+$//g;
55  
56 0 ▶ if ( my ( $dup, $selectors ) = $in =~ /^\[ ([^\]]+) ] \s+ (.+)/x ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $in =~ /^\[ ([^\]]+) ] \s+ (.+)/x) { } 0 0 0
57 0 $selectors =~ s/(^|,\s*)/$1$dup /g;
58 0 return $selectors;
59 }
60 else {
61 0 return "Input must be in the form:"
62 . " [part_to_duplicate] sel1, sel2 .. selN";
63 }
64 }
65  
66 0 ▶sub _command_link {
Subroutine _command_link: not called CC=1 SCAR=6.9
67 0 my ( $self, $in ) = @_;
68 0 my $out = 'a:link, a:visited, a:hover, a:active';
69 0 $out =~ s/a(?=:)/$in/g;
70 0 return $out;
71 }
72  
73 0 ▶sub _prepare_output {
Subroutine _prepare_output: not called CC=3 SCAR=24.8
74 0 my ( $self, $out ) = @_;
75 0 my @out;
76 0 my ( $max, $len ) = @$self{ qw(max_length line_length) };
77  
78 0 ▶ $out = substr( $out, 0, $max ) . q|...|
Branch: 1 branch
BranchTrueFalseTotal
if length $out >= $max 0 0 0
79 if length $out >= $max;
80  
81 0 ▶ while ( length $out > $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $out > $len) 0 0 0
82 0 push @out, substr $out, 0, $len;
83 0 $out = substr $out, $len;
84 }
85 0 return [ @out, $out ];
86 }
87  
88 1 1;
89 __END__
« Plugin/WWW/Lipsum.pm ↑ Summary Plugin/CSS/PropertyInfo.pm »