line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Collage; |
2
|
2
|
|
|
2
|
|
6926
|
use v5.24; |
|
2
|
|
|
|
|
16
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
55
|
|
4
|
2
|
|
|
2
|
|
496
|
use experimental qw< signatures >; |
|
2
|
|
|
|
|
3614
|
|
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
270
|
no warnings qw< experimental::signatures >; |
|
2
|
|
|
|
|
20
|
|
|
2
|
|
|
|
|
122
|
|
6
|
|
|
|
|
|
|
{ our $VERSION = '0.001001' } |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
114
|
|
9
|
2
|
|
|
2
|
|
1070
|
use English qw< -no_match_vars >; |
|
2
|
|
|
|
|
6974
|
|
|
2
|
|
|
|
|
11
|
|
10
|
2
|
|
|
2
|
|
2342
|
use JSON::PP qw< decode_json >; |
|
2
|
|
|
|
|
31688
|
|
|
2
|
|
|
|
|
132
|
|
11
|
2
|
|
|
2
|
|
13
|
use Scalar::Util qw< blessed >; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
156
|
|
12
|
2
|
|
|
2
|
|
917
|
use Data::Resolver qw< file_to_data >; |
|
2
|
|
|
|
|
6845
|
|
|
2
|
|
|
|
|
119
|
|
13
|
2
|
|
|
2
|
|
2499
|
use PDF::Collage::Template (); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
72
|
|
14
|
2
|
|
|
2
|
|
1073
|
use PDF::Collage::TemplatesCollection (); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
59
|
|
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
31
|
use Exporter 'import'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1662
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw< |
18
|
|
|
|
|
|
|
collage |
19
|
|
|
|
|
|
|
collage_from_definition |
20
|
|
|
|
|
|
|
collage_from_dir |
21
|
|
|
|
|
|
|
collage_from_resolver |
22
|
|
|
|
|
|
|
collage_from_tar |
23
|
|
|
|
|
|
|
>; |
24
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [@EXPORT_OK],); |
25
|
|
|
|
|
|
|
|
26
|
6
|
|
|
6
|
1
|
13940
|
sub collage ($input, @args) { |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
12
|
|
27
|
6
|
50
|
|
|
|
37
|
my %args = @args == 0 ? (auto => $input) : ($input, @args); |
28
|
|
|
|
|
|
|
return collage_from_resolver($args{resolver}) |
29
|
6
|
100
|
|
|
|
29
|
if defined $args{resolver}; |
30
|
5
|
50
|
|
|
|
21
|
return collage_from_dir($args{dir}) if defined $args{dir}; |
31
|
5
|
50
|
|
|
|
19
|
return collage_from_tar($args{tar}) if defined $args{tar}; |
32
|
|
|
|
|
|
|
return collage_from_definition($args{definition}) |
33
|
5
|
50
|
|
|
|
17
|
if defined $args{definition}; |
34
|
5
|
50
|
|
|
|
24
|
if (defined(my $auto = $args{auto})) { |
35
|
5
|
50
|
|
|
|
24
|
return collage_from_resolver($auto) if blessed($auto); |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
10
|
my $ar = ref($auto); |
38
|
5
|
50
|
33
|
|
|
42
|
if ($ar eq '' && $auto =~ m{\A [\[\{]}mxs) { |
39
|
0
|
|
|
|
|
0
|
$auto = decode_json($auto); |
40
|
0
|
|
|
|
|
0
|
$ar = ref($auto); |
41
|
|
|
|
|
|
|
} |
42
|
5
|
50
|
33
|
|
|
67
|
return collage_from_definition($auto) |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
43
|
|
|
|
|
|
|
if ($ar eq '' && $ar =~ m{\A \s* [\[\{] }mxs) |
44
|
|
|
|
|
|
|
|| ($ar eq 'HASH') |
45
|
|
|
|
|
|
|
|| ($ar eq 'ARRAY'); |
46
|
|
|
|
|
|
|
|
47
|
5
|
50
|
|
|
|
20
|
croak "cannot handle auto input of type $ar" if $ar ne ''; |
48
|
5
|
50
|
|
|
|
133
|
croak "cannot use provided automatic hint" unless -r $auto; |
49
|
|
|
|
|
|
|
|
50
|
5
|
100
|
|
|
|
115
|
return collage_from_dir($auto) if -d $auto; |
51
|
|
|
|
|
|
|
|
52
|
2
|
50
|
|
|
|
124
|
open my $fh, '<:raw', $auto or croak "open('$auto'): $OS_ERROR"; |
53
|
2
|
|
|
|
|
11
|
my $first = ''; |
54
|
2
|
|
|
|
|
116
|
my $n = read $fh, $first, 1; |
55
|
2
|
50
|
|
|
|
20
|
croak "sysread() on '$auto': $OS_ERROR" unless defined $n; |
56
|
2
|
|
|
|
|
50
|
close $fh; |
57
|
2
|
50
|
33
|
|
|
25
|
return collage_from_definition(file_to_data($auto)) |
58
|
|
|
|
|
|
|
if ($first eq '{') || ($first eq '{'); |
59
|
2
|
|
|
|
|
16
|
return collage_from_tar($auto); |
60
|
|
|
|
|
|
|
} ## end if (defined(my $auto =...)) |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
croak 'no useful input'; |
63
|
|
|
|
|
|
|
} ## end sub collage |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
0
|
sub collage_from_definition ($def) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
66
|
0
|
0
|
|
|
|
0
|
$def = decode_json($def) unless ref $def; |
67
|
0
|
0
|
|
|
|
0
|
$def = {commands => $def} if ref($def) eq 'ARRAY'; |
68
|
0
|
|
|
|
|
0
|
return PDF::Collage::Template->new($def->%*); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
3
|
|
|
3
|
1
|
9
|
sub collage_from_dir ($path) { |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
7
|
|
72
|
3
|
|
|
|
|
23
|
return collage_from_resolver( |
73
|
|
|
|
|
|
|
{class => 'Data::Resolver::FromDir', root => $path}); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
6
|
|
|
6
|
1
|
12
|
sub collage_from_resolver ($resolver) { |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
10
|
|
77
|
6
|
|
|
|
|
176
|
return PDF::Collage::TemplatesCollection->new(resolver => $resolver); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
2
|
1
|
6
|
sub collage_from_tar ($path) { |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
81
|
2
|
|
|
|
|
18
|
return collage_from_resolver( |
82
|
|
|
|
|
|
|
{class => 'Data::Resolver::FromTar', root => $path}); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |