| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 tw=78 et si: |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
package App::Checklist::Formatter; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
72707
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
33
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
498
|
use version; our $VERSION = qv('v0.0.7'); |
|
|
1
|
|
|
|
|
2032
|
|
|
|
1
|
|
|
|
|
6
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
864
|
use Class::Std; |
|
|
1
|
|
|
|
|
14479
|
|
|
|
1
|
|
|
|
|
5
|
|
|
11
|
|
|
|
|
|
|
{ |
|
12
|
|
|
|
|
|
|
my %author : ATTR; |
|
13
|
|
|
|
|
|
|
my %title : ATTR; |
|
14
|
|
|
|
|
|
|
my %checklist : ATTR; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub BUILD { |
|
17
|
1
|
|
|
1
|
0
|
656
|
my ($self,$ident,$args_ref) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
5
|
$checklist{$ident} = []; |
|
20
|
|
|
|
|
|
|
} # BUILD() |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub read_vim_outliner { |
|
23
|
1
|
|
|
1
|
1
|
50
|
my ($self,$filename) = @_; |
|
24
|
1
|
|
|
|
|
3
|
my $OTL; |
|
25
|
|
|
|
|
|
|
my $vo = { |
|
26
|
1
|
|
|
|
|
8
|
curr_list => $checklist{ident $self}, |
|
27
|
|
|
|
|
|
|
lastindent => 0, |
|
28
|
|
|
|
|
|
|
last_items => [], |
|
29
|
|
|
|
|
|
|
last_lists => [], |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
50
|
|
|
|
46
|
if (open $OTL, '<', $filename) { |
|
33
|
|
|
|
|
|
|
# read in vim outliner |
|
34
|
1
|
|
|
|
|
27
|
while (<$OTL>) { |
|
35
|
9
|
100
|
|
|
|
34
|
next if /^\s*$/; |
|
36
|
8
|
100
|
|
|
|
41
|
if (/^(\s*):(.*)$/) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
8
|
$self->_vo_item_colon($vo,$1,$2); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
elsif (/^(\s*);(.*)$/) { |
|
40
|
2
|
|
|
|
|
8
|
$self->_vo_item_semicolon($vo,$1,$2); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
elsif (/^(\s*)\[([x_])\]\s(.+)$/i) { |
|
43
|
3
|
|
|
|
|
18
|
$self->_vo_item($vo,$1,$2,$3); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
else { |
|
46
|
0
|
|
|
|
|
0
|
croak("can't process line $.: $_"); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
1
|
|
|
|
|
40
|
close $OTL; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
else { |
|
52
|
0
|
|
|
|
|
0
|
die "can't open '$filename' for reading: $!"; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
1
|
|
|
|
|
3
|
return scalar @{$checklist{ident $self}}; |
|
|
1
|
|
|
|
|
13
|
|
|
55
|
|
|
|
|
|
|
} # read_vim_outliner() |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _vo_down { |
|
58
|
0
|
|
|
0
|
|
0
|
my ($self,$vo,$indent,$check,$text) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
push @{$vo->{last_lists}}, $vo->{curr_list}; |
|
|
0
|
|
|
|
|
0
|
|
|
61
|
0
|
|
|
|
|
0
|
$vo->{curr_list} = $vo->{curr_item}->{sublist} = []; |
|
62
|
0
|
|
|
|
|
0
|
$vo->{lastindent} = length $indent; |
|
63
|
0
|
|
|
|
|
0
|
$self->next_item($vo,$check,$text); |
|
64
|
|
|
|
|
|
|
} # _vo_down() |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _vo_item { |
|
67
|
3
|
|
|
3
|
|
17
|
my ($self,$vo,$indent,$check,$text) = @_; |
|
68
|
|
|
|
|
|
|
|
|
69
|
3
|
50
|
|
|
|
13
|
if (length($indent) > $vo->{lastindent}) { |
|
|
|
50
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
$self->_vo_down($vo,$indent,$check,$text); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
elsif (length($indent) == $vo->{lastindent}) { |
|
73
|
3
|
|
|
|
|
9
|
$self->_vo_next_item($vo,$check,$text); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
else { |
|
76
|
0
|
|
|
|
|
0
|
$self->_vo_up($vo,$indent,$check,$text); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} # _vo_item() |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _vo_item_colon { |
|
81
|
3
|
|
|
3
|
|
12
|
my ($self,$vo,$indent,$text) = @_; |
|
82
|
3
|
|
|
|
|
5
|
push @{$vo->{last_items} ->[length($indent)-1]->{comment}}, $text; |
|
|
3
|
|
|
|
|
24
|
|
|
83
|
|
|
|
|
|
|
} # _vo_item_colon() |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _vo_item_semicolon { |
|
86
|
2
|
|
|
2
|
|
11
|
my ($self,$vo,$indent,$text) = @_; |
|
87
|
|
|
|
|
|
|
|
|
88
|
2
|
100
|
|
|
|
10
|
if ($text =~ /^\s*author: (.+)/) { |
|
89
|
1
|
|
|
|
|
6
|
$author{ident $self} = $1; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
2
|
100
|
|
|
|
11
|
if ($text =~ /^\s*checklist: (.+)/) { |
|
92
|
1
|
|
|
|
|
11
|
$title{ident $self} = $1; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} # _vo_item_semicolon() |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _vo_next_item { |
|
97
|
3
|
|
|
3
|
|
7
|
my ($self,$vo,$check,$text) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
3
|
|
|
|
|
12
|
$vo->{curr_item} = { text => $text, check => $check, comment => [], }; |
|
100
|
3
|
|
|
|
|
6
|
push @{$vo->{curr_list}}, $vo->{curr_item}; |
|
|
3
|
|
|
|
|
8
|
|
|
101
|
3
|
|
|
|
|
12
|
$vo->{last_items}->[$vo->{lastindent}] = $vo->{curr_item}; |
|
102
|
|
|
|
|
|
|
} # _vo_next_item() |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _vo_up { |
|
105
|
0
|
|
|
0
|
|
|
my ($self,$vo,$indent,$check,$text) = @_; |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$vo->{lastindent} = length $indent; |
|
108
|
0
|
|
|
|
|
|
$vo->{curr_list} = pop @{$vo->{last_lists}}; |
|
|
0
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$#{$vo->{last_items}} = $vo->{lastindent}; |
|
|
0
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$self->next_item($vo,$check,$text); |
|
111
|
|
|
|
|
|
|
} # _vo_up() |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} # package App::Checklist::Formatter |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
116
|
|
|
|
|
|
|
__END__ |