File Coverage

blib/lib/App/Slackeria/Plugin/Ikiwiki.pm
Criterion Covered Total %
statement 18 31 58.0
branch 0 4 0.0
condition 0 5 0.0
subroutine 6 7 85.7
pod 0 1 0.0
total 24 48 50.0


line stmt bran cond sub pod time code
1             package App::Slackeria::Plugin::Ikiwiki;
2              
3 1     1   2758636 use strict;
  1         17  
  1         131  
4 1     1   7 use warnings;
  1         3  
  1         101  
5 1     1   1043 use autodie;
  1         26069  
  1         6  
6 1     1   6085 use 5.010;
  1         8  
  1         33  
7              
8 1     1   1087 use parent 'App::Slackeria::Plugin';
  1         375  
  1         8  
9              
10             our $VERSION = '0.12';
11              
12             sub check {
13 0     0 0   my ($self) = @_;
14              
15 0           my $p = $self->{conf}->{name};
16              
17 0   0       my $re_p = $self->{conf}->{title_name} // $p;
18              
19 0           my $pfile = sprintf( $self->{conf}->{source_file}, $p );
20 0           my $re_title = qr{
21             ^ \[ \[ \! meta\s title = "
22             $re_p (?: \s v (? [0-9.-]+ ))?
23             " ]] $
24             }x;
25              
26 0 0         if ( not -e $pfile ) {
27 0           die("No project file\n");
28             }
29             else {
30 0           open( my $fh, '<', $pfile );
31 0           while ( my $line = <$fh> ) {
32 0 0         if ( $line =~ $re_title ) {
33 1   0 1   1134 return { data => $+{version} // q{}, };
  1         819  
  1         116  
  0            
34             }
35             }
36 0           close($fh);
37 0           die("Wrong name or no title\n");
38             }
39             }
40              
41             1;
42              
43             __END__