line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic (ProhibitUnusedPrivateSubroutines) |
2
|
|
|
|
|
|
|
package Text::Template::Simple::Base::Examine; |
3
|
62
|
|
|
62
|
|
757
|
use strict; |
|
62
|
|
|
|
|
144
|
|
|
62
|
|
|
|
|
3045
|
|
4
|
62
|
|
|
62
|
|
374
|
use warnings; |
|
62
|
|
|
|
|
134
|
|
|
62
|
|
|
|
|
2784
|
|
5
|
|
|
|
|
|
|
|
6
|
62
|
|
|
62
|
|
371
|
use Text::Template::Simple::Util qw(:all); |
|
62
|
|
|
|
|
128
|
|
|
62
|
|
|
|
|
28573
|
|
7
|
62
|
|
|
62
|
|
442
|
use Text::Template::Simple::Constants qw(:all); |
|
62
|
|
|
|
|
155
|
|
|
62
|
|
|
|
|
109314
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.86'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _examine { |
12
|
772
|
|
|
772
|
|
1301
|
my $self = shift; |
13
|
772
|
|
|
|
|
1474
|
my $TMP = shift; |
14
|
772
|
|
|
|
|
3422
|
my($type, $thing) = $self->_examine_type( $TMP ); |
15
|
772
|
|
|
|
|
25620
|
my $rv; |
16
|
|
|
|
|
|
|
|
17
|
772
|
50
|
|
|
|
4610
|
if ( $type eq 'ERROR' ) { |
|
|
50
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
$rv = $thing; |
19
|
0
|
|
|
|
|
0
|
$self->[TYPE] = $type; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif ( $type eq 'GLOB' ) { |
22
|
0
|
|
|
|
|
0
|
$rv = $self->_examine_glob( $thing ); |
23
|
0
|
|
|
|
|
0
|
$self->[TYPE] = $type; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
772
|
100
|
|
|
|
3397
|
if ( my $path = $self->io->file_exists( $thing ) ) { |
27
|
566
|
|
|
|
|
1908
|
$rv = $self->io->slurp( $path ); |
28
|
566
|
|
|
|
|
1918
|
$self->[TYPE] = 'FILE'; |
29
|
566
|
|
|
|
|
1304
|
$self->[TYPE_FILE] = $path; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
|
|
|
|
|
|
# just die if file is absent, but user forced the type as FILE |
33
|
206
|
100
|
|
|
|
780
|
$self->io->slurp( $thing ) if $type eq 'FILE'; |
34
|
202
|
|
|
|
|
3897
|
$rv = $thing; |
35
|
202
|
|
|
|
|
3934
|
$self->[TYPE] = 'STRING'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
768
|
50
|
|
|
|
3271
|
LOG( EXAMINE => sprintf q{%s; LENGTH: %s}, $self->[TYPE], length $rv ) if DEBUG; |
40
|
768
|
|
|
|
|
3141
|
return $rv; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _examine_glob { |
44
|
0
|
|
|
0
|
|
0
|
my($self, $thing) = @_; |
45
|
0
|
|
|
|
|
0
|
my $type = ref $thing; |
46
|
0
|
0
|
|
|
|
0
|
fatal( 'tts.base.examine.notglob' => $type ) if $type ne 'GLOB'; |
47
|
0
|
0
|
|
|
|
0
|
fatal( 'tts.base.examine.notfh' ) if ! fileno $thing; |
48
|
0
|
|
|
|
|
0
|
return $self->io->slurp( $thing ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _examine_type { |
52
|
772
|
|
|
772
|
|
1337
|
my $self = shift; |
53
|
772
|
|
|
|
|
1543
|
my $TMP = shift; |
54
|
772
|
|
|
|
|
1386
|
my $ref = ref $TMP; |
55
|
|
|
|
|
|
|
|
56
|
772
|
100
|
|
|
|
4160
|
return EMPTY_STRING , $TMP if ! $ref; |
57
|
4
|
50
|
|
|
|
13
|
return GLOB => $TMP if $ref eq 'GLOB'; |
58
|
|
|
|
|
|
|
|
59
|
4
|
50
|
|
|
|
15
|
if ( isaref( $TMP ) ) { |
60
|
4
|
|
33
|
|
|
7
|
my $ftype = shift @{ $TMP } || fatal('tts.base.examine._examine_type.ftype'); |
61
|
4
|
|
33
|
|
|
10
|
my $fthing = shift @{ $TMP } || fatal('tts.base.examine._examine_type.fthing'); |
62
|
4
|
50
|
|
|
|
7
|
fatal('tts.base.examine._examine_type.extra') if @{ $TMP }; |
|
4
|
|
|
|
|
15
|
|
63
|
4
|
|
|
|
|
16
|
return uc $ftype, $fthing; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return fatal('tts.base.examine._examine_type.unknown', $ref); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Text::Template::Simple::Base::Examine - Base class for Text::Template::Simple |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Private module. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This document describes version C<0.86> of C<Text::Template::Simple::Base::Examine> |
84
|
|
|
|
|
|
|
released on C<5 March 2012>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Private module. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Burak Gursoy <burak@cpan.org>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Copyright 2004 - 2012 Burak Gursoy. All rights reserved. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 LICENSE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
99
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.12.3 or, |
100
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |