File Coverage

blib/lib/Data/Sah/Coerce/perl/To_obj/From_str/perl_version.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              
2             use 5.010001;
3 1     1   5923 use strict;
  1         3  
4 1     1   4 use warnings;
  1         2  
  1         24  
5 1     1   4  
  1         2  
  1         164  
6             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7             our $DATE = '2021-12-01'; # DATE
8             our $DIST = 'Sah-Schemas-Perl'; # DIST
9             our $VERSION = '0.042'; # VERSION
10              
11             +{
12             v => 4,
13             summary => 'Coerce perl::version from str',
14 1     1 0 11 might_fail => 1,
15             prio => 50,
16             };
17             }
18              
19             my %args = @_;
20              
21             my $dt = $args{data_term};
22 1     1 0 12  
23             my $res = {};
24 1         2  
25             $res->{expr_match} = "!ref($dt)";
26 1         2 $res->{expr_coerce} = join(
27             "",
28 1         5 "do { my \$v; eval { \$v = version->parse($dt) }; if (\$@) { ['Invalid version format'] } else { [undef, \$v] } }",
29 1         3 );
30              
31             $res;
32             }
33              
34 1         2 1;
35             # ABSTRACT:
36              
37              
38             =pod
39              
40             =encoding UTF-8
41              
42             =head1 NAME
43              
44             Data::Sah::Coerce::perl::To_obj::From_str::perl_version
45              
46             =head1 VERSION
47              
48             This document describes version 0.042 of Data::Sah::Coerce::perl::To_obj::From_str::perl_version (from Perl distribution Sah-Schemas-Perl), released on 2021-12-01.
49              
50             =for Pod::Coverage ^(meta|coerce)$
51              
52             =head1 HOMEPAGE
53              
54             Please visit the project's homepage at L<https://metacpan.org/release/Sah-Schemas-Perl>.
55              
56             =head1 SOURCE
57              
58             Source repository is at L<https://github.com/perlancar/perl-Sah-Schemas-Perl>.
59              
60             =head1 AUTHOR
61              
62             perlancar <perlancar@cpan.org>
63              
64             =head1 CONTRIBUTING
65              
66              
67             To contribute, you can send patches by email/via RT, or send pull requests on
68             GitHub.
69              
70             Most of the time, you don't need to build the distribution yourself. You can
71             simply modify the code, then test via:
72              
73             % prove -l
74              
75             If you want to build the distribution (e.g. to try to install it locally on your
76             system), you can install L<Dist::Zilla>,
77             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
78             Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required
79             beyond that are considered a bug and can be reported to me.
80              
81             =head1 COPYRIGHT AND LICENSE
82              
83             This software is copyright (c) 2021, 2020, 2019, 2018, 2017, 2016 by perlancar <perlancar@cpan.org>.
84              
85             This is free software; you can redistribute it and/or modify it under
86             the same terms as the Perl 5 programming language system itself.
87              
88             =head1 BUGS
89              
90             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Perl>
91              
92             When submitting a bug or request, please include a test-file or a
93             patch to an existing test-file that illustrates the bug or desired
94             feature.
95              
96             =cut