line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
26
|
use v5.12; |
|
2
|
|
|
|
|
6
|
|
2
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
43
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
124
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Data::Validate::CSV::Schema; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
12
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
12
|
|
11
|
2
|
|
|
2
|
|
644
|
use Data::Validate::CSV::Types -types; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
12
|
2
|
|
|
2
|
|
12271
|
use PerlX::Maybe; |
|
2
|
|
|
|
|
5050
|
|
|
2
|
|
|
|
|
9
|
|
13
|
2
|
|
|
2
|
|
84
|
use namespace::autoclean; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has columns => ( |
16
|
|
|
|
|
|
|
is => 'lazy', |
17
|
|
|
|
|
|
|
isa => ArrayRef[Column], |
18
|
0
|
|
|
0
|
|
0
|
builder => sub { [] }, |
19
|
|
|
|
|
|
|
coerce => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has notes => ( |
23
|
|
|
|
|
|
|
is => 'lazy', |
24
|
|
|
|
|
|
|
isa => ArrayRef[Note], |
25
|
0
|
|
|
0
|
|
0
|
builder => sub { [] }, |
26
|
|
|
|
|
|
|
coerce => 1, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has primary_key => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => ArrayRef->of(Str)->plus_coercions(Str, '[$_]'), |
32
|
|
|
|
|
|
|
coerce => 1, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new_from_file { |
36
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
37
|
0
|
|
|
|
|
0
|
require Path::Tiny; |
38
|
0
|
|
|
|
|
0
|
my $file = Path::Tiny::path(@_); |
39
|
0
|
|
|
|
|
0
|
$class->new_from_json( $file->slurp_utf8 ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new_from_json { |
43
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
44
|
0
|
|
|
|
|
0
|
my ($str) = @_; |
45
|
0
|
|
|
|
|
0
|
require JSON::PP; |
46
|
0
|
0
|
|
|
|
0
|
$class->new_from_hashref( JSON::PP->new->decode(ref $str ? $$str : $str) ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new_from_hashref { |
50
|
1
|
|
|
1
|
0
|
370
|
my $class = shift; |
51
|
1
|
|
|
|
|
5
|
my ($schema) = @_; |
52
|
|
|
|
|
|
|
$class->new( |
53
|
|
|
|
|
|
|
notes => $schema->{notes} || [], |
54
|
|
|
|
|
|
|
columns => $schema->{tableSchema}{columns} || [], |
55
|
|
|
|
|
|
|
maybe primary_key => $schema->{tableSchema}{primaryKey}, |
56
|
1
|
|
50
|
|
|
19
|
); |
|
|
|
50
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub clone_columns { |
60
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
61
|
1
|
|
|
|
|
711
|
require Storable; |
62
|
1
|
|
|
|
|
3451
|
Storable::dclone($self->columns); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |