lib/MMS/Parser/WorkHorse.pm.PL

filter: Statementstmt 82.3% 28 / 34 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 80.4% 37 / 46 CC 1 SCAR 0.0
CC
1
Cov
78%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/MMS/Parser/g-startup.pl ↑ Summary blib/lib/MMS/Parser.pm »
1 # vim: filetype=perl :
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Parse::RecDescent;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Path::Class qw( file );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Slurp qw( read_file write_file );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 my $target = shift;
10 1 my @grammars = qw( WSP MMS );
11  
12 1 my $dir = file(__FILE__)->dir();
13 1 my @grammar_files = map { $dir->file("gr-$_.prd")->stringify() } @grammars;
14 1 unshift @grammar_files, $dir->file("g-startup.pl")->stringify();
15 1 ▶$target = $dir->file('WorkHorse.pm')->stringify()
Branch: 1 branch
BranchTrueFalseTotal
unless $target =~ /WorkHorse/ 1 0 1
16 unless $target =~ /WorkHorse/;
17  
18 # Check if the precompiled module has been already compiled and is
19 # up to date
20 1 ▶if (-e $target) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $target) 1 0 1
21 1 my $module_time = get_modification_time($target);
22 my $modified =
23 1 grep { get_modification_time($_) >= $module_time; } @grammar_files;
24 1 ▶ exit(0) unless $modified;
Branch: 1 branch
BranchTrueFalseTotal
unless $modified 1 0 1
25 } ## end if (-e $target)
26  
27 0 my $grammar = join '', map { read_file $_ } @grammar_files;
28 0 $Parse::RecDescent::skip = '';
29 0 Parse::RecDescent->Precompile($grammar, "MMS::Parser::WorkHorse");
30 0 write_file $target, read_file('WorkHorse.pm'), "\n";
31 0 unlink 'WorkHorse.pm';
32  
33 4 ▶sub get_modification_time { return (stat($_[0]))[9] }
Subroutine get_modification_time: called CC=1 SCAR=0.0
« blib/lib/MMS/Parser/g-startup.pl ↑ Summary blib/lib/MMS/Parser.pm »