blib/lib/Text/Trac/Context.pm

filter: Statementstmt 90.7% 39 / 43 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 9.0% 1 / 11 totaltotal 75.7% 53 / 70 SCAR 6.9
CC
2
Cov
91%
currentline
2.0
htmllines
2.0
lasthtmlline
2.0
CRAP 2.0
« blib/lib/Text/Trac/Macro/Timestamp.pm ↑ Summary blib/lib/Text/Trac/Hr.pm »
1 package Text::Trac::Context;
2 53 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 53 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 53 ▶use base qw (Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 53 our $VERSION = '0.23';
7  
8 53 __PACKAGE__->mk_accessors(qw( ul ol min_heading_level permalink in_block_of trac_url ));
9  
10 53 my %Defaults = (
11 text => '',
12 html => '',
13 htmllines => [],
14 ul => {},
15 ol => {},
16 shift_count => 0,
17 in_block_of => [],
18 disable_links => [],
19 enable_links => [],
20 );
21  
22 sub new {
23 160 ▶ my ( $class, $args ) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
24  
25 160 my $self = { %Defaults, %$args, };
26  
27 160 bless $self, $class;
28 160 $self->init;
29 160 return $self;
30 }
31  
32 sub init {
33 160 ▶ my $self = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
34 160 $self->{text} =~ s/\r//g;
35 160 @{ $self->{lines} } = split( '\n', $self->{text} );
36 160 $self->{index} = -1;
37 160 $self->{htmllines} = [];
38 }
39  
40 sub hasnext {
41 3620 ▶ my $self = shift;
Subroutine hasnext: called CC=1 SCAR=0.0
Pod undocumented
42 3620 defined( $self->{lines}->[ $self->{index} + 1 ] );
43 }
44  
45 sub nextline {
46 3243 ▶ my $self = shift;
Subroutine nextline: called CC=1 SCAR=0.0
Pod undocumented
47 3243 $self->{lines}->[ $self->{index} + 1 ];
48 }
49  
50 sub shiftline {
51 4849 ▶ my $self = shift;
Subroutine shiftline: called CC=1 SCAR=0.0
Pod undocumented
52 4849 $self->{lines}->[ ++$self->{index} ];
53 }
54  
55 sub unshiftline {
56 962 ▶ my $self = shift;
Subroutine unshiftline: called CC=1 SCAR=0.0
Pod undocumented
57 962 $self->{lines}->[ --$self->{index} ];
58 }
59  
60 sub currentline {
61 0 ▶ my $self = shift;
Subroutine currentline: not called CC=1 SCAR=6.9
Pod undocumented
62 0 $self->{lines}->[ $self->{index} ];
63 }
64  
65 sub html {
66 160 ▶ my $self = shift;
Subroutine html: called CC=1 SCAR=0.0
Pod undocumented
67 160 join( "\n", @{ $self->{htmllines} } );
68 }
69  
70 sub htmllines {
71 4760 ▶ my $self = shift;
Subroutine htmllines: called CC=2 SCAR=6.9
Pod undocumented
72 4760 ▶ push @{ $self->{htmllines} }, $_[0] if defined $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 4623 137 4760
73 4760 $self->{htmllines};
74 }
75  
76 0 ▶sub lasthtmlline { $_[0]->{htmllines}->[-1]; }
Subroutine lasthtmlline: not called CC=1 SCAR=6.9
Pod undocumented
77  
78 sub list_level {
79 0 ▶ my $self = shift;
Subroutine list_level: not called CC=1 SCAR=6.9
Pod undocumented
80 }
81  
82 53 1;
« blib/lib/Text/Trac/Macro/Timestamp.pm ↑ Summary blib/lib/Text/Trac/Hr.pm »