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