File Coverage

blib/lib/Data/Sah/Coerce/perl/To_array/From_str/tsv_row.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 20 22 90.9


line stmt bran cond sub pod time code
1             package Data::Sah::Coerce::perl::To_array::From_str::tsv_row;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2021-04-08'; # DATE
5             our $DIST = 'Data-Sah-Coerce-perl-To_array-From_str-tsv_row'; # DIST
6             our $VERSION = '0.001'; # VERSION
7              
8 1     1   1964 use 5.010001;
  1         4  
9 1     1   6 use strict;
  1         2  
  1         21  
10 1     1   4 use warnings;
  1         3  
  1         164  
11              
12             sub meta {
13             +{
14 1     1 0 13 v => 4,
15             summary => 'Coerce a single TSV row to array of scalars',
16             prio => 50,
17             };
18             }
19              
20             sub coerce {
21 1     1 0 19 my %args = @_;
22              
23 1         3 my $dt = $args{data_term};
24              
25 1         2 my $res = {};
26              
27 1         3 $res->{expr_match} = "!ref($dt)";
28 1         3 $res->{expr_coerce} = join(
29             "",
30             "[split(/\t/, $dt)]",
31             );
32              
33 1         3 $res;
34             }
35              
36             1;
37             # ABSTRACT: Coerce a single TSV row to array of scalars
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             Data::Sah::Coerce::perl::To_array::From_str::tsv_row - Coerce a single TSV row to array of scalars
48              
49             =head1 VERSION
50              
51             This document describes version 0.001 of Data::Sah::Coerce::perl::To_array::From_str::tsv_row (from Perl distribution Data-Sah-Coerce-perl-To_array-From_str-tsv_row), released on 2021-04-08.
52              
53             =head1 SYNOPSIS
54              
55             To use in a Sah schema:
56              
57             ["array",{"x.perl.coerce_rules"=>["From_str::tsv_row"]}]
58              
59             =for Pod::Coverage ^(meta|coerce)$
60              
61             =head1 HOMEPAGE
62              
63             Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah-Coerce-perl-To_array-From_str-tsv_row>.
64              
65             =head1 SOURCE
66              
67             Source repository is at L<https://github.com/perlancar/perl-Data-Sah-Coerce-perl-To_array-From_str-tsv_row>.
68              
69             =head1 BUGS
70              
71             Please report any bugs or feature requests on the bugtracker website L<https://github.com/perlancar/perl-Data-Sah-Coerce-perl-To_array-From_str-tsv_row/issues>
72              
73             When submitting a bug or request, please include a test-file or a
74             patch to an existing test-file that illustrates the bug or desired
75             feature.
76              
77             =head1 SEE ALSO
78              
79             L<Data::Sah::Coerce::perl::To_array::From_str::csv_row>,
80             L<Data::Sah::Coerce::perl::To_array::From_str::comma_sep>
81              
82             L<Data::Sah::Coerce::perl::To_array::From_str::tsv>
83              
84             =head1 AUTHOR
85              
86             perlancar <perlancar@cpan.org>
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             This software is copyright (c) 2021 by perlancar@cpan.org.
91              
92             This is free software; you can redistribute it and/or modify it under
93             the same terms as the Perl 5 programming language system itself.
94              
95             =cut