line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Collage; |
2
|
2
|
|
|
2
|
|
6891
|
use v5.24; |
|
2
|
|
|
|
|
15
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
500
|
use experimental qw< signatures >; |
|
2
|
|
|
|
|
3768
|
|
|
2
|
|
|
|
|
9
|
|
5
|
2
|
|
|
2
|
|
265
|
no warnings qw< experimental::signatures >; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
137
|
|
6
|
|
|
|
|
|
|
{ our $VERSION = '0.001' } |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
13
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
118
|
|
9
|
2
|
|
|
2
|
|
1082
|
use English qw< -no_match_vars >; |
|
2
|
|
|
|
|
7265
|
|
|
2
|
|
|
|
|
10
|
|
10
|
2
|
|
|
2
|
|
2219
|
use JSON::PP qw< decode_json >; |
|
2
|
|
|
|
|
31441
|
|
|
2
|
|
|
|
|
153
|
|
11
|
2
|
|
|
2
|
|
968
|
use Data::Resolver qw< file_to_data generate >; |
|
2
|
|
|
|
|
6801
|
|
|
2
|
|
|
|
|
131
|
|
12
|
2
|
|
|
2
|
|
867
|
use PDF::Collage::Template (); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
59
|
|
13
|
2
|
|
|
2
|
|
1045
|
use PDF::Collage::TemplatesCollection (); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
62
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
13
|
use Exporter 'import'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1682
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw< |
17
|
|
|
|
|
|
|
collage |
18
|
|
|
|
|
|
|
collage_from_definition |
19
|
|
|
|
|
|
|
collage_from_dir |
20
|
|
|
|
|
|
|
collage_from_resolver |
21
|
|
|
|
|
|
|
collage_from_tar |
22
|
|
|
|
|
|
|
>; |
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [@EXPORT_OK],); |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
6
|
1
|
22009
|
sub collage ($input, @args) { |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
11
|
|
26
|
6
|
50
|
|
|
|
42
|
my %args = @args == 0 ? (auto => $input) : ($input, @args); |
27
|
|
|
|
|
|
|
return collage_from_resolver($args{resolver}) |
28
|
6
|
100
|
|
|
|
32
|
if defined $args{resolver}; |
29
|
5
|
50
|
|
|
|
23
|
return collage_from_dir($args{dir}) if defined $args{dir}; |
30
|
5
|
50
|
|
|
|
19
|
return collage_from_tar($args{tar}) if defined $args{tar}; |
31
|
|
|
|
|
|
|
return collage_from_definition($args{definition}) |
32
|
5
|
50
|
|
|
|
18
|
if defined $args{definition}; |
33
|
5
|
50
|
|
|
|
20
|
if (defined(my $auto = $args{auto})) { |
34
|
5
|
|
|
|
|
15
|
my $ar = ref($auto); |
35
|
5
|
50
|
|
|
|
18
|
return collage_from_resolver($auto) if $ar eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
5
|
50
|
33
|
|
|
43
|
if ($ar eq '' && $auto =~ m{\A [\[\{]}mxs) { |
38
|
0
|
|
|
|
|
0
|
$auto = decode_json($auto); |
39
|
0
|
|
|
|
|
0
|
$ar = ref($auto); |
40
|
|
|
|
|
|
|
} |
41
|
5
|
50
|
33
|
|
|
68
|
return collage_from_definition($auto) |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
42
|
|
|
|
|
|
|
if ($ar eq '' && $ar =~ m{\A \s* [\[\{] }mxs) |
43
|
|
|
|
|
|
|
|| ($ar eq 'HASH') |
44
|
|
|
|
|
|
|
|| ($ar eq 'ARRAY'); |
45
|
|
|
|
|
|
|
|
46
|
5
|
50
|
|
|
|
17
|
croak "cannot handle auto input of type $ar" if $ar ne ''; |
47
|
5
|
50
|
|
|
|
134
|
croak "cannot use provided automatic hint" unless -r $auto; |
48
|
|
|
|
|
|
|
|
49
|
5
|
100
|
|
|
|
74
|
return collage_from_dir($auto) if -d $auto; |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
106
|
open my $fh, '<:raw', $auto or croak "open('$auto'): $OS_ERROR"; |
52
|
2
|
|
|
|
|
16
|
my $first = ''; |
53
|
2
|
|
|
|
|
121
|
my $n = read $fh, $first, 1; |
54
|
2
|
50
|
|
|
|
19
|
croak "sysread() on '$auto': $OS_ERROR" unless defined $n; |
55
|
2
|
|
|
|
|
39
|
close $fh; |
56
|
2
|
50
|
33
|
|
|
23
|
return collage_from_definition(file_to_data($auto)) |
57
|
|
|
|
|
|
|
if ($first eq '{') || ($first eq '{'); |
58
|
2
|
|
|
|
|
9
|
return collage_from_tar($auto); |
59
|
|
|
|
|
|
|
} ## end if (defined(my $auto =...)) |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
croak 'no useful input'; |
62
|
|
|
|
|
|
|
} ## end sub collage |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
1
|
0
|
sub collage_from_definition ($def) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
65
|
0
|
0
|
|
|
|
0
|
$def = decode_json($def) unless ref $def; |
66
|
0
|
0
|
|
|
|
0
|
$def = {commands => $def} if ref($def) eq 'ARRAY'; |
67
|
0
|
|
|
|
|
0
|
return PDF::Collage::Template->new($def->%*); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
3
|
|
|
3
|
1
|
10
|
sub collage_from_dir ($path, %args) { |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
7
|
|
71
|
3
|
|
|
|
|
30
|
my $resolver = generate( |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
%args, |
74
|
|
|
|
|
|
|
root => $path, |
75
|
|
|
|
|
|
|
-factory => 'resolver_from_dir', |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
); |
78
|
3
|
|
|
|
|
15050
|
return collage_from_resolver($resolver); |
79
|
|
|
|
|
|
|
} ## end sub collage_from_dir |
80
|
|
|
|
|
|
|
|
81
|
6
|
|
|
6
|
1
|
19
|
sub collage_from_resolver ($resolver) { |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
12
|
|
82
|
6
|
|
|
|
|
190
|
return PDF::Collage::TemplatesCollection->new(resolver => $resolver); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
2
|
|
|
2
|
1
|
6
|
sub collage_from_tar ($path, %args) { |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
3
|
|
86
|
2
|
|
|
|
|
20
|
my $resolver = generate( |
87
|
|
|
|
|
|
|
{ |
88
|
|
|
|
|
|
|
%args, |
89
|
|
|
|
|
|
|
archive => $path, |
90
|
|
|
|
|
|
|
-factory => 'resolver_from_tar', |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
); |
93
|
2
|
|
|
|
|
51784
|
return collage_from_resolver($resolver); |
94
|
|
|
|
|
|
|
} ## end sub collage_from_dir |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |