| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::DocClaims::Line; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright (c) Scott E. Lee |
|
4
|
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
104200
|
use 5.008009; |
|
|
13
|
|
|
|
|
37
|
|
|
6
|
13
|
|
|
13
|
|
47
|
use strict; |
|
|
13
|
|
|
|
|
18
|
|
|
|
13
|
|
|
|
|
214
|
|
|
7
|
13
|
|
|
13
|
|
60
|
use warnings; |
|
|
13
|
|
|
|
|
24
|
|
|
|
13
|
|
|
|
|
592
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Keys in the blessed hash |
|
10
|
|
|
|
|
|
|
# {text} text of the line |
|
11
|
|
|
|
|
|
|
# {path} path of the file |
|
12
|
|
|
|
|
|
|
# {lnum} line number of the line |
|
13
|
|
|
|
|
|
|
# {...} other attributes |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use overload |
|
16
|
|
|
|
|
|
|
'""' => 'text', |
|
17
|
7638
|
|
|
7638
|
|
10506
|
'bool' => sub { 1 }, |
|
18
|
13
|
|
|
13
|
|
11142
|
; |
|
|
13
|
|
|
|
|
9416
|
|
|
|
13
|
|
|
|
|
86
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Test::DocClaims::Line - Represent one line from a text file |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Test::DocClaims::Line; |
|
27
|
|
|
|
|
|
|
my %hash = ( text => 'package Foo;', lnum => 1 ); |
|
28
|
|
|
|
|
|
|
$hash{file} = { path => 'foo/bar.pm', has_pod => 1 }; |
|
29
|
|
|
|
|
|
|
$line = Test::DocClaims::Line->new(%hash); |
|
30
|
|
|
|
|
|
|
say $line->lnum(); # 1 |
|
31
|
|
|
|
|
|
|
say $line->path(); # foo/bar.pm |
|
32
|
|
|
|
|
|
|
say $line->text(); # package Foo; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This object represents a single line from a source file, documentation file |
|
37
|
|
|
|
|
|
|
or test suite file. |
|
38
|
|
|
|
|
|
|
It knows what file it came from and the line number in that file. |
|
39
|
|
|
|
|
|
|
It also records other attributes. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new I |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This method creates a new object from the I. |
|
46
|
|
|
|
|
|
|
The I must have as a minimum the following keys: |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
file hash of information about the file containing this line |
|
49
|
|
|
|
|
|
|
text the text of the line |
|
50
|
|
|
|
|
|
|
lnum the line number in the file |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
The hash in the "file" key must have as a minimum the following keys: |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
path path of the file |
|
55
|
|
|
|
|
|
|
has_pod true if this file supports POD (*.pm vs. *.md) |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
If the above minimum keys are not present the method will die. |
|
58
|
|
|
|
|
|
|
Additional keys may be present in either hash. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
|
63
|
5491
|
|
|
5491
|
1
|
10185
|
my $class = shift; |
|
64
|
5491
|
|
|
|
|
17622
|
my %attr = @_; |
|
65
|
5491
|
|
33
|
|
|
13673
|
my $self = bless \%attr, ref($class) || $class; |
|
66
|
5491
|
|
|
|
|
7659
|
foreach my $k (qw< file text lnum >) { |
|
67
|
|
|
|
|
|
|
die "missing $k key in " . __PACKAGE__ . "->new" |
|
68
|
16467
|
100
|
|
|
|
24229
|
unless exists $self->{$k}; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
die "'file' key in " . __PACKAGE__ . "->new is not hash" |
|
71
|
5485
|
50
|
33
|
|
|
13054
|
unless exists $self->{file} && ref $self->{file} eq "HASH"; |
|
72
|
5485
|
|
|
|
|
6443
|
foreach my $k (qw< path has_pod >) { |
|
73
|
|
|
|
|
|
|
die "missing $k key in " . __PACKAGE__ . "->new file hash" |
|
74
|
10969
|
100
|
|
|
|
16114
|
unless exists $self->{file}{$k}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
5483
|
|
|
|
|
16053
|
return $self; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 ACCESSORS |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The following accessors simply return a value from the constructor. |
|
82
|
|
|
|
|
|
|
The meaning of all such values is determined by the caller of the |
|
83
|
|
|
|
|
|
|
constructor. |
|
84
|
|
|
|
|
|
|
No logic is present to calculate or validate these values. |
|
85
|
|
|
|
|
|
|
If the requested value was not passed to the constructor then the returned |
|
86
|
|
|
|
|
|
|
value will be undef. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 path |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Return the path of the file. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 has_pod |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Return true if the file supports POD, false otherwise. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 lnum |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Return the line number in the file that this line came from. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 text |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Return the text of the line. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 is_doc |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Return true if this line is a line of documentation (e.g., a POD line) or |
|
107
|
|
|
|
|
|
|
false if not (e.g., code). |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 code |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Return true if this line is from a DC_CODE section, false otherwise. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 todo |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Return true if this line is a "=for DC_TODO" command paragraph. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
|
|
119
|
52
|
|
|
52
|
1
|
906
|
sub path { $_[0]->{file}{path} } |
|
120
|
24
|
|
|
24
|
1
|
7763
|
sub has_pod { $_[0]->{file}{has_pod} } |
|
121
|
|
|
|
|
|
|
|
|
122
|
10
|
|
|
10
|
1
|
29
|
sub lnum { $_[0]->{lnum} } |
|
123
|
3537
|
|
|
3537
|
1
|
8872
|
sub text { $_[0]->{text} } |
|
124
|
5273
|
|
|
5273
|
1
|
10819
|
sub is_doc { $_[0]->{is_doc} } |
|
125
|
718
|
|
|
718
|
1
|
1334
|
sub code { $_[0]->{code} } |
|
126
|
2007
|
|
|
2007
|
1
|
3215
|
sub todo { $_[0]->{todo} } |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Copyright (c) Scott E. Lee |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
|
135
|
|
|
|
|
|
|
|