| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Indent; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
90564
|
use strict; |
|
|
7
|
|
|
|
|
62
|
|
|
|
7
|
|
|
|
|
234
|
|
|
4
|
7
|
|
|
7
|
|
50
|
use warnings; |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
235
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
3642
|
use Class::Utils qw(set_params); |
|
|
7
|
|
|
|
|
215684
|
|
|
|
7
|
|
|
|
|
150
|
|
|
7
|
7
|
|
|
7
|
|
529
|
use Error::Pure qw(err); |
|
|
7
|
|
|
|
|
17
|
|
|
|
7
|
|
|
|
|
263
|
|
|
8
|
7
|
|
|
7
|
|
49
|
use Readonly; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
3205
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Constants. |
|
11
|
|
|
|
|
|
|
Readonly::Scalar my $EMPTY_STR => q{}; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.08; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constructor. |
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
16
|
|
|
16
|
1
|
15336
|
my ($class, @params) = @_; |
|
18
|
16
|
|
|
|
|
41
|
my $self = bless {}, $class; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Default indent. |
|
21
|
16
|
|
|
|
|
67
|
$self->{'indent'} = $EMPTY_STR; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Every next indent string. |
|
24
|
16
|
|
|
|
|
32
|
$self->{'next_indent'} = "\t"; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Process params. |
|
27
|
16
|
|
|
|
|
68
|
set_params($self, @params); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Check to 'next_indent' parameter. |
|
30
|
14
|
100
|
|
|
|
161
|
if (! defined $self->{'next_indent'}) { |
|
31
|
1
|
|
|
|
|
6
|
err "'next_indent' parameter must be defined."; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
13
|
100
|
|
|
|
36
|
if (ref $self->{'next_indent'}) { |
|
34
|
2
|
|
|
|
|
8
|
err "'next_indent' parameter must be a string."; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Check to 'indent' parameter. |
|
38
|
11
|
100
|
|
|
|
33
|
if (! defined $self->{'indent'}) { |
|
39
|
1
|
|
|
|
|
4
|
err "'indent' parameter must be defined."; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
10
|
100
|
|
|
|
30
|
if (ref $self->{'indent'}) { |
|
42
|
2
|
|
|
|
|
6
|
err "'indent' parameter must be a string."; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Object. |
|
46
|
8
|
|
|
|
|
32
|
return $self; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Add an indent to global indent. |
|
50
|
|
|
|
|
|
|
sub add { |
|
51
|
7
|
|
|
7
|
1
|
25
|
my ($self, $indent) = @_; |
|
52
|
7
|
100
|
|
|
|
48
|
if (! defined $indent) { |
|
53
|
2
|
|
|
|
|
6
|
$indent = $self->{'next_indent'}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
7
|
|
|
|
|
19
|
$self->{'indent'} .= $indent; |
|
56
|
7
|
|
|
|
|
24
|
return 1; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Get a indent value. |
|
60
|
|
|
|
|
|
|
sub get { |
|
61
|
13
|
|
|
13
|
1
|
1087
|
my $self = shift; |
|
62
|
13
|
|
|
|
|
69
|
return $self->{'indent'}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Remove an indent from global indent. |
|
66
|
|
|
|
|
|
|
sub remove { |
|
67
|
3
|
|
|
3
|
1
|
14
|
my ($self, $indent) = @_; |
|
68
|
3
|
100
|
|
|
|
7
|
if (! defined $indent) { |
|
69
|
1
|
|
|
|
|
2
|
$indent = $self->{'next_indent'}; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
3
|
|
|
|
|
5
|
my $indent_length = length $indent; |
|
72
|
3
|
100
|
|
|
|
12
|
if (substr($self->{'indent'}, -$indent_length) ne $indent) { |
|
73
|
1
|
|
|
|
|
8
|
err "Cannot remove indent '$indent'."; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
2
|
|
|
|
|
10
|
$self->{'indent'} = substr $self->{'indent'}, 0, -$indent_length; |
|
76
|
2
|
|
|
|
|
5
|
return 1; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Reseting indent. |
|
80
|
|
|
|
|
|
|
sub reset { |
|
81
|
2
|
|
|
2
|
1
|
11
|
my ($self, $reset_value) = @_; |
|
82
|
2
|
100
|
|
|
|
10
|
if (! defined $reset_value) { |
|
83
|
1
|
|
|
|
|
3
|
$reset_value = $EMPTY_STR; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
2
|
|
|
|
|
4
|
$self->{'indent'} = $reset_value; |
|
86
|
2
|
|
|
|
|
4
|
return 1; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |