blib/lib/Pinto/Types.pm

filter: Statementstmt 84.5% 126 / 149 Branchbran 75.0% 12 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 73.0% 46 / 63 Podpod n/a totaltotal 80.7% 184 / 228 CC 9 SCAR 3.5
CC
9
Cov
84%
__ANON__
3.7
__ANON__
2.1
__ANON__
2.1
CRAP 1.4
« blib/lib/Pinto/Action/Nop.pm ↑ Summary blib/lib/Pinto/Action/Lock.pm »
1 # ABSTRACT: Moose types used within Pinto
2  
3 package Pinto::Types;
4  
5 152 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 152 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 152 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 152 ▶use MooseX::Types -declare => [ qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
10 ANSIColor
11 ANSIColorPalette
12 AuthorID
13 DiffStyle
14 Dir
15 DistributionTarget
16 DistributionTargetList
17 File
18 FileList
19 Io
20 PackageTarget
21 PackageTargetList
22 PerlVersion
23 PropertyName
24 RevisionHead
25 RevisionID
26 StackAll
27 StackDefault
28 StackName
29 StackObject
30 Target
31 TargetList
32 Uri
33 Username
34 Version
35 152 )];
36  
37 152 ▶use MooseX::Types::Moose qw( Str Num ScalarRef ArrayRef Undef
Subroutine BEGIN: called CC=1 SCAR=0.0
38 152 HashRef FileHandle Object Int );
39  
40 152 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 152 ▶use Path::Class::Dir;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 152 ▶use Path::Class::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 152 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 152 ▶use Module::CoreList;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 152 ▶use IO::String;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 152 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 152 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 152 ▶use Pinto::Target;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 152 ▶use Pinto::Constants qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 #-----------------------------------------------------------------------------
53  
54 152 our $VERSION = '0.14'; # VERSION
55  
56 #-----------------------------------------------------------------------------
57  
58 subtype AuthorID, as Str,
59 142 ▶ where { $_ =~ $PINTO_AUTHOR_REGEX },
Subroutine __ANON__: called CC=1 SCAR=0.0
60 5 ▶ message { 'The author id (' . ( defined() ? $_ : 'undef' ) . ') must match /^[A-Z]{2}[-A-Z0-9]*$/' };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 4 1 5
61  
62 10 ▶coerce AuthorID, from Str, via { uc $_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
63  
64 #-----------------------------------------------------------------------------
65  
66 subtype Username, as Str,
67 41 ▶ where { $_ =~ $PINTO_USERNAME_REGEX },
Subroutine __ANON__: called CC=1 SCAR=0.0
68 0 ▶ message { 'The username (' . ( defined() ? $_ : 'undef' ) . ') must be alphanumeric' };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
69  
70 #-----------------------------------------------------------------------------
71  
72 subtype StackName, as Str,
73 157 ▶ where { $_ =~ $PINTO_STACK_NAME_REGEX },
Subroutine __ANON__: called CC=1 SCAR=0.0
74 7 ▶ message { 'The stack name (' . ( defined() ? $_ : 'undef' ) . ') must be alphanumeric' };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 5 2 7
75  
76 #-----------------------------------------------------------------------------
77  
78 subtype StackAll, as Str,
79 3 ▶ where { $_ eq $PINTO_STACK_NAME_ALL },
Subroutine __ANON__: called CC=1 SCAR=0.0
80 3 ▶ message {qq{The stack name must be '$PINTO_STACK_NAME_ALL'}};
Subroutine __ANON__: called CC=1 SCAR=0.0
81  
82 #-----------------------------------------------------------------------------
83  
84 152 subtype StackDefault, as Undef;
85  
86 #-----------------------------------------------------------------------------
87  
88 152 class_type StackObject,
89 { class => 'Pinto::Schema::Result::Stack' };
90  
91 #-----------------------------------------------------------------------------
92  
93 subtype PropertyName, as Str,
94 3 ▶ where { $_ =~ $PINTO_PROPERTY_NAME_REGEX },
Subroutine __ANON__: called CC=1 SCAR=0.0
95 3 ▶ message { 'The property name (' . ( defined() ? $_ : 'undef' ) . 'must be alphanumeric' };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 2 1 3
96  
97 #-----------------------------------------------------------------------------
98  
99 152 class_type Version,
100 { class => 'version' };
101  
102 coerce Version,
103 15 ▶ from Str, via { version->parse($_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
104  
105 coerce Version,
106 0 ▶ from Num, via { version->parse($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
107  
108 #-----------------------------------------------------------------------------
109  
110 subtype PerlVersion, as Object,
111 80 ▶ where { $_->isa('version') && exists $Module::CoreList::version{ $_->numify + 0 } },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_->isa("version") and exists $Module::CoreList::version{$_->numify + 0} 80 0 80
112 0 ▶ message {"perl version ($_) is unknown to me; try updating Pinto's copy of Module::CoreList"};
Subroutine __ANON__: not called CC=1 SCAR=1.2
113  
114 coerce PerlVersion,
115 80 ▶ from Str, via { version->parse($_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
116  
117 coerce PerlVersion,
118 0 ▶ from Num, via { version->parse($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
119  
120 #-----------------------------------------------------------------------------
121  
122 subtype ANSIColor, as Str,
123 27 ▶ where { Term::ANSIColor::colorvalid($_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
124 2 ▶ message { 'The color name (' . ( defined() ? $_ : 'undef' ) . 'is not valid' };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 1 1 2
125  
126 #-----------------------------------------------------------------------------
127  
128 subtype ANSIColorPalette, as ArrayRef[ANSIColor],
129 9 ▶ where { @{$_} == 3 },
Subroutine __ANON__: called CC=1 SCAR=0.0
130 4 ▶ message {'Must be exactly three colors'};
Subroutine __ANON__: called CC=1 SCAR=0.0
131  
132 #-----------------------------------------------------------------------------
133  
134 152 class_type Uri,
135 { class => 'URI' };
136  
137 coerce Uri,
138 2 ▶ from Str, via { URI->new($_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
139  
140 #-----------------------------------------------------------------------------
141  
142 152 class_type Dir,
143 { class => 'Path::Class::Dir' };
144  
145 # file:/// URIs will be converted to plain paths
146  
147 coerce Dir,
148 6 ▶ from Str, via { $_ =~ s{^file://}{}; Path::Class::Dir->new($_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
149  
150 #-----------------------------------------------------------------------------
151  
152 152 class_type File,
153 { class => 'Path::Class::File' };
154  
155 # file:/// URIs will be converted to plain paths
156  
157 coerce File,
158 4 ▶ from Str, via { $_ =~ s{^file://}{}; Path::Class::File->new($_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
159  
160 #-----------------------------------------------------------------------------
161  
162 152 subtype FileList, as ArrayRef [File];
163  
164 coerce FileList,
165 56 ▶ from File, via { [ $_ ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
166 1 ▶ from Str, via { s{^file://}{}; [ Path::Class::File->new($_) ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
167 4 ▶ from ArrayRef[Str], via { [ map { s{^file://}{}; Path::Class::File->new($_) } @$_ ] };
Subroutine __ANON__: called CC=1 SCAR=0.0
168  
169 #-----------------------------------------------------------------------------
170  
171 152 class_type PackageTarget, { class => 'Pinto::Target::Package' };
172  
173 coerce PackageTarget,
174 1 ▶ from Str, via { Pinto::Target->new($_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
175 0 ▶ from HashRef, via { Pinto::Target->new($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
176  
177 #-----------------------------------------------------------------------------
178  
179 152 class_type DistributionTarget, { class => 'Pinto::Target::Distribution' };
180  
181 coerce DistributionTarget,
182 1 ▶ from Str, via { Pinto::Target->new($_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
183 0 ▶ from HashRef, via { Pinto::Target->new($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
184  
185 #-----------------------------------------------------------------------------
186  
187 152 subtype TargetList, as ArrayRef [ PackageTarget | DistributionTarget ]; ## no critic qw(ProhibitBitwiseOperators);
188  
189 coerce TargetList,
190 0 ▶ from PackageTarget, via { [ $_ ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
191 0 ▶ from DistributionTarget, via { [ $_ ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
192 10 ▶ from Str, via { [ Pinto::Target->new($_) ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
193 2 ▶ from ArrayRef[Str], via { [ map { Pinto::Target->new($_) } @$_ ] };
Subroutine __ANON__: called CC=1 SCAR=0.0
194  
195 #-----------------------------------------------------------------------------
196  
197 152 subtype DistributionTargetList, as ArrayRef [DistributionTarget]; ## no critic qw(ProhibitBitwiseOperators);
198  
199 coerce DistributionTargetList,
200 0 ▶ from DistributionTarget, via { [$_] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
201 0 ▶ from Str, via { [ Pinto::Target::Distribution->new($_) ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
202 0 ▶ from ArrayRef[Str], via { [ map { Pinto::Target::Distribution->new($_) } @$_ ] };
Subroutine __ANON__: not called CC=1 SCAR=2.6
203  
204 #-----------------------------------------------------------------------------
205  
206 152 subtype PackageTargetList, as ArrayRef [PackageTarget]; ## no critic qw(ProhibitBitwiseOperators);
207  
208 coerce PackageTargetList,
209 0 ▶ from DistributionTarget, via { [ $_ ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
210 0 ▶ from Str, via { [ Pinto::Target::Package->new($_) ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
211 0 ▶ from ArrayRef[Str], via { [ map { Pinto::Target::Package->new($_) } @$_ ] };
Subroutine __ANON__: not called CC=1 SCAR=2.6
212  
213 #-----------------------------------------------------------------------------
214  
215 152 subtype Io, as Object;
216  
217 coerce Io,
218 0 ▶ from Str, via { my $fh = IO::File->new(); $fh->open($_); return $fh },
Subroutine __ANON__: not called CC=1 SCAR=6.9
219 0 ▶ from File, via { my $fh = IO::File->new(); $fh->open("$_"); return $fh },
Subroutine __ANON__: not called CC=1 SCAR=6.9
220 0 ▶ from ArrayRef, via { IO::Handle->new_from_fd(@$_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
221 142 ▶ from ScalarRef, via { IO::String->new( ${$_} ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
222  
223 #-----------------------------------------------------------------------------
224  
225 subtype RevisionID, as Str,
226 18 ▶ where { $_ =~ $PINTO_REVISION_ID_REGEX and length($_) >= 4 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /$Pinto::Types::PINTO_REVISION_ID_REGEX/ and length $_ >= 4 11 7 18
227 2 ▶ message { 'The revision id (' . ( defined() ? $_ : 'undef' ) . ') must be a hexadecimal string of 4 or more chars' };
Subroutine __ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 2 0 2
228  
229 3 ▶coerce RevisionID, from Str, via { lc $_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
230  
231 #-----------------------------------------------------------------------------
232  
233 152 subtype RevisionHead, as Undef;
234  
235 #-----------------------------------------------------------------------------
236  
237 152 enum DiffStyle, [$PINTO_DIFF_STYLE_CONCISE, $PINTO_DIFF_STYLE_DETAILED];
238  
239 #-----------------------------------------------------------------------------
240  
241 152 1;
242  
243 __END__
« blib/lib/Pinto/Action/Nop.pm ↑ Summary blib/lib/Pinto/Action/Lock.pm »