line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Types::Dist; |
2
|
|
|
|
|
|
|
$Types::Dist::VERSION = '0.09'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Types related to distributions (e.g. distributions on CPAN) |
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
151526
|
use v5.10; |
|
10
|
|
|
|
|
49
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
56
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
279
|
|
8
|
10
|
|
|
10
|
|
64
|
use warnings; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
480
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Type::Library |
11
|
10
|
|
|
|
|
148
|
-base, |
12
|
10
|
|
|
10
|
|
2124
|
-declare => qw( DistName DistVersion DistFQ CPANfile ); |
|
10
|
|
|
|
|
139540
|
|
13
|
|
|
|
|
|
|
|
14
|
10
|
|
|
10
|
|
14088
|
use Type::Utils -all; |
|
10
|
|
|
|
|
37794
|
|
|
10
|
|
|
|
|
119
|
|
15
|
10
|
|
|
10
|
|
26820
|
use Types::Standard -types; |
|
10
|
|
|
|
|
269687
|
|
|
10
|
|
|
|
|
113
|
|
16
|
|
|
|
|
|
|
|
17
|
10
|
|
|
10
|
|
56729
|
use Module::CPANfile; |
|
10
|
|
|
|
|
137874
|
|
|
10
|
|
|
|
|
2680
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $distname_re = qr{ |
20
|
|
|
|
|
|
|
(?:[A-Za-z][A-Za-z0-9]*) |
21
|
|
|
|
|
|
|
(?: - [A-Za-z0-9]+ )* |
22
|
|
|
|
|
|
|
}xms; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $distversion_re = qr{ |
25
|
|
|
|
|
|
|
v? |
26
|
|
|
|
|
|
|
(?: |
27
|
|
|
|
|
|
|
[0-9]+ |
28
|
|
|
|
|
|
|
(?: \. [0-9]+ )* |
29
|
|
|
|
|
|
|
) |
30
|
|
|
|
|
|
|
}xms; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $distfq_re = qr{$distname_re-$distversion_re}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
declare DistName => |
36
|
|
|
|
|
|
|
as Str, |
37
|
|
|
|
|
|
|
where { $_ =~ m{\A$distname_re\z} }; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
declare DistVersion => |
40
|
|
|
|
|
|
|
as Str, |
41
|
|
|
|
|
|
|
where { $_ =~ m{\A$distversion_re\z} }; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
declare DistFQ => |
44
|
|
|
|
|
|
|
as Str, |
45
|
|
|
|
|
|
|
where { $_ =~ m{\A$distfq_re\z} }; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
class_type CPANfile, { class => 'Module::CPANfile' }; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
coerce CPANfile, |
50
|
|
|
|
|
|
|
from Str, via { Module::CPANfile->load( $_ ) } |
51
|
|
|
|
|
|
|
; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=encoding UTF-8 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Types::Dist - Types related to distributions (e.g. distributions on CPAN) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 VERSION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
version 0.09 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 TYPES |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 DistFQ |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
I<DistName>-I<DistVersion> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
package MyClass; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use Moo; |
78
|
|
|
|
|
|
|
use Types::Dist qw(DistName); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has dist => ( is => 'ro', isa => DistName ); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
And then use your class: |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $object = MyClass->new( dist => 'Types-RENEEB-0.09' ); |
87
|
|
|
|
|
|
|
my $object = MyClass->new( dist => '0.09' ); # fails |
88
|
|
|
|
|
|
|
my $object = MyClass->new( dist => 'Types-RENEEB' ); # fails |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 DistName |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
A name of a distribution |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $object = MyClass->new( dist => 'Types-RENEEB' ); # ok |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 DistVersion |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
A version of a distribution |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $object = MyClass->new( dist => '0.09' ); # ok |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 CPANfile |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
An instance of L<Module::CPANfile> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
package MyClass; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
use Moo; |
109
|
|
|
|
|
|
|
use Types::Dist qw(CPANfile); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
has prereqs => ( is => 'ro', isa => CPANfile, coerce => 1 ); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
And then use your class: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $object = MyClass->new( prereqs => '/path/to/cpanfile' ); |
118
|
|
|
|
|
|
|
my @features = $object->prereqs->features; # call features method from Module::CPANfile |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Renee Baecker <reneeb@cpan.org> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Renee Baecker. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This is free software, licensed under: |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |