blib/lib/Text/Trac.pm

filter: Statementstmt 100% 32 / 32 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 98.0% 50 / 51 SCAR 17.9
CC
6
Cov
98%
parse
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.0
« blib/lib/Text/Trac/Macro.pm ↑ Summary blib/lib/Text/Trac/LinkResolver/Comment.pm »
1 package Text::Trac;
2  
3 53 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 53 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 53 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 53 ▶use Text::Trac::Context;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 53 ▶use Text::Trac::BlockNode;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 53 our $VERSION = '0.23';
11  
12 53 my %Defaults = (
13 html => '',
14 permalink => '',
15 min_heading_level => 1,
16 class => 1,
17 id => 1,
18 span => 1,
19 );
20  
21 sub new {
22 48 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
23  
24 48 my $self = { %Defaults, %args, };
25  
26 48 bless $self, $class;
27 }
28  
29 sub parse {
30 160 ▶ my $self = shift;
Subroutine parse: called CC=6 SCAR=17.9
Pod documented
31 160 ▶ my $text = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $text = shift() or return 0 160 160
32  
33 160 ▶ $self->{trac_url} = '/' unless defined $self->{trac_url};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"trac_url"} 3 157 160
34 160 for ( keys %$self ) {
35 1190 ▶ if ( $_ =~ /^trac.+url$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^trac.+url$/) 224 966 1190
36 224 ▶ $self->{$_} .= '/' if $self->{$_} !~ m!/$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{$_} =~ m[/$] 48 176 224
37 }
38 }
39  
40 160 my $c = Text::Trac::Context->new(
41 {
42 %$self, text => $text,
43 }
44 );
45  
46 160 my $node = Text::Trac::BlockNode->new(
47 {
48 context => $c,
49 }
50 );
51 160 $node->parse;
52  
53 160 $self->{html} = $c->html;
54 }
55  
56 160 ▶sub html { $_[0]->{html}; }
Subroutine html: called CC=1 SCAR=0.0
Pod documented
57  
58 53 *process = \&parse;
59  
60 53 1;
61 __END__
« blib/lib/Text/Trac/Macro.pm ↑ Summary blib/lib/Text/Trac/LinkResolver/Comment.pm »