File Coverage

blib/lib/Text/Trac/LinkResolver/Wiki.pm
Criterion Covered Total %
statement 22 22 100.0
branch 4 6 66.6
condition 6 9 66.6
subroutine 5 5 100.0
pod 0 2 0.0
total 37 44 84.0


line stmt bran cond sub pod time code
1             package Text::Trac::LinkResolver::Wiki;
2              
3 8     8   52 use strict;
  8         16  
  8         266  
4 8     8   43 use warnings;
  8         17  
  8         252  
5 8     8   45 use base qw( Text::Trac::LinkResolver );
  8         15  
  8         47  
6              
7             our $VERSION = '0.22';
8              
9             sub init {
10 1607     1607 0 2431 my $self = shift;
11             $self->{pattern}
12 1607         3854 = '!?(?
13             }
14              
15             sub format_link {
16 5     5 0 17 my ( $self, $match, $target, $label ) = @_;
17 5 50       32 return $match if $self->_is_disabled;
18              
19 5         25 my $c = $self->{context};
20 5   66     29 $label ||= $match;
21 5   66     24 $target ||= $match;
22              
23 5 100       19 if ( $label =~ /\[wiki:(\S+)\s+(.+)\]/ ) {
24 1         4 $target = $1;
25 1         3 $label = $2;
26             }
27              
28 5   66     105 my $url = $c->{trac_wiki_url} || $c->trac_url . 'wiki/';
29 5         38 $url .= $target;
30 5 50       61 return sprintf '%s', ( $c->{class} ? q{class="wiki"} : '' ), $url, $label;
31             }
32              
33             1;