File Coverage

blib/lib/Text/Trac/LinkResolver/Report.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 4 50.0
condition 4 6 66.6
subroutine 5 5 100.0
pod 0 2 0.0
total 30 36 83.3


line stmt bran cond sub pod time code
1             package Text::Trac::LinkResolver::Report;
2              
3 8     8   46 use strict;
  8         12  
  8         192  
4 8     8   34 use warnings;
  8         15  
  8         175  
5 8     8   33 use base qw( Text::Trac::LinkResolver );
  8         11  
  8         32  
6              
7             our $VERSION = '0.24';
8              
9             sub init {
10 1607     1607 0 2083 my $self = shift;
11 1607         2854 $self->{pattern} = '!?\{\d+\}';
12             }
13              
14             sub format_link {
15 5     5 0 13 my ( $self, $match, $target, $label ) = @_;
16 5 50       27 return $match if $self->_is_disabled;
17              
18 5         36 my $c = $self->{context};
19 5   66     20 $label ||= $match;
20 5         22 my ($rev) = ( $match =~ m/(\d+)/ );
21              
22 5   66     91 my $url = $c->{trac_report_url} || $c->trac_url . 'report/';
23 5         32 $url .= $rev;
24 5 50       51 return sprintf '%s', ( $c->{class} ? q{class="report"} : '' ), $url, $label;
25             }
26              
27             1;