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   47 use strict;
  8         12  
  8         189  
4 8     8   32 use warnings;
  8         14  
  8         188  
5 8     8   34 use base qw( Text::Trac::LinkResolver );
  8         12  
  8         35  
6              
7             our $VERSION = '0.24';
8              
9             sub init {
10 1607     1607 0 2052 my $self = shift;
11 1607         2778 $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       50 return $match if $self->_is_disabled;
17              
18 7         30 my $c = $self->{context};
19 7   66     28 $label ||= $match;
20 7         41 my ( $from, $to ) = ( $match =~ m/(\d+):(\d+)/ );
21              
22 7   66     136 my $url = $c->{trac_log_url} || $c->trac_url . 'log/';
23 7 50       117 return sprintf '%s', ( $c->{class} ? q{class="source"} : '' ), $url,
24             $to, $from, $label;
25             }
26              
27             1;