line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Papery::Pulp; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
76280
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
3689
|
use Papery::Util; # do not import merge_meta() |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
91
|
|
7
|
2
|
|
|
2
|
|
2262
|
use Storable qw( dclone ); |
|
2
|
|
|
|
|
16764
|
|
|
2
|
|
|
|
|
627
|
|
8
|
2
|
|
|
2
|
|
25
|
use File::Spec; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
52
|
|
9
|
2
|
|
|
2
|
|
33
|
use File::Path; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2621
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
1
|
16329
|
my ( $class, $meta ) = @_; |
13
|
1
|
50
|
|
|
|
171
|
return bless { meta => $meta ? dclone($meta) : {} }, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
1
|
0
|
sub merge_meta { Papery::Util::merge_meta( $_[0]->{meta}, $_[1] ); } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# Steps handlers |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# utility method |
23
|
|
|
|
|
|
|
sub _class_args { |
24
|
1
|
|
|
1
|
|
10
|
my ( $self, $step_handler) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# compute the base class name |
27
|
1
|
|
|
|
|
9
|
my $base = $step_handler; |
28
|
1
|
|
|
|
|
13
|
$base =~ s/^_//; |
29
|
1
|
|
|
|
|
4
|
$base = 'Papery::' . ucfirst $base; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# get the values from the meta |
32
|
1
|
|
|
|
|
6
|
my $which = $self->{meta}{$step_handler}; |
33
|
1
|
50
|
|
|
|
9
|
my ( $class, @args ) = ref $which eq 'ARRAY' ? @{$which} : $which; |
|
0
|
|
|
|
|
0
|
|
34
|
1
|
50
|
|
|
|
9
|
return $class ? "$base\::$class" : $base, @args; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub analyze_file { |
38
|
1
|
|
|
1
|
1
|
14
|
my ( $self, $file ) = @_; |
39
|
1
|
|
|
|
|
11
|
my ( $class, @options ) = $self->_class_args('_analyzer'); |
40
|
1
|
50
|
|
|
|
13
|
return $self if !$class; |
41
|
1
|
50
|
|
|
|
141
|
eval "require $class" or die $@; |
42
|
0
|
|
|
|
|
|
return $class->analyze_file( $self, $file, @options ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub process { |
46
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
47
|
0
|
|
|
|
|
|
my ( $class, @options ) = $self->_class_args('_processor'); |
48
|
0
|
0
|
|
|
|
|
return $self if !$class; |
49
|
0
|
0
|
|
|
|
|
eval "require $class" or die $@; |
50
|
0
|
|
|
|
|
|
return $class->process($self, @options); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub render { |
54
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
55
|
0
|
|
|
|
|
|
my ( $class, @options ) = $self->_class_args('_renderer'); |
56
|
0
|
0
|
|
|
|
|
return $self if !$class; |
57
|
0
|
0
|
|
|
|
|
eval "require $class" or die $@; |
58
|
0
|
|
|
|
|
|
return $class->render($self, @options); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub save { |
62
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
63
|
0
|
|
|
|
|
|
my $meta = $self->{meta}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# _permalink is relative to __destination |
66
|
0
|
0
|
|
|
|
|
$meta->{_permalink} = $meta->{__source_path} |
67
|
|
|
|
|
|
|
if !exists $meta->{_permalink}; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $abspath |
70
|
|
|
|
|
|
|
= File::Spec->catfile( $meta->{__destination}, $meta->{_permalink} ); |
71
|
0
|
|
|
|
|
|
my ( $volume, $directories, $file ) = File::Spec->splitpath($abspath); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# portably compute the directory path |
74
|
0
|
|
|
|
|
|
my $dir = File::Spec->catpath( $volume, $directories, '' ); |
75
|
0
|
0
|
|
|
|
|
mkpath($dir) if !-e $dir; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# now create the file and dump the output |
78
|
0
|
0
|
|
|
|
|
open my $fh, '>', $abspath or die "Can't create $abspath: $!"; |
79
|
0
|
|
|
|
|
|
print {$fh} $meta->{_output}; |
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
close $fh; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |