File Coverage

blib/lib/Data/Unixish/rins.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 7 7 100.0
pod 1 1 100.0
total 35 36 97.2


line stmt bran cond sub pod time code
1             package Data::Unixish::rins;
2              
3 1     1   407 use 5.010;
  1         5  
4 1     1   5 use strict;
  1         1  
  1         19  
5 1     1   364 use syntax 'each_on_array'; # to support perl < 5.12
  1         19894  
  1         5  
6 1     1   2920 use warnings;
  1         3  
  1         22  
7             #use Log::Any '$log';
8              
9 1     1   379 use Data::Unixish::Util qw(%common_args);
  1         2  
  1         268  
10              
11             our $VERSION = '1.572'; # VERSION
12              
13             our %SPEC;
14              
15             $SPEC{rins} = {
16             v => 1.1,
17             summary => 'Add some text at the end of each line of text',
18             description => <<'_',
19              
20             This is sort of a counterpart for rtrim, which removes whitespace at the end
21             (right) of each line of text.
22              
23             _
24             args => {
25             %common_args,
26             text => {
27             summary => 'The text to add',
28             schema => ['str*'],
29             req => 1,
30             pos => 0,
31             },
32             },
33             tags => [qw/text itemfunc/],
34             };
35             sub rins {
36 1     1 1 3 my %args = @_;
37 1         2 my ($in, $out) = ($args{in}, $args{out});
38              
39 1         17 while (my ($index, $item) = each @$in) {
40 4         8 push @$out, _rins_item($item, \%args);
41             }
42              
43 1         5 [200, "OK"];
44             }
45              
46             sub _rins_item {
47 8     8   14 my ($item, $args) = @_;
48 8 100 66     23 if (defined($item) && !ref($item)) {
49 6         33 $item =~ s/$/$args->{text}/mg;
50             }
51 8         22 return $item;
52             }
53              
54             1;
55             # ABSTRACT: Add some text at the end of each line of text
56              
57             __END__