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   5859 use strict;
  1         3  
4 1     1   5 use warnings;
  1         2  
  1         16  
5 1     1   5  
  1         1  
  1         173  
6             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7             our $DATE = '2022-09-11'; # DATE
8             our $DIST = 'Sah-Schemas-Perl'; # DIST
9             our $VERSION = '0.045'; # 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 13  
23             my $res = {};
24 1         2  
25             $res->{expr_match} = "!ref($dt)";
26 1         2 $res->{expr_coerce} = join(
27             "",
28 1         2 "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         3 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.045 of Data::Sah::Coerce::perl::To_obj::From_str::perl_version (from Perl distribution Sah-Schemas-Perl), released on 2022-09-11.
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>,
78             L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
79             Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
80             that are considered a bug and can be reported to me.
81              
82             =head1 COPYRIGHT AND LICENSE
83              
84             This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016 by perlancar <perlancar@cpan.org>.
85              
86             This is free software; you can redistribute it and/or modify it under
87             the same terms as the Perl 5 programming language system itself.
88              
89             =head1 BUGS
90              
91             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Perl>
92              
93             When submitting a bug or request, please include a test-file or a
94             patch to an existing test-file that illustrates the bug or desired
95             feature.
96              
97             =cut