Wiki/Plugin/Block/CopyAndPaste.pm

filter: Statementstmt 100% 64 / 64 Branchbran 100% 18 / 18 Conditioncond 100% 17 / 17 MC/DCmcdc 100% 9 / 9 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 116 / 116 CC 19 SCAR 24.4
CC
19
Cov
100%
check
16.0
get
4.0
BEGIN
1.0
CRAP 11.5
« Wiki/CatalogKeeper.pm ↑ Summary Wiki/Plugin/Block/Toggle.pm »
1 package Text::Livedoor::Wiki::Plugin::Block::CopyAndPaste;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use base qw(Text::Livedoor::Wiki::Plugin::Block);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Text::Livedoor::Wiki::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 __PACKAGE__->trigger({ start=> '^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$' , end => '^\|\|=$' , escape => 1 });
9  
10 336 ▶sub check {
Subroutine check: called CC=16 SCAR=27.7
Pod documented
11 336 my $class = shift;
12 336 my $line = shift;
13 336 my $args = shift;
14 336 my $on_next = $args->{on_next};
15 336 my $id = $args->{id};
16 336 my $scratchpad = $Text::Livedoor::Wiki::scratchpad;
17 336 my $row;
18 my $option_str;
19 336 my $processing = $scratchpad->{block}{$id}{processing};
20  
21  
22  
23 # header
24 336 ▶ if (( ( $row, $option_str ) = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/) && !$processing && !$on_next ){
Branch: 4 branches
BranchTrueFalseTotal
if (() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ and not $processing and not $on_next) { } 17 319 336
elsif ($line =~ /^\|\|=$/ and $processing and not $on_next) { } 17 302 319
elsif ($on_next and not $processing) { } 6 296 302
elsif ($processing) { } 89 207 296
Condition100%6/6
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ and not $processing and not $on_next
!ll&&!rl&&r
316317
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ and not $processing
!ll&&!rl&&r
314220
MC/DC100%3/3
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ and not $processing and not $on_next
() = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/ not $processing not $on_next
Truth table100%4/4
A and not(B) and not(C)
A= () = $line =~ /^=\|([a-z0-9A-Z\-_]*)(?:\(([^\)\|]+)\))?\|$/B= not $processingC= not $on_next
ABCresult
0XX0
10X0
1100
1111
25 17 my $res = { id => $id };
26 17 ▶ $row ||= 'PLAIN-BOX';
Condition100%2/2
$row ||= "PLAIN-BOX"
l!l
116
MC/DC100%1/1
$row ||= "PLAIN-BOX"
$row
Truth table100%2/2
A
A= $row
Aresult
11
00
27 17 $res->{class_name} = $row;
28  
29 #XXX
30 17 $Text::Livedoor::Wiki::scratchpad->{skip_ajust_block_break} = '1';
31
32 17 my $box = 'pre';
33 17 ▶ if ($option_str) {
Branch: 1 branch
BranchTrueFalseTotal
if ($option_str) 4 13 17
34 4 my @params = split( ';', $option_str );
35  
36 4 for my $param (@params) {
37 4 my ( $k, $v ) = split( '=', $param );
38 4 ▶ if ( $k eq 'box' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq "box") 3 1 4
39 3 ▶ if ( $v eq 'div' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($v eq 'div') { } 1 2 3
elsif ($v eq 'textarea') { } 1 1 2
40 1 $box = 'div';
41 }
42 elsif( $v eq 'textarea' ) {
43 1 $box = 'textarea';
44 }
45 }
46 }
47 }
48 17 $res->{box} = $box;
49 17 $scratchpad->{block}{$id}{processing} = 1;
50 17 return $res;
51 }
52 # end box
53 ▶ elsif( $line =~ /^\|\|=$/ && $processing && !$on_next ) {
Condition100%6/6
$line =~ /^\|\|=$/ and $processing and not $on_next
!ll&&!rl&&r
2851717
$line =~ /^\|\|=$/ and $processing
!ll&&!rl&&r
284134
MC/DC100%3/3
$line =~ /^\|\|=$/ and $processing and not $on_next
$line =~ /^\|\|=$/ $processing not $on_next
Truth table100%4/4
A and B and not(C)
A= $line =~ /^\|\|=$/B= $processingC= not $on_next
ABCresult
0XX0
10X0
1100
1111
54 17 $scratchpad->{block}{$id}{processing} = 0;
55 17 return { line => '' } ;
56 }
57 # finalize
58 ▶ elsif( $on_next && !$processing ) {
Condition100%3/3
$on_next and not $processing
!ll&&!rl&&r
243536
MC/DC100%2/2
$on_next and not $processing
$on_next not $processing
Truth table100%3/3
A and not(B)
A= $on_nextB= not $processing
ABresult
0X0
100
111
59 6 return ;
60 }
61 # processing
62 elsif( $processing ) {
63 89 return { line => $line };
64 }
65  
66 # not much
67 207 return;
68 }
69  
70 17 ▶sub get {
Subroutine get: called CC=4 SCAR=13.9
Pod documented
71 17 my $class = shift;
72 17 my $block = shift;
73 17 my $inline = shift;
74 17 my $items = shift;
75 17 my $meta = shift @{$items};
76 17 my $box = $meta->{box};
77 17 my $class_name = $meta->{class_name};
78 17 my $id = $meta->{id};
79 17 my $on_prettyprint = "";
80 17 my @syntax = qw/C CC CPP CS CYC JAVA BSH CSH SH CV PY PERL PL PM RB JS HTML XHTML XML XSL/;
81 17 for my $sh ( @syntax ) {
82 332 ▶ if ( $class_name eq $sh ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class_name eq $sh) 1 331 332
83 1 $on_prettyprint = "prettyprint ";
84 1 last;
85 }
86 }
87 17 my $data = '';
88 17 $data .= $_->{line} . "\n" for @$items;
89 17 $data =~ s/\n$//;
90  
91 17 $data = Text::Livedoor::Wiki::Utils::escape_more( $data );
92  
93 17 return qq|<$box id="$id" class="$on_prettyprint$class_name">\n| . $data . "</$box>\n";;
94 }
95  
96 5 1;
97  
98 =head1 NAME
99  
100 Text::Livedoor::Wiki::Plugin::Block::CopyAndPaste - Copy & Page Block Plugin
101  
102 =head1 DESCRIPTION
103  
104 You can escape Wiki format. Just copy and paste!
105  
106 =head1 SYNOPSIS
107  
108 =||
109 %%hi mom%%
110 ||=
111  
112 =|class_name|
113 %%hi mom with class name%%
114 ||=
115  
116 =|HTML|
117 <html>
118 <title>prettify js class name support.</title>
119 </html>
120 ||=
121  
122 =head1 FUNCTION
123  
124 =head2 check
125  
126 =head2 get
127  
128 =head1 AUTHOR
129  
130 polocky
131  
132 =cut
« Wiki/CatalogKeeper.pm ↑ Summary Wiki/Plugin/Block/Toggle.pm »