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   52 use strict;
  8         18  
  8         234  
4 8     8   40 use warnings;
  8         15  
  8         233  
5 8     8   41 use base qw( Text::Trac::LinkResolver );
  8         13  
  8         41  
6              
7             our $VERSION = '0.22';
8              
9             sub init {
10 1607     1607 0 2394 my $self = shift;
11 1607         3409 $self->{pattern} = '!?\{\d+\}';
12             }
13              
14             sub format_link {
15 5     5 0 17 my ( $self, $match, $target, $label ) = @_;
16 5 50       29 return $match if $self->_is_disabled;
17              
18 5         27 my $c = $self->{context};
19 5   66     24 $label ||= $match;
20 5         25 my ($rev) = ( $match =~ m/(\d+)/ );
21              
22 5   66     106 my $url = $c->{trac_report_url} || $c->trac_url . 'report/';
23 5         41 $url .= $rev;
24 5 50       77 return sprintf '%s', ( $c->{class} ? q{class="report"} : '' ), $url, $label;
25             }
26              
27             1;