File Coverage

blib/lib/Data/Sah/Filter/perl/Str/oneline.pm
Criterion Covered Total %
statement 8 14 57.1
branch n/a
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 11 21 52.3


line stmt bran cond sub pod time code
1             package Data::Sah::Filter::perl::Str::oneline;
2              
3 1     1   530097 use 5.010001;
  1         3  
4 1     1   4 use strict;
  1         2  
  1         20  
5 1     1   3 use warnings;
  1         5  
  1         196  
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 => 'Replace newlines with spaces',
16             examples => [
17             {value=>"a"},
18             {value=>"a\nb", filtered_value=>"a b"},
19             {value=>"a\n\n\nb\n", filtered_value=>"a b "},
20             ],
21             };
22             }
23              
24             sub filter {
25 0     0 0   my %fargs = @_;
26              
27 0           my $dt = $fargs{data_term};
28 0           my $res = {};
29 0           $res->{expr_filter} = join(
30             "",
31             "do { my \$res = $dt; \$res =~ s/\\R/ /g; \$res }",
32             );
33              
34 0           $res;
35             }
36              
37             1;
38             # ABSTRACT: Replace newlines with spaces
39              
40             __END__