Wiki/Plugin/Function/Color.pm

filter: Statementstmt 100% 43 / 43 Branchbran 100% 18 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 100% 70 / 70 CC 10 SCAR 13.4
CC
10
Cov
100%
prepare_args
6.0
process
3.0
process_mobile
3.0
CRAP 3.8
« Wiki/Plugin/Block.pm ↑ Summary Wiki/Plugin/Function/Lislog.pm »
1 package Text::Livedoor::Wiki::Plugin::Function::Color;
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use base qw/Text::Livedoor::Wiki::Plugin::Function/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 __PACKAGE__->function_name('color');
6  
7 17 ▶sub prepare_args {
Subroutine prepare_args: called CC=6 SCAR=17.9
Pod documented
8 17 my $class = shift;
9 17 my $args = shift;
10 17 ▶ die 'no args' unless scalar @$args;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$args 1 16 17
11  
12 16 my $color = $args->[0];
13 16 my $bgcolor = $args->[1];
14 16 my $my_args = {};
15
16 16 ▶ if( $color ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($color) 13 3 16
17 13 ▶ die 'color is not web color' unless $color =~ /^[a-zA-Z0-9#]+$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $color =~ /^[a-zA-Z0-9#]+$/i 1 12 13
18 12 $my_args->{color} = $color;
19 }
20  
21 15 ▶ if( $bgcolor ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bgcolor) 8 7 15
22 8 ▶ die 'bgcolor is not web color' unless $bgcolor=~ /^[a-zA-Z0-9#]+$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $bgcolor =~ /^[a-zA-Z0-9#]+$/i 1 7 8
23 7 $my_args->{bgcolor} = $bgcolor;
24 }
25 14 return $my_args;
26 }
27 9 ▶sub process {
Subroutine process: called CC=3 SCAR=11.0
Pod documented
28 9 my ( $class, $inline, $data ) = @_;
29 9 my $str_color = '';
30 9 my $str_bgcolor = '';
31  
32 9 ▶ if( my $color = $data->{args}{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $color = $data->{"args"}{"color"}) 7 2 9
33 7 $str_color = "color:$color;";
34 }
35  
36 9 ▶ if( my $bgcolor = $data->{args}{bgcolor} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bgcolor = $data->{"args"}{"bgcolor"}) 5 4 9
37 5 $str_bgcolor = "background-color:$bgcolor;";
38 }
39  
40 9 my $style = qq{style="$str_color$str_bgcolor"};
41 9 my $value = $inline->parse( $data->{value} );
42 9 return "<span $style>$value</span>";
43
44 }
45  
46 5 ▶sub process_mobile {
Subroutine process_mobile: called CC=3 SCAR=11.0
Pod documented
47 5 my ( $class, $inline, $data ) = @_;
48 5 my $str_color ='';
49 5 my $str_bgcolor = '';
50  
51 5 ▶ if( my $color = $data->{args}{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $color = $data->{"args"}{"color"}) 4 1 5
52 4 $str_color = qq| color="$color"|;
53 }
54  
55 5 ▶ if( my $bgcolor = $data->{args}{bgcolor} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bgcolor = $data->{"args"}{"bgcolor"}) 2 3 5
56 2 $str_bgcolor = qq| style="background-color:$bgcolor"|;
57 }
58  
59 5 my $value = $inline->parse( $data->{value} );
60 5 return (qq|<font${str_color}${str_bgcolor}>$value</font>|);
61 }
62  
63 11 1;
64  
65 =head1 NAME
66  
67 Text::Livedoor::Wiki::Plugin::Function::Color - Color Function Plugin
68  
69 =head1 DESCRIPTION
70  
71 customize font color.
72  
73 =head1 SYNOPSIS
74  
75 &color(red){red}
76 &color(,red){back ground red}
77 &color(red,black){ red text and block background}
78 &color(#ffffff,#000000){hey hey}
79  
80 =head1 FUNCTION
81  
82 =head2 prepare_args
83  
84 =head2 process
85  
86 =head2 process_mobile
87  
88 =head1 AUTHOR
89  
90 polocky
91  
92 =cut
« Wiki/Plugin/Block.pm ↑ Summary Wiki/Plugin/Function/Lislog.pm »