File Coverage

blib/lib/Data/Sah/Coerce/perl/To_array/From_str/comma_sep.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::comma_sep;
2              
3             # AUTHOR
4             our $DATE = '2019-11-28'; # DATE
5             our $DIST = 'Data-Sah-CoerceBundle-To_array-From_str-comma_sep'; # DIST
6             our $VERSION = '0.011'; # VERSION
7              
8 1     1   1690 use 5.010001;
  1         3  
9 1     1   5 use strict;
  1         1  
  1         18  
10 1     1   4 use warnings;
  1         1  
  1         118  
11              
12             sub meta {
13             +{
14 1     1 0 12 v => 4,
15             summary => 'Coerce array from a comma-separated items in a string',
16             prio => 60, # a bit lower than normal
17             };
18             }
19              
20             sub coerce {
21 1     1 0 14 my %args = @_;
22              
23 1         2 my $dt = $args{data_term};
24              
25 1         1 my $res = {};
26              
27 1         3 $res->{expr_match} = "!ref($dt)";
28              
29 1         3 $res->{expr_coerce} = "[split /\\s*,\\s*/, $dt]";
30              
31 1         3 $res;
32             }
33              
34             1;
35             # ABSTRACT: Coerce array from a comma-separated items in a string
36              
37             __END__
38              
39             =pod
40              
41             =encoding UTF-8
42              
43             =head1 NAME
44              
45             Data::Sah::Coerce::perl::To_array::From_str::comma_sep - Coerce array from a comma-separated items in a string
46              
47             =head1 VERSION
48              
49             This document describes version 0.011 of Data::Sah::Coerce::perl::To_array::From_str::comma_sep (from Perl distribution Data-Sah-CoerceBundle-To_array-From_str-comma_sep), released on 2019-11-28.
50              
51             =head1 SYNOPSIS
52              
53             To use in a Sah schema:
54              
55             ["array",{"x.perl.coerce_rules"=>["From_str::comma_sep"]}]
56              
57             =for Pod::Coverage ^(meta|coerce)$
58              
59             =head1 HOMEPAGE
60              
61             Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah-CoerceBundle-To_array-From_str-comma_sep>.
62              
63             =head1 SOURCE
64              
65             Source repository is at L<https://github.com/perlancar/perl-Data-Sah-CoerceBundle-To_array-From_str-comma_sep>.
66              
67             =head1 BUGS
68              
69             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah-CoerceBundle-To_array-From_str-comma_sep>
70              
71             When submitting a bug or request, please include a test-file or a
72             patch to an existing test-file that illustrates the bug or desired
73             feature.
74              
75             =head1 AUTHOR
76              
77             perlancar <perlancar@cpan.org>
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             This software is copyright (c) 2019, 2018, 2016 by perlancar@cpan.org.
82              
83             This is free software; you can redistribute it and/or modify it under
84             the same terms as the Perl 5 programming language system itself.
85              
86             =cut