blib/lib/Types/PerlVersion.pm

filter: Statementstmt 100% 24 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 32 / 32 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package Types::PerlVersion;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Types::PerlVersion - L<Perl::Version> type constraint for L<Type::Tiny>
9  
10 =head1 VERSION
11  
12 Version 0.002
13  
14 =cut
15  
16 3 our $VERSION = '0.002';
17  
18 =head1 SYNOPSIS
19  
20 package MyApp::Thingie;
21  
22 use Moose;
23 use Types::PerlVersion qw/PerlVersion/;
24  
25 has version => (
26 is => 'ro',
27 isa => PerlVersion,
28 coerce => 1,
29 required => 1,
30 );
31  
32 =head1 DESCRIPTION
33  
34 L<Types::PerlVersion> is a type constraint suitable for use with
35 L<Moo>/L<Moose> attributes that need to deal with version strings as
36 handled by L<Perl::Version>.
37  
38 =head2 Types
39  
40 This module provides the single type constraint C<PerlVersion>. Coercion is
41 provided from C<Str> and C<Num> types.
42  
43 =cut
44  
45 3 ▶use Type::Library -base, -declare => qw( PerlVersion );
Subroutine BEGIN: called CC=1 SCAR=0.0
46 3 ▶use Type::Utils -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 3 ▶use Types::Standard qw/Num Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 3 ▶use Perl::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 3 class_type PerlVersion, { class => "Perl::Version" };
51  
52 coerce PerlVersion,
53 1 ▶ from Num, via { "Perl::Version"->new($_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
54 4 ▶ from Str, via { "Perl::Version"->new($_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
55  
56 =head1 AUTHOR
57  
58 Peter Mottram (SysPete), C<< <peter at sysnix.com> >>
59  
60 =head1 BUGS
61  
62 Please report any bugs found to:
63  
64 L<https://github.com/SysPete/p5-Types-PerlVersion/issues>
65  
66 =head1 SUPPORT
67  
68 You can find documentation for this module with the perldoc command.
69  
70 perldoc Types::PerlVersion
71  
72 You can also look for information at:
73  
74 =over 4
75  
76 =item * L<GitHub repository|https://github.com/SysPete/p5-Types-PerlVersion>
77  
78 =item * L<meta::cpan|https://metacpan.org/pod/Types::PerlVersion>
79  
80 =back
81  
82 =head1 SEE ALSO
83  
84 If you prefer to use L<MooseX::Types> then see L<MooseX::Types::PerlVersion>
85 which was the basis of this module.
86  
87 =head1 ACKNOWLEDGEMENTS
88  
89 Toby Inkster for his excellent L<Type::Tiny>, brian d foy for L<Perl::Version>
90 and Roman F. for L<MooseX::Types::PerlVersion> from which I stole most of the
91 code for this module.
92  
93 =head1 LICENSE AND COPYRIGHT
94  
95 Copyright 2015 Peter Mottram (SysPete).
96  
97 This program is free software; you can redistribute it and/or modify
98 it under the same terms as the Perl 5 programming language system itself.
99  
100 =cut
101  
102 3 1; # End of Types::PerlVersion
↑ Summary