File Coverage

blib/lib/Text/Trac/LinkResolver/Ticket.pm
Criterion Covered Total %
statement 19 19 100.0
branch 3 4 75.0
condition 4 6 66.6
subroutine 5 5 100.0
pod 0 2 0.0
total 31 36 86.1


line stmt bran cond sub pod time code
1             package Text::Trac::LinkResolver::Ticket;
2              
3 8     8   46 use strict;
  8         15  
  8         190  
4 8     8   31 use warnings;
  8         14  
  8         174  
5 8     8   30 use base qw( Text::Trac::LinkResolver );
  8         12  
  8         33  
6              
7             our $VERSION = '0.24';
8              
9             sub init {
10 1607     1607 0 1959 my $self = shift;
11 1607         2865 $self->{pattern} = '!?(?
12             }
13              
14             sub format_link {
15 7     7 0 23 my ( $self, $match, $target, $label ) = @_;
16 7 100       44 return $match if $self->_is_disabled;
17              
18 6         28 my $c = $self->{context};
19 6   66     21 $label ||= $match;
20 6         24 my ($rev) = ( $match =~ m/(\d+)/ );
21              
22 6   66     120 my $url = $c->{trac_ticket_url} || $c->trac_url . 'ticket/';
23 6         41 $url .= $rev;
24 6 50       77 return sprintf '%s', ( $c->{class} ? q{class="ticket"} : '' ), $url, $label;
25             }
26              
27             1;