| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Sah::Filter::perl::Str::check_oneline; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
518603
|
use 5.010001; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
461
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
8
|
|
|
|
|
|
|
our $DATE = '2024-07-17'; # DATE |
|
9
|
|
|
|
|
|
|
our $DIST = 'Data-Sah-Filter'; # DIST |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.025'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub meta { |
|
13
|
|
|
|
|
|
|
+{ |
|
14
|
0
|
|
|
0
|
0
|
|
v => 1, |
|
15
|
|
|
|
|
|
|
summary => 'Check that string does not contain more than one line', |
|
16
|
|
|
|
|
|
|
description => <<'_', |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
You can also use the clause C to achieve the same: |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# a schema, using 'match' clause and regex to match string that does not contain a newline |
|
21
|
|
|
|
|
|
|
["str", {"match" => qr/\A(?!.*\R).*\z/}] |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# a schema, using reversed 'match' clause and regex to match newline |
|
24
|
|
|
|
|
|
|
["str", {"!match" => '\\R'}] |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
_ |
|
27
|
|
|
|
|
|
|
might_fail => 1, |
|
28
|
|
|
|
|
|
|
examples => [ |
|
29
|
|
|
|
|
|
|
{value=>'', valid=>1}, |
|
30
|
|
|
|
|
|
|
{value=>"foo", valid=>1}, |
|
31
|
|
|
|
|
|
|
{value=>("foo bar\tbaz" x 10), valid=>1, summary=>"Long line, spaces and tabs are okay as long as it does not contain newline"}, |
|
32
|
|
|
|
|
|
|
{value=>"foo\n", valid=>0, summary=>"Containing newline at the end counts as having more than oneline; use the Str::rtrim or Str::rtrim_newline if you want to remove trailing newline"}, |
|
33
|
|
|
|
|
|
|
{value=>"foo\nbar", valid=>0}, |
|
34
|
|
|
|
|
|
|
{value=>"\n", valid=>0}, |
|
35
|
|
|
|
|
|
|
], |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub filter { |
|
40
|
0
|
|
|
0
|
0
|
|
my %args = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $dt = $args{data_term}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $res = {}; |
|
45
|
0
|
|
|
|
|
|
$res->{expr_filter} = join( |
|
46
|
|
|
|
|
|
|
"", |
|
47
|
|
|
|
|
|
|
"do { my \$tmp = $dt; \$tmp !~ /\\R/ ? [undef,\$tmp] : [\"String contains newline\"] }", |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$res; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
|
54
|
|
|
|
|
|
|
# ABSTRACT: Check that string does not contain more than one line |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |