Wiki/Plugin/Block/H4.pm

filter: Statementstmt 100% 50 / 50 Branchbran 100% 8 / 8 Conditioncond 86.6% 13 / 15 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 95.4% 83 / 87 CC 11 SCAR 19.7
CC
11
Cov
97%
check
10.0
get
2.0
BEGIN
1.0
CRAP 7.1
« Wiki/Plugin/Block/Table.pm ↑ Summary Wiki/Plugin/Block/H5.pm »
1 package Text::Livedoor::Wiki::Plugin::Block::H4;
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  
7 213 ▶sub check {
Subroutine check: called CC=10 SCAR=23.0
Pod documented
8 213 my $class = shift;
9 213 my $line = shift;
10 213 my $args = shift;
11 213 my $id = $args->{id};
12 213 my $inline = $args->{inline};
13 213 my $on_next = $args->{on_next};
14 213 my $scratchpad = $Text::Livedoor::Wiki::scratchpad;
15  
16 213 my $catalog_keeper = $Text::Livedoor::Wiki::opts->{catalog_keeper};
17 213 my $id_keeper = $Text::Livedoor::Wiki::opts->{id_keeper};
18 213 my $skip_catalog = $Text::Livedoor::Wiki::opts->{skip_catalog};
19  
20 213 my $key = 'h4_is_active_' . $id;
21
22 # start rule
23 # 1. start with **~
24 # 2. not end yet
25 #if ( $line =~ /^\*\*[^\*]./ && !$scratchpad->{$key} && !$class->get_child($id)){
26 213 ▶ if ( $line =~ /^\*\*[^\*]+/ && !$scratchpad->{$key} && !$class->get_child($id)){
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ /^\*\*[^\*]+/ and not $scratchpad->{$key} and not $class->get_child($id)) { } 17 196 213
elsif ($on_next and $class->trigger_check($id, $line) and $line =~ /^\*/ and $scratchpad->{$key}) { } 14 182 196
elsif ($scratchpad->{$key}) { } 26 156 182
Condition83%5/6
$line =~ /^\*\*[^\*]+/ and not $scratchpad->{$key} and not $class->get_child($id)
!ll&&!rl&&r
196017
$line =~ /^\*\*[^\*]+/ and not $scratchpad->{$key}
!ll&&!rl&&r
192417
MC/DC66%2/3
$line =~ /^\*\*[^\*]+/ and not $scratchpad->{$key} and not $class->get_child($id)
$line =~ /^\*\*[^\*]+/ not $scratchpad->{$key} not $class->get_child($id)
Truth table75%3/4
A and not(B) and not(C)
A= $line =~ /^\*\*[^\*]+/B= not $scratchpad->{$key}C= not $class->get_child($id)
ABCresult
0XX0
10X0
1100
1111
27 17 $scratchpad->{$key} = 1 ;
28 17 $line =~ s/^\*\*//;
29 17 my $title = $inline->parse($line);
30 17 my $header = '';
31  
32 #XXX
33 17 $Text::Livedoor::Wiki::scratchpad->{skip_ajust_block_break} = '1';
34
35 17 ▶ if( $skip_catalog ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip_catalog) { } 3 14 17
36 3 $header = sprintf( qq|<div class="title-2"><h4>%s</h4></div>\n| , $title ) ;
37 }
38 else {
39 14 $id_keeper->up(2);
40 14 $catalog_keeper->append( {level=>2 , id => $id_keeper->id(2) , label => $title } );
41 14 $header = sprintf( qq|<div class="title-2"><h4 id="%s">%s</h4></div>\n| , $id_keeper->id(2) , $title ) ;
42 }
43 17 return { header => $header , id => $id };
44 }
45 # end rule
46 # 1. next line
47 # 2. no not-closed child block
48 # 3. *
49 ▶ elsif( $on_next && $class->trigger_check($id,$line) && $line =~ /^\*/ && $scratchpad->{$key} ) {
Condition88%8/9
$on_next and $class->trigger_check($id, $line) and $line =~ /^\*/ and $scratchpad->{$key}
!ll&&!rl&&r
182014
$on_next and $class->trigger_check($id, $line) and $line =~ /^\*/
!ll&&!rl&&r
1721014
$on_next and $class->trigger_check($id, $line)
!ll&&!rl&&r
169324
MC/DC75%3/4
$on_next and $class->trigger_check($id, $line) and $line =~ /^\*/ and $scratchpad->{$key}
$on_next $class->trigger_check($id, $line) $line =~ /^\*/ $scratchpad->{$key}
Truth table80%4/5
A and B and C and D
A= $on_nextB= $class->trigger_check($id, $line)C= $line =~ /^\*/D= $scratchpad->{$key}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
50 14 $scratchpad->{$key} = 0 ;
51 14 return ;
52 }
53 elsif( $scratchpad->{$key} ) {
54 26 return { line => $line };
55 }
56  
57 156 return;
58  
59 }
60  
61 17 ▶sub get {
Subroutine get: called CC=2 SCAR=6.9
Pod documented
62 17 my $class = shift;
63 17 my $block = shift;
64 17 my $inline = shift;
65 17 my $items = shift;
66 17 my $meta = shift @{$items};
67 17 my $header = $meta->{header} ;
68 17 my $id = $meta->{id} ;
69 17 my $html = '';
70 17 $html .= $_->{line} . "\n" for @$items;
71 17 $html =~ s/\n$//;
72 # block in block
73 17 $html = $block->parse( $html , 1 ) ;
74 17 return qq|<div id="$id" class="wiki-section-2">\n$header<div id="$id-body" class="wiki-section-body-2">\n$html</div>\n</div>\n|;
75 }
76  
77 5 1;
78  
79 =head1 NAME
80  
81 Text::Livedoor::Wiki::Plugin::Block::H4 - H4 Block Plugin
82  
83 =head1 DESCRIPTION
84  
85 H4 is second level header
86  
87 =head1 SYNOPSIS
88  
89 ** title2
90
91 content
92
93 ** title2
94  
95 =head1 FUNCTION
96  
97 =head2 check
98  
99 =head2 get
100  
101 =head1 AUTHOR
102  
103 polocky
104  
105 =cut
« Wiki/Plugin/Block/Table.pm ↑ Summary Wiki/Plugin/Block/H5.pm »