File Coverage

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