Plugin/CSS/PropertyInfo.pm

filter: Statementstmt 30.9% 17 / 55 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 28.5% 4 / 14 Podpod n/a totaltotal 22.8% 21 / 92 CC 12 SCAR 27.3
CC
12
Cov
22%
_make_response_message
42.0
_do_response
20.0
_command_inherited
6.0
CRAP 15.3
« Plugin/CSS/SelectorTools.pm ↑ Summary Plugin/WWW/HTMLTagAttributeCounter.pm »
1 package POE::Component::IRC::Plugin::CSS::PropertyInfo;
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 base 'POE::Component::IRC::Plugin::BaseWrap';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use POE qw(Component::IRC::Plugin::CSS::PropertyInfo::Data);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 my %Properties
12 = POE::Component::IRC::Plugin::CSS::PropertyInfo::Data->_make_property_data;
13  
14 1 my %Value_Types
15 = POE::Component::IRC::Plugin::CSS::PropertyInfo::Data->_make_vt_data;
16  
17 1 my %Make_Output_For_Command = (
18 initial => \&_command_initial,
19 values => \&_command_values,
20 inherited => \&_command_inherited,
21 percentages => \&_command_percentages,
22 applies_to => \&_command_applies_to,
23 media => \&_command_media,
24 value_type => \&_command_value_type,
25 );
26  
27 0 ▶sub _make_default_args {
Subroutine _make_default_args: not called CC=1 SCAR=6.9
28 return (
29 0 trigger => qr/^css\s+(?=\S+\s+\S+)/i,
30 command_triggers => {
31 exists => qr/^ e (?:xist s?)? \s+/xi,
32 initial => qr/^ i (?:nitial)? \s+/xi,
33 values => qr/^ v (?:alue s?)? \s+/xi,
34 inherited => qr/^ in (?:herit (?:ed)? )? \s+/xi,
35 percentages => qr/^ p (?:ercent (?:age s? )? )? \s+/xi,
36 applies_to => qr/^ a (?: ppl (?:y|ies))? \s* (?:to)? \s+/xi,
37 media => qr/^ m (?: edia)? \s* (?:type)? \s+/xi,
38 value_type => qr/^ v (?: alue )? \s* t (?: ypes?)? \s+/xi,
39 },
40 response_event => 'irc_css_property_info',
41 );
42 }
43  
44 0 ▶sub _do_response {
Subroutine _do_response: not called CC=4 SCAR=30.0
45 0 my ( $self, $in_ref ) = @_;
46  
47 0 my $response_message = $self->_make_response_message( $in_ref );
48  
49 0 $in_ref->{out} = $response_message;
50 $self->{irc}->_send_event(
51 0 $self->{response_event} => $in_ref,
52 );
53  
54 0 ▶ if ( $self->{auto} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"auto"}) 0 0 0
55 my $response_type = $in_ref->{type} eq 'public'
56 ? 'privmsg'
57 0 ▶ : $in_ref->{type};
Branch: 1 branch
BranchTrueFalseTotal
$in_ref->{'type'} eq 'public' ? : 0 0 0
58  
59 my $where = $in_ref->{type} eq 'public'
60 ? $in_ref->{channel}
61 0 ▶ : (split /!/, $in_ref->{who})[0];
Branch: 1 branch
BranchTrueFalseTotal
$in_ref->{'type'} eq 'public' ? : 0 0 0
62  
63 $poe_kernel->post( $self->{irc} =>
64 0 $response_type =>
65 $where =>
66 $response_message
67 );
68 }
69  
70 0 undef;
71 }
72  
73 0 ▶sub _make_response_message {
Subroutine _make_response_message: not called CC=6 SCAR=37.4
74 0 my ( $self, $in_ref ) = @_;
75  
76 0 my $in = $in_ref->{what};
77  
78 0 my $trigs_ref = $self->{command_triggers};
79  
80 0 for my $command ( sort keys %$trigs_ref ) {
81 0 my $trigger = $trigs_ref->{ $command };
82 0 ▶ if ( $in =~ s/$trigger// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in =~ s/$trigger//) 0 0 0
83 0 $in =~ s/^\s+|\s+$//g;
84 0 $in = lc $in;
85  
86 0 ▶ if ( $command ne 'value_type' and !exists $Properties{$in} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command ne "value_type" and not exists $Properties{$in}) 0 0 0
Condition0%0/3
$command ne "value_type" and not exists $Properties{$in}
!ll&&!rl&&r
000
MC/DC0%0/2
$command ne "value_type" and not exists $Properties{$in}
$command ne "value_type" not exists $Properties{$in}
Truth table0%0/3
A and not(B)
A= $command ne "value_type"B= not exists $Properties{$in}
ABresult
0X0
100
111
87 0 return "Property '$in' does not seem to exist";
88 }
89 0 ▶ if ( $command eq 'exists' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command eq "exists") 0 0 0
90 0 return "Yes, property '$in' does exist";
91 }
92  
93 0 return $Make_Output_For_Command{ $command }->( $in );
94 }
95 }
96  
97 0 return 'Invalid command in CSS Property Info plugin';
98 }
99  
100 0 ▶sub _command_initial {
Subroutine _command_initial: not called CC=1 SCAR=6.9
101 0 my $in = shift;
102 0 return "Initial value for '$in' is $Properties{ $in }{initial}";
103 }
104  
105 0 ▶sub _command_values {
Subroutine _command_values: not called CC=1 SCAR=6.9
106 0 my $in = shift;
107 0 return "Property '$in' accepts: $Properties{ $in }{values}";
108 }
109  
110 0 ▶sub _command_inherited {
Subroutine _command_inherited: not called CC=2 SCAR=17.9
111 0 my $in = shift;
112 0 ▶ return $Properties{ $in }{inherited} eq 'yes'
Branch: 1 branch
BranchTrueFalseTotal
$Properties{$in}{'inherited'} eq 'yes' ? : 0 0 0
113 ? "Yes, '$in' is inherited"
114 : "No, '$in' is not inherited";
115 }
116  
117 0 ▶sub _command_percentages {
Subroutine _command_percentages: not called CC=2 SCAR=17.9
118 0 my $in = shift;
119 return $Properties{ $in }{percentages} eq 'N/A'
120 ? "Percetages do not apply to '$in'"
121 : "Percentages for '$in' refer to "
122 0 ▶ . $Properties{ $in }{percentages};
Branch: 1 branch
BranchTrueFalseTotal
$Properties{$in}{'percentages'} eq 'N/A' ? : 0 0 0
123 }
124  
125 0 ▶sub _command_applies_to {
Subroutine _command_applies_to: not called CC=1 SCAR=6.9
126 0 my $in = shift;
127 0 return "Property '$in' applies to: $Properties{ $in }{applies_to}";
128 }
129  
130 0 ▶sub _command_media {
Subroutine _command_media: not called CC=1 SCAR=6.9
131 0 my $in = shift;
132 0 return "Property '$in' belongs to $Properties{ $in }{media} "
133 . "media type(s)";
134 }
135  
136 0 ▶sub _command_value_type {
Subroutine _command_value_type: not called CC=2 SCAR=17.9
137 0 my $in = shift;
138 0 ▶ return exists $Value_Types{ $in }
Branch: 1 branch
BranchTrueFalseTotal
exists $Value_Types{$in} ? : 0 0 0
139 ? "Value type '$in' is described on $Value_Types{$in}"
140 : "I am not aware of value type '$in'";
141 }
142  
143 1 1;
144 __END__
« Plugin/CSS/SelectorTools.pm ↑ Summary Plugin/WWW/HTMLTagAttributeCounter.pm »