Wiki/IDKeeper.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 3 / 3 totaltotal 100% 34 / 34 CC 4 SCAR 6.9
CC
4
Cov
100%
id
3.0
new
2.0
BEGIN
1.0
CRAP 2.0
« Wiki/Plugin.pm ↑ Summary Wiki/Plugin/Block/Blockquote.pm »
1 package Text::Livedoor::Wiki::IDKeeper;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 92 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
7 92 my $class = shift;
8 92 my $self = shift ;
9 92 bless $self , $class;
10 92 for(1..3){
11 276 $self->{level}{$_} = 0;
12 }
13 92 return $self;
14 }
15  
16 58 ▶sub up {
Subroutine up: called CC=1 SCAR=0.0
Pod documented
17 58 my $self = shift;
18 58 my $level = shift ;
19 58 $self->{level}{$level}++;
20 }
21  
22 176 ▶sub id {
Subroutine id: called CC=3 SCAR=11.0
Pod documented
23 176 my $self = shift;
24 176 my $target_level = shift;
25  
26 176 my $id = $self->{name} ;
27  
28 176 foreach my $level ( sort keys %{$self->{level}} ) {
29 408 ▶ last if $level > $target_level;
Branch: 1 branch
BranchTrueFalseTotal
if $level > $target_level 148 260 408
30 260 $id.= '_' . $self->{level}{$level} ;
31 }
32 176 return $id;
33 }
34  
35 10 1;
36  
37 =head1 NAME
38  
39 Text::Livedoor::Wiki::IDKeeper - ID Keeper
40  
41 =head1 DESCRIPTION
42  
43 keep header id for #contents
44  
45 =head1 METHOD
46  
47 =head2 new
48  
49 =head2 up
50  
51 =head2 id
52  
53 =head1 AUTHOR
54  
55 polocky
56  
57 =cut
« Wiki/Plugin.pm ↑ Summary Wiki/Plugin/Block/Blockquote.pm »