line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Helper::Schema::Verifier; |
2
|
|
|
|
|
|
|
$DBIx::Class::Helper::Schema::Verifier::VERSION = '2.036000'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Verify the Results and ResultSets of your Schemata |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
49986
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
118
|
|
6
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
95
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
33
|
use MRO::Compat; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
107
|
|
9
|
5
|
|
|
5
|
|
21
|
use mro 'c3'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
21
|
|
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
130
|
use Try::Tiny; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
234
|
|
12
|
5
|
|
|
5
|
|
1593
|
use namespace::clean; |
|
5
|
|
|
|
|
43883
|
|
|
5
|
|
|
|
|
38
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
1025
|
use base 'DBIx::Class::Schema'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
2471
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub result_verifiers { |
17
|
|
|
|
|
|
|
return () |
18
|
16
|
|
|
16
|
1
|
186
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $_FATAL = 1; |
21
|
|
|
|
|
|
|
our @_ERRORS; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub register_source { |
24
|
4
|
|
|
4
|
1
|
19206
|
my ($self, $name, $rclass) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
10
|
unless ($_FATAL) { |
27
|
|
|
|
|
|
|
$self->$_($rclass->result_class, $rclass->resultset_class) |
28
|
0
|
|
|
|
|
0
|
for $self->result_verifiers; |
29
|
|
|
|
|
|
|
} else { |
30
|
4
|
|
|
|
|
13
|
for ($self->result_verifiers) { |
31
|
|
|
|
|
|
|
try { |
32
|
12
|
|
|
12
|
|
573
|
$self->$_($rclass->result_class, $rclass->resultset_class) |
33
|
|
|
|
|
|
|
} catch { |
34
|
4
|
|
|
4
|
|
341
|
push @_ERRORS, $_ |
35
|
|
|
|
|
|
|
} |
36
|
12
|
|
|
|
|
414
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
71
|
$self->next::method($name, $rclass); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub load_namespaces { |
43
|
1
|
|
|
1
|
1
|
11
|
local $_FATAL = 1; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
4
|
shift->next::method(@_); |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
250
|
my @e = @_ERRORS; |
48
|
1
|
|
|
|
|
2
|
@_ERRORS = (); |
49
|
1
|
50
|
|
|
|
24
|
die sort @e if @e; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub load_classes { |
53
|
1
|
|
|
1
|
1
|
155
|
local $_FATAL = 1; |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
3
|
shift->next::method(@_); |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
269
|
my @e = @_ERRORS; |
58
|
1
|
|
|
|
|
2
|
@_ERRORS = (); |
59
|
1
|
50
|
|
|
|
6
|
die sort @e if @e; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
DBIx::Class::Helper::Schema::Verifier - Verify the Results and ResultSets of your Schemata |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SYNOPSIS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
package MyApp::Schema; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->load_components('Helper::Schema::Verifier'); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub result_verifiers { |
79
|
|
|
|
|
|
|
( |
80
|
|
|
|
|
|
|
sub { |
81
|
|
|
|
|
|
|
my ($self, $result, $set) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
for ($result, $set) { |
84
|
|
|
|
|
|
|
die "$_ does not start with the letter A" unless m/^A/ |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
}, |
87
|
|
|
|
|
|
|
shift->next::method, |
88
|
|
|
|
|
|
|
) |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
C<DBIx::Class::Helper::Schema::Verifier> is a minuscule framework to assist in |
94
|
|
|
|
|
|
|
creating schemata that are to your very own exacting specifications. It is |
95
|
|
|
|
|
|
|
inspired by my own travails in discovering that C<< use mro 'c3' >> is both |
96
|
|
|
|
|
|
|
required and barely documented in much Perl code. As time goes by I expect to |
97
|
|
|
|
|
|
|
add many more verifiers, but with this inaugural release I am merely including |
98
|
|
|
|
|
|
|
L<DBIx::Class::Helper::Schema::Verifier::C3>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 INTERFACE METHODS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 result_verifiers |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
You must implement C<result_verifiers> in your subclass of C<::Verifier>. Each |
105
|
|
|
|
|
|
|
verifier gets called on the schema and gets each result and resultset together |
106
|
|
|
|
|
|
|
as arguments. You can use this to validate almost anything about the results |
107
|
|
|
|
|
|
|
and resultsets of a schema; contributions are warmly welcomed. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 MORE ERRORS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Initially I kept this module simple, but after using it in production at |
112
|
|
|
|
|
|
|
L<ZipRecruiter|https://www.ziprecruiter.com> I found that showing the user the |
113
|
|
|
|
|
|
|
first error that occurred and then giving up was pretty annoying. Now |
114
|
|
|
|
|
|
|
C<Schema::Verifier> wraps both L<DBIx::Class::Schema/load_namespaces> and |
115
|
|
|
|
|
|
|
L<DBIx::Class::Schema/load_classes> and shows all the exceptions encoutered as a |
116
|
|
|
|
|
|
|
list at the end of loading all the results. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
127
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |