File Coverage

blib/lib/Data/Unixish/lins.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::lins;
2              
3 1     1   511 use 5.010;
  1         7  
4 1     1   5 use strict;
  1         2  
  1         21  
5 1     1   413 use syntax 'each_on_array'; # to support perl < 5.12
  1         23849  
  1         4  
6 1     1   3502 use warnings;
  1         2  
  1         28  
7             #use Log::Any '$log';
8              
9 1     1   434 use Data::Unixish::Util qw(%common_args);
  1         2  
  1         313  
10              
11             our $VERSION = '1.571'; # VERSION
12              
13             our %SPEC;
14              
15             $SPEC{lins} = {
16             v => 1.1,
17             summary => 'Add some text at the beginning of each line of text',
18             description => <<'_',
19              
20             This is sort of a counterpart for ltrim, which removes whitespace at the
21             beginning (left) 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 lins {
36 1     1 1 5 my %args = @_;
37 1         2 my ($in, $out) = ($args{in}, $args{out});
38              
39 1         6 while (my ($index, $item) = each @$in) {
40 4         8 push @$out, _lins_item($item, \%args);
41             }
42              
43 1         4 [200, "OK"];
44             }
45              
46             sub _lins_item {
47 8     8   14 my ($item, $args) = @_;
48              
49 8 100 66     38 if (defined($item) && !ref($item)) {
50 6         34 $item =~ s/^/$args->{text}/mg;
51             }
52 8         29 return $item;
53             }
54              
55             1;
56             # ABSTRACT: Add some text at the beginning of each line of text
57              
58             __END__