Generator/Exporter.pm

filter: Statementstmt 48.8% 22 / 45 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 4 totaltotal 38.1% 29 / 76 CC 7 SCAR 27.8
CC
7
Cov
39%
initExporter
42.0
init
6.0
new
2.0
CRAP 16.2
« Generator/Exporter/XHTML.pm ↑ Summary Generator/Analyser.pm »
1 package EBook::Generator::Exporter;
2  
3 1 ▶use 5.008009;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use EBook::Generator::Exporter::PDF;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use EBook::Generator::Exporter::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use EBook::Generator::Exporter::XHTML;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = '0.01';
13  
14 sub new
15 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my ($class, @args) = @_;
17 0 my $self = bless {}, $class;
18 0 return $self->init(@args);
19 }
20  
21 sub init
22 0 ▶{
Subroutine init: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my ($self, $browser, $log) = @_;
24 0 $self->{'browser'} = $browser;
25 0 $self->{'log'} = $log;
26 0 foreach my $format (qw(pdf text epub xhtml)) {
27 0 $self->{$format.'-exporter'} = undef;
28 }
29 0 return $self;
30 }
31  
32 sub initExporter
33 0 ▶{
Subroutine initExporter: not called CC=6 SCAR=37.4
Pod undocumented
34 0 my ($self, $format) = @_;
35
36 # there is no extra exporter for EPUB, its just a special kind of XHTML!
37 0 ▶ if ($format =~ /^epub$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format =~ /^epub$/i) 0 0 0
38 0 $self->{'options'}->{'epub'} = 1;
39 0 $format = 'xhtml';
40 }
41  
42 # create exporter for requested export format
43 0 ▶ if ($format =~ /^(x?html?)$/i && !defined $self->{'xhtml-exporter'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($format =~ /^(x?html?)$/i and not defined $self->{'xhtml-exporter'}) { } 0 0 0
elsif ($format =~ /^(te?xt)$/i and not defined $self->{'text-exporter'}) { } 0 0 0
Condition0%0/3
$format =~ /^(x?html?)$/i and not defined $self->{"xhtml-exporter"}
!ll&&!rl&&r
000
MC/DC0%0/2
$format =~ /^(x?html?)$/i and not defined $self->{"xhtml-exporter"}
$format =~ /^(x?html?)$/i not defined $self->{"xhtml-exporter"}
Truth table0%0/3
A and not(B)
A= $format =~ /^(x?html?)$/iB= not defined $self->{"xhtml-exporter"}
ABresult
0X0
100
111
44 0 $self->{'xhtml-exporter'} = EBook::Generator::Exporter::XHTML->new($self->{'browser'});
45 0 return $self->{'xhtml-exporter'};
46 }
47 ▶ elsif ($format =~ /^(te?xt)$/i && !defined $self->{'text-exporter'}) {
Condition0%0/3
$format =~ /^(te?xt)$/i and not defined $self->{"text-exporter"}
!ll&&!rl&&r
000
MC/DC0%0/2
$format =~ /^(te?xt)$/i and not defined $self->{"text-exporter"}
$format =~ /^(te?xt)$/i not defined $self->{"text-exporter"}
Truth table0%0/3
A and not(B)
A= $format =~ /^(te?xt)$/iB= not defined $self->{"text-exporter"}
ABresult
0X0
100
111
48 0 $self->{'text-exporter'} = EBook::Generator::Exporter::Text->new($self->{'browser'});
49 0 return $self->{'text-exporter'};
50 }
51 else { #($format =~ /^(pdf)$/i && !defined $self->{'pdf-exporter'}) {
52 0 $self->{'pdf-exporter'} = EBook::Generator::Exporter::PDF->new($self->{'browser'});
53 0 return $self->{'pdf-exporter'};
54 }
55 #die "unable to handle unknown export format '$format'\n";
56 }
57  
58 sub writeEBook
59 0 ▶{
Subroutine writeEBook: not called CC=1 SCAR=6.9
Pod undocumented
60 0 my ($self, $ebook, $format, $options) = @_;
61 0 my $exporter = $self->initExporter($format);
62 #print Dumper($exporter);
63 0 return $exporter->writeEBook($ebook, $options);
64 }
65  
66 1 1;
67 __END__
« Generator/Exporter/XHTML.pm ↑ Summary Generator/Analyser.pm »