File Coverage

blib/lib/Data/Unixish/join.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 4 100.0
condition 4 4 100.0
subroutine 7 7 100.0
pod 1 1 100.0
total 37 37 100.0


line stmt bran cond sub pod time code
1             package Data::Unixish::join;
2              
3             our $DATE = '2019-10-26'; # DATE
4             our $DIST = 'Data-Unixish'; # DIST
5             our $VERSION = '1.571'; # VERSION
6              
7 1     1   560 use 5.010001;
  1         6  
8 1     1   5 use strict;
  1         2  
  1         24  
9 1     1   441 use syntax 'each_on_array'; # to support perl < 5.12
  1         25605  
  1         5  
10 1     1   3773 use warnings;
  1         3  
  1         33  
11             #use Log::Any '$log';
12              
13 1     1   485 use Data::Unixish::Util qw(%common_args);
  1         3  
  1         305  
14              
15             our %SPEC;
16              
17             $SPEC{join} = {
18             v => 1.1,
19             summary => 'Join elements of array into string',
20             description => <<'_',
21              
22             _
23             args => {
24             %common_args,
25             string => {
26             summary => 'String to join elements with',
27             schema => 'str*',
28             default => '',
29             pos => 0,
30             },
31             },
32             tags => [qw/text datatype-in:array itemfunc/],
33             };
34             sub join {
35 2     2 1 10 my %args = @_;
36 2         4 my ($in, $out) = ($args{in}, $args{out});
37              
38 2         10 while (my ($index, $item) = each @$in) {
39 6 100 100     40 push @$out, ref $item eq 'ARRAY' ? CORE::join($args{string}//'', @$item) : $item;
40             }
41              
42 2         8 [200, "OK"];
43             }
44              
45             sub _join_item {
46 6     6   14 my ($item, $args) = @_;
47              
48 6 100 100     33 ref $item eq 'ARRAY' ? CORE::join($args->{string}//'', @$item) : $item;
49             }
50              
51             1;
52             # ABSTRACT: Join elements of array into string
53              
54             __END__