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