| 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
| |||||||||||||||
| 33 | |||||||||||||||
| 34 | 0 | my $trig_ref = $self->{ztriggers}; | |||||||||||||
| 35 | 0 | ▶ | if ( $in =~ s/$trig_ref->{link}// ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 36 | $self->{debug} | ||||||||||||||
| 37 | 0 | ▶ | and carp "CSS SelectorTools [LINK]: ($in)"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 79 | if length $out >= $max; | ||||||||||||||
| 80 | |||||||||||||||
| 81 | 0 | ▶ | while ( length $out > $len ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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__ | ||||||||||||||