line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::BDD::Cucumber::Model::Line; |
2
|
|
|
|
|
|
|
$Test::BDD::Cucumber::Model::Line::VERSION = '0.84'; |
3
|
18
|
|
|
18
|
|
139
|
use Moo; |
|
18
|
|
|
|
|
60
|
|
|
18
|
|
|
|
|
124
|
|
4
|
18
|
|
|
18
|
|
5670
|
use Types::Standard qw( Int InstanceOf Str ); |
|
18
|
|
|
|
|
77
|
|
|
18
|
|
|
|
|
131
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Test::BDD::Cucumber::Model::Line - Model to represent a line in a feature file |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
version 0.84 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Model to represent a line in a feature file |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 number |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The line number this line represents |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'number' => ( is => 'rw', isa => Int ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 document |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The L object this line belongs to. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'document' => ( is => 'rw', isa => InstanceOf['Test::BDD::Cucumber::Model::Document'] ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 raw_content |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The content of the line, unmodified |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'raw_content' => ( is => 'rw', isa => Str ); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 indent |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Returns the number of preceding spaces before content on a line |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub indent { |
53
|
27
|
|
|
27
|
1
|
58
|
my $self = shift; |
54
|
27
|
|
|
|
|
460
|
my ($indent) = $self->raw_content =~ m/^( +)/g; |
55
|
27
|
|
100
|
|
|
371
|
return length( $indent || '' ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 content |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns the line's content, with the indentation stripped |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
5490
|
|
|
5490
|
1
|
91809
|
sub content { return _strip( $_[0]->raw_content ) } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 content_remove_indentation |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Accepts an int of number of spaces, and returns the content with exactly that |
69
|
|
|
|
|
|
|
many preceding spaces removed. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub content_remove_indentation { |
74
|
72
|
|
|
72
|
1
|
166
|
my ( $self, $indent ) = @_; |
75
|
72
|
|
|
|
|
160
|
$indent = ' ' x $indent; |
76
|
72
|
|
|
|
|
1129
|
my $content = $self->raw_content; |
77
|
72
|
|
|
|
|
793
|
$content =~ s/^$indent//; |
78
|
72
|
|
|
|
|
241
|
return $content; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 debug_summary |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns a string with the filename and line number |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub debug_summary { |
88
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
89
|
0
|
|
|
|
|
0
|
my $filename = $self->filename; |
90
|
|
|
|
|
|
|
return |
91
|
0
|
|
|
|
|
0
|
"Input: $filename line " |
92
|
|
|
|
|
|
|
. $self->number . ": [" |
93
|
|
|
|
|
|
|
. $self->raw_content . "]"; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 filename |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns either the filename, or the string C<[String]> if the document was |
99
|
|
|
|
|
|
|
loaded from a string |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub filename { |
104
|
26
|
|
|
26
|
1
|
82
|
my $self = shift; |
105
|
26
|
50
|
|
|
|
446
|
$self->document->filename || '[String]'; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 is_blank |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 is_comment |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Return true if the line is either blank, or is a comment. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
853
|
|
|
853
|
1
|
1867
|
sub is_blank { return !( $_[0]->content =~ m/\S/ ) } |
117
|
1864
|
|
|
1864
|
1
|
7367
|
sub is_comment { return scalar $_[0]->content =~ m/^\s*#/ } |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _strip { |
120
|
5490
|
|
|
5490
|
|
32183
|
my $string = shift; |
121
|
5490
|
|
|
|
|
17280
|
$string =~ s/^\s+//; |
122
|
5490
|
|
|
|
|
16686
|
$string =~ s/\s+$//; |
123
|
5490
|
|
|
|
|
24319
|
return $string; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Peter Sergeant C |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 LICENSE |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Copyright 2019-2023, Erik Huelsmann |
133
|
|
|
|
|
|
|
Copyright 2011-2019, Peter Sergeant; Licensed under the same terms as Perl |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |