File Coverage

blib/lib/App/Sqitch/Types.pm
Criterion Covered Total %
statement 36 36 100.0
branch n/a
condition n/a
subroutine 13 13 100.0
pod n/a
total 49 49 100.0


line stmt bran cond sub pod time code
1             package App::Sqitch::Types;
2              
3 50     50   1033 use 5.010;
  50         196  
4 50     50   293 use strict;
  50         131  
  50         1049  
5 50     50   243 use warnings;
  50         118  
  50         1297  
6 50     50   264 use utf8;
  50         101  
  50         411  
7 50         382 use Type::Library 0.040 -base, -declare => qw(
8             Sqitch
9             Engine
10             Target
11             UserName
12             UserEmail
13             Plan
14             Change
15             ChangeList
16             LineList
17             Tag
18             Depend
19             DateTime
20             URI
21             URIDB
22             File
23             Dir
24             Config
25             DBH
26 50     50   2661 );
  50         1114  
27 50     50   117318 use Type::Utils -all;
  50         123  
  50         358  
28 50     50   171413 use Types::Standard -types;
  50         119  
  50         391  
29 50     50   239118 use Locale::TextDomain 1.20 qw(App-Sqitch);
  50         1049  
  50         501  
30 50     50   11354 use App::Sqitch::X qw(hurl);
  50         122  
  50         378  
31 50     50   33812 use App::Sqitch::Config;
  50         217  
  50         2007  
32 50     50   356 use Scalar::Util qw(blessed);
  50         160  
  50         2698  
33 50     50   361 use List::Util qw(first);
  50         139  
  50         3975  
34              
35             our $VERSION = 'v1.4.0'; # VERSION
36              
37             # Inherit standard types.
38 50     50   380 BEGIN { extends 'Types::Standard' };
39              
40             class_type Sqitch, { class => 'App::Sqitch' };
41             class_type Engine, { class => 'App::Sqitch::Engine' };
42             class_type Target, { class => 'App::Sqitch::Target' };
43             class_type Plan, { class => 'App::Sqitch::Plan' };
44             class_type Change, { class => 'App::Sqitch::Plan::Change' };
45             class_type ChangeList, { class => 'App::Sqitch::Plan::ChangeList' };
46             class_type LineList, { class => 'App::Sqitch::Plan::LineList' };
47             class_type Tag, { class => 'App::Sqitch::Plan::Tag' };
48             class_type Depend, { class => 'App::Sqitch::Plan::Depend' };
49             class_type DateTime, { class => 'App::Sqitch::DateTime' };
50             class_type URIDB, { class => 'URI::db' };
51             class_type Config { class => 'App::Sqitch::Config' };
52             class_type File { class => 'Path::Class::File' };
53             class_type Dir { class => 'Path::Class::Dir' };
54             class_type DBH { class => 'DBI::db' };
55              
56             subtype UserName, as Str, where {
57             hurl user => __ 'User name may not contain "<" or start with "["'
58             if /^[[]/ || /</;
59             1;
60             };
61              
62             subtype UserEmail, as Str, where {
63             hurl user => __ 'User email may not contain ">"' if />/;
64             1;
65             };
66              
67             # URI can be URI or URI::Nested.
68             declare name => URI, constraint => sub {
69             my $o = $_;
70             return blessed $o && first { $o->isa($_)} qw(URI URI::Nested URI::WithBase)
71             };
72              
73             1;
74             __END__
75              
76             =head1 Name
77              
78             App::Sqitch::Types - Definition of attribute data types
79              
80             =head1 Synopsis
81              
82             use App::Sqitch::Types qw(Bool);
83              
84             =head1 Description
85              
86             This module defines data types use in Sqitch object attributes. Supported types
87             are:
88              
89             =over
90              
91             =item C<Sqitch>
92              
93             An L<App::Sqitch> object.
94              
95             =item C<Engine>
96              
97             An L<App::Sqitch::Engine> object.
98              
99             =item C<Target>
100              
101             An L<App::Sqitch::Target> object.
102              
103             =item C<UserName>
104              
105             A Sqitch user name.
106              
107             =item C<UserEmail>
108              
109             A Sqitch user email address.
110              
111             =item C<Plan>
112              
113             A L<Sqitch::App::Plan> object.
114              
115             =item C<Change>
116              
117             A L<Sqitch::App::Plan::Change> object.
118              
119             =item C<ChangeList>
120              
121             A L<Sqitch::App::Plan::ChangeList> object.
122              
123             =item C<LineList>
124              
125             A L<Sqitch::App::Plan::LineList> object.
126              
127             =item C<Tag>
128              
129             A L<Sqitch::App::Plan::Tag> object.
130              
131             =item C<Depend>
132              
133             A L<Sqitch::App::Plan::Depend> object.
134              
135             =item C<DateTime>
136              
137             A L<Sqitch::App::DateTime> object.
138              
139             =item C<URI>
140              
141             A L<URI> object.
142              
143             =item C<URIDB>
144              
145             A L<URI::db> object.
146              
147             =item C<File>
148              
149             A C<Class::Path::File> object.
150              
151             =item C<Dir>
152              
153             A C<Class::Path::Dir> object.
154              
155             =item C<Config>
156              
157             A L<Sqitch::App::Config> object.
158              
159             =item C<DBH>
160              
161             A L<DBI> database handle.
162              
163             =back
164              
165             =head1 Author
166              
167             David E. Wheeler <david@justatheory.com>
168              
169             =head1 License
170              
171             Copyright (c) 2012-2023 iovation Inc., David E. Wheeler
172              
173             Permission is hereby granted, free of charge, to any person obtaining a copy
174             of this software and associated documentation files (the "Software"), to deal
175             in the Software without restriction, including without limitation the rights
176             to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
177             copies of the Software, and to permit persons to whom the Software is
178             furnished to do so, subject to the following conditions:
179              
180             The above copyright notice and this permission notice shall be included in all
181             copies or substantial portions of the Software.
182              
183             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
184             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
185             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
186             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
187             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
188             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
189             SOFTWARE.
190              
191             =cut