line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Schema::Abstract; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
61387
|
use strict; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
843
|
use Class::Utils qw(set_params); |
|
2
|
|
|
|
|
53161
|
|
|
2
|
|
|
|
|
35
|
|
7
|
2
|
|
|
2
|
|
128
|
use English; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
8
|
2
|
|
|
2
|
|
820
|
use Error::Pure qw(err); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
9
|
2
|
|
|
2
|
|
1006
|
use Perl6::Slurp qw(slurp); |
|
2
|
|
|
|
|
2790
|
|
|
2
|
|
|
|
|
12
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.01; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Constructor. |
14
|
|
|
|
|
|
|
sub new { |
15
|
0
|
|
|
0
|
1
|
|
my ($class, @params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Create object. |
18
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Version. |
21
|
0
|
|
|
|
|
|
$self->{'version'} = undef; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Process parameters. |
24
|
0
|
|
|
|
|
|
set_params($self, @params); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Load file with versions. |
27
|
0
|
|
|
|
|
|
$self->{'_versions_file'} = $self->_versions_file; |
28
|
0
|
|
|
|
|
|
my @versions = slurp($self->{'_versions_file'}, {'chomp' => 1}); |
29
|
0
|
|
|
|
|
|
$self->{'_versions'} = \@versions; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Set version to last if isn't defined. |
32
|
0
|
0
|
|
|
|
|
if (! defined $self->{'version'}) { |
33
|
0
|
|
|
|
|
|
$self->{'version'} = $self->{'_versions'}->[-1]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ($self->{'version'} !~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/) { |
37
|
|
|
|
|
|
|
err 'Schema version has bad format.', |
38
|
0
|
|
|
|
|
|
'Schema version', $self->{'version'}, |
39
|
|
|
|
|
|
|
; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Load schema. |
43
|
0
|
|
|
|
|
|
$self->{'_schema_module_name'} = $class.'::'."$1\_$2\_$3"; |
44
|
0
|
|
|
|
|
|
eval 'require '.$self->{'_schema_module_name'}; |
45
|
0
|
0
|
|
|
|
|
if ($EVAL_ERROR) { |
46
|
|
|
|
|
|
|
err 'Cannot load Schema module.', |
47
|
0
|
|
|
|
|
|
'Module name', $self->{'_schema_module_name'}, |
48
|
|
|
|
|
|
|
'Error', $EVAL_ERROR, |
49
|
|
|
|
|
|
|
; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub list_versions { |
56
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return sort @{$self->{'_versions'}}; |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub schema { |
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $self->{'_schema_module_name'}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub version { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
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__ |