| 1 | package App::XML::DocBook::Docmake; | ||||||||||||||||||||||||||||||||||
| 2 | 3 | $App::XML::DocBook::Docmake::VERSION = '0.1101'; | |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Getopt::Long qw/ GetOptionsFromArray /; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use File::Path qw/ mkpath /; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Pod::Usage qw/ pod2usage /; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use File::ShouldUpdate v0.2.0 qw/ should_update_multi /; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use App::XML::DocBook::Docmake::CmdComponent (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use Class::XSAccessor { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | 3 | accessors => [ | |||||||||||||||||||||||||||||||||
| 18 | qw( | ||||||||||||||||||||||||||||||||||
| 19 | _base_path | ||||||||||||||||||||||||||||||||||
| 20 | _has_output | ||||||||||||||||||||||||||||||||||
| 21 | _input_path | ||||||||||||||||||||||||||||||||||
| 22 | _make_like | ||||||||||||||||||||||||||||||||||
| 23 | _mode | ||||||||||||||||||||||||||||||||||
| 24 | _output_path | ||||||||||||||||||||||||||||||||||
| 25 | _stylesheet | ||||||||||||||||||||||||||||||||||
| 26 | _trailing_slash | ||||||||||||||||||||||||||||||||||
| 27 | _use_xsl_ns | ||||||||||||||||||||||||||||||||||
| 28 | _verbose | ||||||||||||||||||||||||||||||||||
| 29 | _real_mode | ||||||||||||||||||||||||||||||||||
| 30 | _xslt_mode | ||||||||||||||||||||||||||||||||||
| 31 | _xslt_stringparams | ||||||||||||||||||||||||||||||||||
| 32 | ) | ||||||||||||||||||||||||||||||||||
| 33 | ] | ||||||||||||||||||||||||||||||||||
| 34 | 3 | }; | |||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | use Test::Trap | ||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | qw( trap $trap :flow:stderr(systemsafe):stdout(systemsafe):warn ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 3 | my %modes = ( | |||||||||||||||||||||||||||||||||
| 41 | 'fo' => {}, | ||||||||||||||||||||||||||||||||||
| 42 | 'help' => { | ||||||||||||||||||||||||||||||||||
| 43 | standalone => 1, | ||||||||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||||||||
| 45 | 'manpages' => {}, | ||||||||||||||||||||||||||||||||||
| 46 | 'xhtml' => {}, | ||||||||||||||||||||||||||||||||||
| 47 | 'xhtml-1_1' => { | ||||||||||||||||||||||||||||||||||
| 48 | real_mode => "xhtml", | ||||||||||||||||||||||||||||||||||
| 49 | }, | ||||||||||||||||||||||||||||||||||
| 50 | 'xhtml5' => { | ||||||||||||||||||||||||||||||||||
| 51 | real_mode => "xhtml", | ||||||||||||||||||||||||||||||||||
| 52 | }, | ||||||||||||||||||||||||||||||||||
| 53 | 'rtf' => { | ||||||||||||||||||||||||||||||||||
| 54 | xslt_mode => "fo", | ||||||||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||||||||
| 56 | 'pdf' => { | ||||||||||||||||||||||||||||||||||
| 57 | xslt_mode => "fo", | ||||||||||||||||||||||||||||||||||
| 58 | }, | ||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | sub new | ||||||||||||||||||||||||||||||||||
| 62 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 63 | 13 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 64 | 13 | my $self = {}; | |||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | 13 | bless $self, $class; | |||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | 13 | $self->_init(@_); | |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | 13 | return $self; | |||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | sub _calc_modes_hash | ||||||||||||||||||||||||||||||||||
| 74 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_calc_modes_hash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 75 | 13 | my ( $self, ) = @_; | |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | 13 | return \%modes; | |||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | sub _lookup_mode_struct | ||||||||||||||||||||||||||||||||||
| 81 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_lookup_mode_struct: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 82 | 13 | my ( $self, $mode ) = @_; | |||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | 13 | return $self->_calc_modes_hash()->{$mode}; | |||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | sub _init | ||||||||||||||||||||||||||||||||||
| 88 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=10 SCAR=24.0
| |||||||||||||||||||||||||||||||||||
| 89 | 13 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | 13 | my $argv = $args->{'argv'}; | |||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||
| 93 | 13 | my $output_path; | |||||||||||||||||||||||||||||||||
| 94 | 13 | my $verbose = 0; | |||||||||||||||||||||||||||||||||
| 95 | 13 | my $stylesheet; | |||||||||||||||||||||||||||||||||
| 96 | my @in_stringparams; | ||||||||||||||||||||||||||||||||||
| 97 | 13 | my $base_path; | |||||||||||||||||||||||||||||||||
| 98 | 13 | my $make_like = 0; | |||||||||||||||||||||||||||||||||
| 99 | 13 | my $_use_xsl_ns = 0; | |||||||||||||||||||||||||||||||||
| 100 | 13 | my ( $help, $man ); | |||||||||||||||||||||||||||||||||
| 101 | 13 | my $trailing_slash = 1; | |||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||
| 103 | 13 | my $ret = GetOptionsFromArray( | |||||||||||||||||||||||||||||||||
| 104 | $argv, | ||||||||||||||||||||||||||||||||||
| 105 | "o=s" => \$output_path, | ||||||||||||||||||||||||||||||||||
| 106 | "v|verbose" => \$verbose, | ||||||||||||||||||||||||||||||||||
| 107 | "x|stylesheet=s" => \$stylesheet, | ||||||||||||||||||||||||||||||||||
| 108 | "stringparam=s" => \@in_stringparams, | ||||||||||||||||||||||||||||||||||
| 109 | "basepath=s" => \$base_path, | ||||||||||||||||||||||||||||||||||
| 110 | "make" => \$make_like, | ||||||||||||||||||||||||||||||||||
| 111 | 'help|h' => \$help, | ||||||||||||||||||||||||||||||||||
| 112 | 'man' => \$man, | ||||||||||||||||||||||||||||||||||
| 113 | 'ns' => \$_use_xsl_ns, | ||||||||||||||||||||||||||||||||||
| 114 | 'trailing-slash=i' => \$trailing_slash, | ||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||
| 117 | 13 | ▶ | if ( !$ret ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||
| 119 | 0 | pod2usage(2); | |||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||
| 121 | 13 | ▶ | if ($help) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||||||||
| 123 | 0 | pod2usage(1); | |||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||
| 125 | 13 | ▶ | if ($man) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||||
| 127 | 0 | pod2usage( -exitstatus => 0, -verbose => 2 ); | |||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | 13 | my @stringparams; | |||||||||||||||||||||||||||||||||
| 131 | 13 | foreach my $param (@in_stringparams) | |||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||
| 133 | 7 | ▶ | if ( $param =~ m{\A([^=]+)=(.*)\z}ms ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||
| 135 | 7 | push @stringparams, [ $1, $2 ]; | |||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||
| 137 | else | ||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||
| 139 | 0 | die "Wrong stringparam argument '$param'! Does not contain a '='!"; | |||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | 13 | ▶ | $self->_has_output( $self->_output_path($output_path) ? 1 : 0 ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | 13 | $self->_verbose($verbose); | |||||||||||||||||||||||||||||||||
| 146 | 13 | $self->_stylesheet($stylesheet); | |||||||||||||||||||||||||||||||||
| 147 | 13 | $self->_xslt_stringparams( \@stringparams ); | |||||||||||||||||||||||||||||||||
| 148 | 13 | $self->_make_like($make_like); | |||||||||||||||||||||||||||||||||
| 149 | 13 | $self->_base_path($base_path); | |||||||||||||||||||||||||||||||||
| 150 | 13 | $self->_trailing_slash($trailing_slash); | |||||||||||||||||||||||||||||||||
| 151 | 13 | $self->_use_xsl_ns($_use_xsl_ns); | |||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | 13 | my $mode = shift(@$argv); | |||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | 13 | my $mode_struct = $self->_lookup_mode_struct($mode); | |||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | 13 | ▶ | if ($mode_struct) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||||||||
| 159 | 13 | $self->_mode($mode); | |||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 26 | ▶ | my $assign_secondary_mode = sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||
| 162 | 26 | my ( $struct_field, $attr ) = @_; | |||||||||||||||||||||||||||||||||
| 163 | 26 | ▶ | $self->$attr( $mode_struct->{$struct_field} || $mode ); | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
$mode_struct->{$struct_field} || $mode
MC/DC0%0/2
$mode_struct->{$struct_field} || $mode
$mode_struct->{$struct_field}
$mode
Truth table66%2/3
A || B
A= $mode_struct->{$struct_field}B= $mode
| |||||||||||||||||||||||||||||||||||
| 164 | 13 | }; | |||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | 13 | $assign_secondary_mode->( 'real_mode', '_real_mode' ); | |||||||||||||||||||||||||||||||||
| 167 | 13 | $assign_secondary_mode->( 'xslt_mode', '_xslt_mode' ); | |||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||
| 169 | else | ||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||
| 171 | 0 | die "Unknown mode \"$mode\""; | |||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | 13 | my $input_path = shift(@$argv); | |||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | 13 | ▶ | if ( !( defined($input_path) || $mode_struct->{standalone} ) ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $input_path || $mode_struct->{'standalone'}
MC/DC0%0/2
defined $input_path || $mode_struct->{'standalone'}
defined $input_path
$mode_struct->{'standalone'}
Truth table66%2/3
A || B
A= defined $input_pathB= $mode_struct->{'standalone'}
| |||||||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||||||
| 178 | 0 | die "Input path not specified on command line"; | |||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||
| 180 | else | ||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||
| 182 | 13 | $self->_input_path($input_path); | |||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||
| 185 | 13 | return; | |||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | sub _exec_command | ||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_exec_command: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 191 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||
| 193 | 0 | my $cmd = $args->{cmd}; | |||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ( $self->_verbose() ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||
| 197 | 0 | print( join( " ", @$cmd ), "\n" ); | |||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||
| 200 | 0 | my $exit_code; | |||||||||||||||||||||||||||||||||
| 201 | trap | ||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 203 | 0 | local $ENV{LC_ALL} = "C.utf-8"; | |||||||||||||||||||||||||||||||||
| 204 | 0 | $exit_code = system(@$cmd); | |||||||||||||||||||||||||||||||||
| 205 | 0 | }; | |||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | 0 | my $stderr = $trap->stderr(); | |||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( not( defined($exit_code) and ( !$exit_code ) ) ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $exit_code and not $exit_code
MC/DC0%0/2
defined $exit_code and not $exit_code
defined $exit_code
not $exit_code
Truth table0%0/3
A and not(B)
A= defined $exit_codeB= not $exit_code
| |||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ( $stderr =~ m#Attempt to load network entity# ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ( $args->{xsltproc} ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||
| 215 | 0 | die <<"EOF"; | |||||||||||||||||||||||||||||||||
| 216 | Running xsltproc failed due to lacking local DocBook 5/XSL stylesheets and data. | ||||||||||||||||||||||||||||||||||
| 217 | See: https://github.com/shlomif/fortune-mod/issues/45 and | ||||||||||||||||||||||||||||||||||
| 218 | https://github.com/docbook/wiki/wiki/DocBookXslStylesheets | ||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||
| 220 | Command was <<@$cmd>>; | ||||||||||||||||||||||||||||||||||
| 221 | EOF | ||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||
| 224 | 0 | die qq/$stderr\n<<@$cmd>> failed./; | |||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||
| 227 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | sub run | ||||||||||||||||||||||||||||||||||
| 231 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 232 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | 12 | my $real_mode = $self->_real_mode(); | |||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||
| 236 | 12 | my $mode_func = '_run_mode_' . $self->_real_mode; | |||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | 12 | return $self->$mode_func(@_); | |||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | sub _run_mode_help | ||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_mode_help: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 243 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||
| 245 | 1 | print <<"EOF"; | |||||||||||||||||||||||||||||||||
| 246 | Docmake version $App::XML::DocBook::Docmake::VERSION | ||||||||||||||||||||||||||||||||||
| 247 | A tool to convert DocBook/XML to other formats | ||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||
| 249 | Available commands: | ||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||
| 251 | help - this help screen. | ||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||
| 253 | fo - convert to XSL-FO. | ||||||||||||||||||||||||||||||||||
| 254 | manpages - convert to Unix manpage (nroff) | ||||||||||||||||||||||||||||||||||
| 255 | rtf - convert to RTF (MS Word). | ||||||||||||||||||||||||||||||||||
| 256 | pdf - convert to PDF (Adobe Acrobat). | ||||||||||||||||||||||||||||||||||
| 257 | xhtml - convert to XHTML. | ||||||||||||||||||||||||||||||||||
| 258 | xhtml-1_1 - convert to XHTML-1.1. | ||||||||||||||||||||||||||||||||||
| 259 | xhtml5 - convert to XHTML5 | ||||||||||||||||||||||||||||||||||
| 260 | EOF | ||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||
| 263 | sub _is_older | ||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_is_older: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 265 | 0 | my ( $self, $result_fn, $source_fn ) = @_; | |||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||
| 267 | 0 | return should_update_multi( [ $result_fn, ], ':', [ $source_fn, ] ); | |||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||
| 270 | sub _should_update_output | ||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_should_update_output: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 272 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||
| 274 | 0 | return $self->_is_older( $args->{output}, $args->{input} ); | |||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||
| 277 | sub _run_mode_fo | ||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_mode_fo: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 279 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 280 | 0 | return $self->_run_xslt(); | |||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||
| 283 | sub _mkdir | ||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_mkdir: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 285 | 0 | my ( $self, $dir ) = @_; | |||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||
| 287 | 0 | mkpath($dir); | |||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||
| 289 | 0 | return; | |||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||
| 292 | sub _run_mode_manpages | ||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_mode_manpages: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 294 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||
| 296 | # Create the directory, because xsltproc requires it. | ||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ( $self->_trailing_slash ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||
| 299 | # die "don't add trailing_slash"; | ||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||
| 301 | # $self->_mkdir( $self->_output_path() ); | ||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | 0 | return $self->_run_xslt(); | |||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||
| 307 | sub _run_mode_xhtml | ||||||||||||||||||||||||||||||||||
| 308 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_mode_xhtml: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 309 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||
| 311 | # Create the directory, because xsltproc requires it. | ||||||||||||||||||||||||||||||||||
| 312 | 7 | ▶ | if ( $self->_trailing_slash ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||||
| 314 | 6 | $self->_mkdir( $self->_output_path() ); | |||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||
| 317 | 7 | return $self->_run_xslt(); | |||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||
| 320 | sub _calc_default_xslt_stylesheet | ||||||||||||||||||||||||||||||||||
| 321 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_calc_default_xslt_stylesheet: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 322 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||
| 324 | 10 | my $mode = $self->_xslt_mode(); | |||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||
| 326 | return | ||||||||||||||||||||||||||||||||||
| 327 | 10 | ▶ | sprintf( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 328 | "http://docbook.sourceforge.net/release/%s/current/%s/docbook.xsl", | ||||||||||||||||||||||||||||||||||
| 329 | ( $self->_use_xsl_ns() ? "xsl-ns" : "xsl" ), $mode, ); | ||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||
| 332 | sub _is_xhtml | ||||||||||||||||||||||||||||||||||
| 333 | 27 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_is_xhtml: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 334 | 27 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | 27 | ▶ | return ( ( $self->_mode() eq "xhtml" ) | ||||||||||||||||||||||||||||||||
|
Condition100%6/6
$self->_mode eq 'xhtml' || $self->_mode eq 'xhtml-1_1' || $self->_mode eq 'xhtml5'
$self->_mode eq "xhtml" or $self->_mode eq "xhtml-1_1"
MC/DC100%3/3
$self->_mode eq 'xhtml' || $self->_mode eq 'xhtml-1_1' || $self->_mode eq 'xhtml5'
$self->_mode eq "xhtml"
$self->_mode eq "xhtml-1_1"
$self->_mode eq 'xhtml5'
Truth table100%4/4
A or B || C
A= $self->_mode eq "xhtml"B= $self->_mode eq "xhtml-1_1"C= $self->_mode eq 'xhtml5'
| |||||||||||||||||||||||||||||||||||
| 337 | || ( $self->_mode() eq "xhtml-1_1" ) | ||||||||||||||||||||||||||||||||||
| 338 | || ( $self->_mode() eq "xhtml5" ) ); | ||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||
| 341 | sub _calc_output_param_for_xslt | ||||||||||||||||||||||||||||||||||
| 342 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_calc_output_param_for_xslt: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||
| 343 | 18 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||
| 345 | 18 | my $output_path = $self->_output_path(); | |||||||||||||||||||||||||||||||||
| 346 | 18 | ▶ | if ( defined( $args->{output_path} ) ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 347 | { | ||||||||||||||||||||||||||||||||||
| 348 | 6 | $output_path = $args->{output_path}; | |||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||
| 351 | 18 | ▶ | if ( !defined($output_path) ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 352 | { | ||||||||||||||||||||||||||||||||||
| 353 | 0 | die "Output path not specified!"; | |||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||
| 356 | # If it's XHTML, then it's a directory and xsltproc requires that | ||||||||||||||||||||||||||||||||||
| 357 | # it will have a trailing slash. | ||||||||||||||||||||||||||||||||||
| 358 | 18 | ▶ | if ( $self->_is_xhtml ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 359 | { | ||||||||||||||||||||||||||||||||||
| 360 | 12 | ▶ | if ( $self->_trailing_slash ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 361 | { | ||||||||||||||||||||||||||||||||||
| 362 | 10 | ▶ | if ( $output_path !~ m{/\z} ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||||||||
| 364 | 10 | $output_path .= "/"; | |||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | 18 | return $output_path; | |||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||
| 372 | sub _calc_make_output_param_for_xslt | ||||||||||||||||||||||||||||||||||
| 373 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_calc_make_output_param_for_xslt: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 374 | 9 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||
| 376 | 9 | my $output_path = $self->_calc_output_param_for_xslt($args); | |||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||
| 378 | # If it's XHTML, then we need to compare against the index.html | ||||||||||||||||||||||||||||||||||
| 379 | # because the directory is freshly made. | ||||||||||||||||||||||||||||||||||
| 380 | 9 | ▶ | if ( $self->_is_xhtml ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||||||||
| 382 | 6 | $output_path .= "index.html"; | |||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||
| 385 | 9 | return $output_path; | |||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||
| 388 | sub _pre_proc_command | ||||||||||||||||||||||||||||||||||
| 389 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_pre_proc_command: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||
| 390 | 11 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||
| 392 | 11 | my $input_fn = $args->{input}; | |||||||||||||||||||||||||||||||||
| 393 | 11 | my $output_fn = $args->{output}; | |||||||||||||||||||||||||||||||||
| 394 | 11 | my $template = $args->{template}; | |||||||||||||||||||||||||||||||||
| 395 | 11 | ▶ | my $xsltproc = ( $args->{xsltproc} // ( die "no xsltproc key" ) ); | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"xsltproc"} // die("no xsltproc key")
MC/DC0%0/1
$args->{"xsltproc"} // die("no xsltproc key")
$args->{"xsltproc"}
Truth table50%1/2
A
A= $args->{"xsltproc"}
| |||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||
| 397 | return +{ | ||||||||||||||||||||||||||||||||||
| 398 | xsltproc => $xsltproc, | ||||||||||||||||||||||||||||||||||
| 399 | cmd => [ | ||||||||||||||||||||||||||||||||||
| 400 | map { | ||||||||||||||||||||||||||||||||||
| 401 | 11 | ( ref($_) eq '' ) ? $_ | |||||||||||||||||||||||||||||||||
| 402 | : $_->is_output() ? $output_fn | ||||||||||||||||||||||||||||||||||
| 403 | : $_->is_input() ? $input_fn | ||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||
| 405 | # Not supposed to happen | ||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | : do { die "Unknown Argument in Command Template."; } | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 407 | } @$template | ||||||||||||||||||||||||||||||||||
| 408 | ] | ||||||||||||||||||||||||||||||||||
| 409 | }; | ||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||
| 412 | sub _run_input_output_cmd | ||||||||||||||||||||||||||||||||||
| 413 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_input_output_cmd: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||
| 414 | 13 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||
| 416 | 13 | my $input_fn = $args->{input}; | |||||||||||||||||||||||||||||||||
| 417 | 13 | my $output_fn = $args->{output}; | |||||||||||||||||||||||||||||||||
| 418 | 13 | ▶ | my $make_output_fn = $args->{make_output} // $output_fn; | ||||||||||||||||||||||||||||||||
|
Condition100%3/3
$args->{"make_output"} // $output_fn
MC/DC100%2/2
$args->{"make_output"} // $output_fn
$args->{"make_output"}
$output_fn
Truth table100%3/3
A // B
A= $args->{"make_output"}B= $output_fn
| |||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||
| 420 | 13 | ▶ | if ( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->_make_like or $self->_should_update_output({"input", $input_fn, "output", $make_output_fn})
MC/DC100%2/2
not $self->_make_like or $self->_should_update_output({"input", $input_fn, "output", $make_output_fn})
not $self->_make_like
$self->_should_update_output({"input", $input_fn, "output", $make_output_fn})
Truth table100%3/3
not(A) or B
A= not $self->_make_likeB= $self->_should_update_output({"input", $input_fn, "output", $make_output_fn})
| |||||||||||||||||||||||||||||||||||
| 421 | ( !$self->_make_like() ) | ||||||||||||||||||||||||||||||||||
| 422 | || $self->_should_update_output( | ||||||||||||||||||||||||||||||||||
| 423 | { | ||||||||||||||||||||||||||||||||||
| 424 | input => $input_fn, | ||||||||||||||||||||||||||||||||||
| 425 | output => $make_output_fn, | ||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||
| 427 | ) | ||||||||||||||||||||||||||||||||||
| 428 | ) | ||||||||||||||||||||||||||||||||||
| 429 | { | ||||||||||||||||||||||||||||||||||
| 430 | 11 | $self->_exec_command( $self->_pre_proc_command($args), ); | |||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||
| 434 | sub _on_output | ||||||||||||||||||||||||||||||||||
| 435 | 20 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_on_output: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 436 | 20 | my ( $self, $meth, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||
| 438 | 20 | ▶ | return $self->_has_output() ? $self->$meth($args) : (); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||
| 441 | sub _calc_output_params | ||||||||||||||||||||||||||||||||||
| 442 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_calc_output_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 443 | 9 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||
| 445 | return ( | ||||||||||||||||||||||||||||||||||
| 446 | 9 | output => $self->_calc_output_param_for_xslt($args), | |||||||||||||||||||||||||||||||||
| 447 | make_output => $self->_calc_make_output_param_for_xslt($args), | ||||||||||||||||||||||||||||||||||
| 448 | ); | ||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||
| 451 | sub _calc_template_o_flag | ||||||||||||||||||||||||||||||||||
| 452 | 9 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_calc_template_o_flag: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 453 | 9 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||
| 455 | 9 | return ( "-o", $self->_output_cmd_comp() ); | |||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||
| 458 | sub _calc_template_string_params | ||||||||||||||||||||||||||||||||||
| 459 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_calc_template_string_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 460 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||
| 462 | 7 | return [ map { ( "--stringparam", @$_ ) } | |||||||||||||||||||||||||||||||||
| 463 | 10 | @{ $self->_xslt_stringparams() } ]; | |||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||
| 466 | sub _run_xslt | ||||||||||||||||||||||||||||||||||
| 467 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_xslt: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 468 | 10 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||
| 470 | 10 | my @stylesheet_params = ( $self->_calc_default_xslt_stylesheet() ); | |||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||
| 472 | 10 | ▶ | if ( defined( $self->_stylesheet() ) ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 473 | { | ||||||||||||||||||||||||||||||||||
| 474 | 1 | @stylesheet_params = ( $self->_stylesheet() ); | |||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||
| 477 | 10 | my @base_path_params; | |||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||
| 479 | 10 | ▶ | if ( defined( $self->_base_path() ) ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||||||||
| 481 | 1 | @base_path_params = | |||||||||||||||||||||||||||||||||
| 482 | ( "--path", ( $self->_base_path() . '/' . $self->_xslt_mode() ), ); | ||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||
| 485 | return $self->_run_input_output_cmd( | ||||||||||||||||||||||||||||||||||
| 486 | { | ||||||||||||||||||||||||||||||||||
| 487 | input => $self->_input_path(), | ||||||||||||||||||||||||||||||||||
| 488 | $self->_on_output( '_calc_output_params', $args ), | ||||||||||||||||||||||||||||||||||
| 489 | xsltproc => 1, | ||||||||||||||||||||||||||||||||||
| 490 | template => [ | ||||||||||||||||||||||||||||||||||
| 491 | "xsltproc", | ||||||||||||||||||||||||||||||||||
| 492 | "--nonet", | ||||||||||||||||||||||||||||||||||
| 493 | $self->_on_output( '_calc_template_o_flag', $args ), | ||||||||||||||||||||||||||||||||||
| 494 | 10 | @{ $self->_calc_template_string_params() }, | |||||||||||||||||||||||||||||||||
| 495 | @base_path_params, | ||||||||||||||||||||||||||||||||||
| 496 | @stylesheet_params, | ||||||||||||||||||||||||||||||||||
| 497 | $self->_input_cmd_comp(), | ||||||||||||||||||||||||||||||||||
| 498 | ], | ||||||||||||||||||||||||||||||||||
| 499 | }, | ||||||||||||||||||||||||||||||||||
| 500 | ); | ||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||
| 503 | sub _run_xslt_and_from_fo | ||||||||||||||||||||||||||||||||||
| 504 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_xslt_and_from_fo: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 505 | 4 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||
| 507 | 4 | my $xslt_output_path = $self->_output_path(); | |||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||
| 509 | 4 | ▶ | if ( !defined($xslt_output_path) ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 510 | { | ||||||||||||||||||||||||||||||||||
| 511 | 1 | die "No -o flag was specified. See the help."; | |||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||
| 514 | # TODO : do something meaningful if a period (".") is not present | ||||||||||||||||||||||||||||||||||
| 515 | 3 | ▶ | if ( $xslt_output_path !~ m{\.}ms ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 516 | { | ||||||||||||||||||||||||||||||||||
| 517 | 1 | $xslt_output_path .= ".fo"; | |||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||
| 519 | else | ||||||||||||||||||||||||||||||||||
| 520 | { | ||||||||||||||||||||||||||||||||||
| 521 | 2 | $xslt_output_path =~ s{\.([^\.]*)\z}{\.fo}ms; | |||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||
| 524 | 3 | $self->_run_xslt( { output_path => $xslt_output_path } ); | |||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||
| 526 | return $self->_run_input_output_cmd( | ||||||||||||||||||||||||||||||||||
| 527 | { | ||||||||||||||||||||||||||||||||||
| 528 | input => $xslt_output_path, | ||||||||||||||||||||||||||||||||||
| 529 | output => $self->_output_path(), | ||||||||||||||||||||||||||||||||||
| 530 | template => [ | ||||||||||||||||||||||||||||||||||
| 531 | 3 | "fop", ( "-" . $args->{fo_out_format} ), | |||||||||||||||||||||||||||||||||
| 532 | $self->_output_cmd_comp(), $self->_input_cmd_comp(), | ||||||||||||||||||||||||||||||||||
| 533 | ], | ||||||||||||||||||||||||||||||||||
| 534 | xsltproc => 0, | ||||||||||||||||||||||||||||||||||
| 535 | }, | ||||||||||||||||||||||||||||||||||
| 536 | ); | ||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||
| 539 | sub _run_mode_pdf | ||||||||||||||||||||||||||||||||||
| 540 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_mode_pdf: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 541 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||
| 543 | 4 | return $self->_run_xslt_and_from_fo( | |||||||||||||||||||||||||||||||||
| 544 | { | ||||||||||||||||||||||||||||||||||
| 545 | fo_out_format => "pdf", | ||||||||||||||||||||||||||||||||||
| 546 | }, | ||||||||||||||||||||||||||||||||||
| 547 | ); | ||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||
| 550 | sub _run_mode_rtf | ||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run_mode_rtf: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 552 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||
| 554 | 0 | return $self->_run_xslt_and_from_fo( | |||||||||||||||||||||||||||||||||
| 555 | { | ||||||||||||||||||||||||||||||||||
| 556 | fo_out_format => "rtf", | ||||||||||||||||||||||||||||||||||
| 557 | }, | ||||||||||||||||||||||||||||||||||
| 558 | ); | ||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||
| 561 | sub _input_cmd_comp | ||||||||||||||||||||||||||||||||||
| 562 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_input_cmd_comp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 563 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||
| 565 | 13 | return App::XML::DocBook::Docmake::CmdComponent->new( | |||||||||||||||||||||||||||||||||
| 566 | { | ||||||||||||||||||||||||||||||||||
| 567 | is_input => 1, | ||||||||||||||||||||||||||||||||||
| 568 | is_output => 0, | ||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||
| 570 | ); | ||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||
| 573 | sub _output_cmd_comp | ||||||||||||||||||||||||||||||||||
| 574 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_output_cmd_comp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 575 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||
| 577 | 12 | return App::XML::DocBook::Docmake::CmdComponent->new( | |||||||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||||||||
| 579 | is_input => 0, | ||||||||||||||||||||||||||||||||||
| 580 | is_output => 1, | ||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||
| 582 | ); | ||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||
| 586 | 3 | 1; | |||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||
| 588 | __END__ | ||||||||||||||||||||||||||||||||||