line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Types::Dist; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Types related to distributions (e.g. distributions on CPAN) |
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
143768
|
use v5.10; |
|
10
|
|
|
|
|
45
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
58
|
use strict; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
243
|
|
8
|
10
|
|
|
10
|
|
51
|
use warnings; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
442
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Type::Library |
11
|
10
|
|
|
|
|
98
|
-base, |
12
|
10
|
|
|
10
|
|
1914
|
-declare => qw( DistName DistVersion DistFQ CPANfile ); |
|
10
|
|
|
|
|
147859
|
|
13
|
|
|
|
|
|
|
|
14
|
10
|
|
|
10
|
|
13916
|
use Type::Utils -all; |
|
10
|
|
|
|
|
38537
|
|
|
10
|
|
|
|
|
93
|
|
15
|
10
|
|
|
10
|
|
29896
|
use Types::Standard -types; |
|
10
|
|
|
|
|
284559
|
|
|
10
|
|
|
|
|
93
|
|
16
|
|
|
|
|
|
|
|
17
|
10
|
|
|
10
|
|
85977
|
use Module::CPANfile; |
|
10
|
|
|
|
|
132605
|
|
|
10
|
|
|
|
|
2690
|
|
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.10 |
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 |