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