line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Schema::Abstract; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
187889
|
use strict; |
|
6
|
|
|
|
|
50
|
|
|
6
|
|
|
|
|
155
|
|
4
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
159
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
814
|
use Class::Utils qw(set_params); |
|
6
|
|
|
|
|
53041
|
|
|
6
|
|
|
|
|
215
|
|
7
|
6
|
|
|
6
|
|
149
|
use English; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
37
|
|
8
|
6
|
|
|
6
|
|
2428
|
use Error::Pure qw(err); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
215
|
|
9
|
6
|
|
|
6
|
|
2524
|
use Perl6::Slurp qw(slurp); |
|
6
|
|
|
|
|
8443
|
|
|
6
|
|
|
|
|
30
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.03; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Constructor. |
14
|
|
|
|
|
|
|
sub new { |
15
|
7
|
|
|
7
|
1
|
69749
|
my ($class, @params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Create object. |
18
|
7
|
|
|
|
|
22
|
my $self = bless {}, $class; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Version. |
21
|
7
|
|
|
|
|
28
|
$self->{'version'} = undef; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Process parameters. |
24
|
7
|
|
|
|
|
32
|
set_params($self, @params); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Load file with versions. |
27
|
7
|
|
|
|
|
86
|
$self->{'_versions_file'} = $self->_versions_file; |
28
|
7
|
|
|
|
|
3949
|
my @versions = slurp($self->{'_versions_file'}, {'chomp' => 1}); |
29
|
7
|
|
|
|
|
1434
|
$self->{'_versions'} = \@versions; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Set version to last if isn't defined. |
32
|
7
|
100
|
|
|
|
31
|
if (! defined $self->{'version'}) { |
33
|
4
|
|
|
|
|
12
|
$self->{'version'} = $self->{'_versions'}->[-1]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
7
|
50
|
|
|
|
47
|
if ($self->{'version'} !~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/) { |
37
|
|
|
|
|
|
|
err 'Schema version has bad format.', |
38
|
0
|
|
|
|
|
0
|
'Schema version', $self->{'version'}, |
39
|
|
|
|
|
|
|
; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Load schema. |
43
|
7
|
|
|
|
|
42
|
$self->{'_schema_module_name'} = $class.'::'."$1\_$2\_$3"; |
44
|
7
|
|
|
|
|
364
|
eval 'require '.$self->{'_schema_module_name'}; |
45
|
7
|
50
|
|
|
|
108
|
if ($EVAL_ERROR) { |
46
|
|
|
|
|
|
|
err 'Cannot load Schema module.', |
47
|
0
|
|
|
|
|
0
|
'Module name', $self->{'_schema_module_name'}, |
48
|
|
|
|
|
|
|
'Error', $EVAL_ERROR, |
49
|
|
|
|
|
|
|
; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
50
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub list_versions { |
56
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
12
|
return sort @{$self->{'_versions'}}; |
|
1
|
|
|
|
|
13
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub schema { |
62
|
2
|
|
|
2
|
1
|
13
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
17
|
return $self->{'_schema_module_name'}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub version { |
68
|
2
|
|
|
2
|
1
|
14
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
17
|
return $self->{'version'}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _versions_file { |
74
|
0
|
|
|
0
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
err "We need to implement distribution file with Schema versions."; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |