File Coverage

blib/lib/Text/Trac/LinkResolver/Log.pm
Criterion Covered Total %
statement 18 18 100.0
branch 3 4 75.0
condition 4 6 66.6
subroutine 5 5 100.0
pod 0 2 0.0
total 30 35 85.7


line stmt bran cond sub pod time code
1             package Text::Trac::LinkResolver::Log;
2              
3 8     8   54 use strict;
  8         17  
  8         225  
4 8     8   39 use warnings;
  8         15  
  8         208  
5 8     8   41 use base qw( Text::Trac::LinkResolver );
  8         13  
  8         39  
6              
7             our $VERSION = '0.22';
8              
9             sub init {
10 1607     1607 0 2506 my $self = shift;
11 1607         3375 $self->{pattern} = '!?\[\d+:\d+\]|(?:\b|!)r\d+:\d+\b';
12             }
13              
14             sub format_link {
15 8     8 0 28 my ( $self, $match, $target, $label ) = @_;
16 8 100       53 return $match if $self->_is_disabled;
17              
18 7         30 my $c = $self->{context};
19 7   66     32 $label ||= $match;
20 7         46 my ( $from, $to ) = ( $match =~ m/(\d+):(\d+)/ );
21              
22 7   66     156 my $url = $c->{trac_log_url} || $c->trac_url . 'log/';
23 7 50       136 return sprintf '%s', ( $c->{class} ? q{class="source"} : '' ), $url,
24             $to, $from, $label;
25             }
26              
27             1;