| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Unixish::indent; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
498
|
use 5.010; |
|
|
1
|
|
|
|
|
7
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
5
|
1
|
|
|
1
|
|
408
|
use syntax 'each_on_array'; # to support perl < 5.12 |
|
|
1
|
|
|
|
|
23795
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
1
|
|
|
1
|
|
3503
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
7
|
|
|
|
|
|
|
#use Log::Any '$log'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
434
|
use Data::Unixish::Util qw(%common_args); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
411
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.571'; # VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %SPEC; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$SPEC{indent} = { |
|
16
|
|
|
|
|
|
|
v => 1.1, |
|
17
|
|
|
|
|
|
|
summary => 'Add spaces or tabs to the beginnning of each line of text', |
|
18
|
|
|
|
|
|
|
args => { |
|
19
|
|
|
|
|
|
|
%common_args, |
|
20
|
|
|
|
|
|
|
num => { |
|
21
|
|
|
|
|
|
|
summary => 'Number of spaces to add', |
|
22
|
|
|
|
|
|
|
schema => ['int*', default=>4], |
|
23
|
|
|
|
|
|
|
cmdline_aliases => { |
|
24
|
|
|
|
|
|
|
n => {}, |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
}, |
|
27
|
|
|
|
|
|
|
tab => { |
|
28
|
|
|
|
|
|
|
summary => 'Number of spaces to add', |
|
29
|
|
|
|
|
|
|
schema => ['bool' => default => 0], |
|
30
|
|
|
|
|
|
|
cmdline_aliases => { |
|
31
|
|
|
|
|
|
|
t => {}, |
|
32
|
|
|
|
|
|
|
}, |
|
33
|
|
|
|
|
|
|
}, |
|
34
|
|
|
|
|
|
|
}, |
|
35
|
|
|
|
|
|
|
tags => [qw/text itemfunc/], |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
sub indent { |
|
38
|
3
|
|
|
3
|
1
|
9
|
my %args = @_; |
|
39
|
3
|
|
|
|
|
7
|
my ($in, $out) = ($args{in}, $args{out}); |
|
40
|
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
7
|
_indent_begin(\%args); |
|
42
|
3
|
|
|
|
|
13
|
while (my ($index, $item) = each @$in) { |
|
43
|
12
|
|
|
|
|
23
|
push @$out, _indent_item($item, \%args); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
11
|
[200, "OK"]; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _indent_begin { |
|
50
|
6
|
|
|
6
|
|
10
|
my $args = shift; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# args abused to store state |
|
53
|
6
|
100
|
100
|
|
|
37
|
$args->{_indent} = ($args->{tab} ? "\t" : " ") x ($args->{num} // 4); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _indent_item { |
|
57
|
24
|
|
|
24
|
|
43
|
my ($item, $args) = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
24
|
100
|
66
|
|
|
88
|
if (defined($item) && !ref($item)) { |
|
60
|
18
|
|
|
|
|
88
|
$item =~ s/^/$args->{_indent}/mg; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
24
|
|
|
|
|
86
|
return $item; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
# ABSTRACT: Add spaces or tabs to the beginnning of each line of text |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |