EP/Producer/File.pm

filter: Statementstmt 66.6% 4 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 75.0% 6 / 8 CC 1 SCAR 1.4
CC
1
Cov
67%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« EP/Processor/XSLTParser.pm ↑ Summary EP.pm »
1 # -*- perl -*-
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 0 ▶use XML::DOM ();
Subroutine BEGIN: called CC=1 SCAR=2.6
6
7 package XML::EP::Producer::File;
8
9 $XML::EP::Producer::File::VERSION = '0.01';
10
11
12 sub new {
13 my $proto = shift;
14 my $self = (@_ == 1) ? \%{ shift() } : { @_ };
15 bless($self, (ref($proto) || $proto));
16 }
17
18 sub Produce {
19 my $self = shift; my $ep = shift;
20 my $request = $ep->Request();
21 my $path = $request->PathTranslated() || $request->PathInfo() ||
22 die XML::EP::Error->new("Missing path specification", 500);
23 die XML::EP::Error->new("No such file or directory", 404)
24 unless -f $path;
25 $ep->{'path'} = $path;
26 $ep->{'path_mtime'} = (stat _)[9];
27 my $parser = XML::DOM::Parser->new();
28 my $xml = $parser->parsefile($path) ||
29 die XML::EP::Error->new("Failed to parse $path", 500);
30 $xml;
31 }
32
33
34 1;
« EP/Processor/XSLTParser.pm ↑ Summary EP.pm »