Data.pm

filter: Statementstmt 89.1% 41 / 46 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 100% 4 / 4 totaltotal 88.0% 59 / 67 SCAR 14.0
CC
4
Cov
87%
new
4.1
_versions_file
2.0
BEGIN
1.0
CRAP 4.0
« Data/Plugin.pm ↑ Summary
1 package Schema::Data;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Perl6::Slurp qw(slurp);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 our $VERSION = 0.05;
12  
13 sub new {
14 7 ▶ my ($class, @params) = @_;
Subroutine new: called CC=4 SCAR=14.1
Pod documented
15  
16 # Create object.
17 7 my $self = bless {}, $class;
18  
19 # Version.
20 7 $self->{'version'} = undef;
21  
22 # Process parameters.
23 7 set_params($self, @params);
24  
25 # Load file with versions.
26 7 $self->{'_versions_file'} = $self->_versions_file;
27 7 my @versions = slurp($self->{'_versions_file'}, {'chomp' => 1});
28 7 $self->{'_versions'} = \@versions;
29  
30 # Set version to last if isn't defined.
31 7 ▶ if (! defined $self->{'version'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"version"}) 4 3 7
32 4 $self->{'version'} = $self->{'_versions'}->[-1];
33 }
34  
35 7 ▶ if ($self->{'version'} !~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"version"} =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/) 0 7 7
36 err 'Schema data version has bad format.',
37 0 'Schema data version', $self->{'version'},
38 ;
39 }
40  
41 # Load schema.
42 7 $self->{'_schema_data_module'} = $class.'::'."$1\_$2\_$3";
43 7 eval 'require '.$self->{'_schema_data_module'};
44 7 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Schema::Data::EVAL_ERROR) 0 7 7
45 err 'Cannot load Schema data module.',
46 0 'Module name', $self->{'_schema_data_module'},
47 'Error', $EVAL_ERROR,
48 ;
49 }
50  
51 7 return $self;
52 }
53  
54 sub list_versions {
55 1 ▶ my $self = shift;
Subroutine list_versions: called CC=1 SCAR=0.0
Pod documented
56  
57 1 return sort @{$self->{'_versions'}};
58 }
59  
60 sub schema_data {
61 2 ▶ my $self = shift;
Subroutine schema_data: called CC=1 SCAR=0.0
Pod documented
62  
63 2 return $self->{'_schema_data_module'};
64 }
65  
66 sub version {
67 2 ▶ my $self = shift;
Subroutine version: called CC=1 SCAR=0.0
Pod documented
68  
69 2 return $self->{'version'};
70 }
71  
72 sub _versions_file {
73 0 ▶ my $self = shift;
Subroutine _versions_file: not called CC=1 SCAR=6.9
74  
75 0 err "We need to implement distribution file with Schema data versions.";
76  
77 0 return;
78 }
79  
80 6 1;
81  
82  
83 __END__
« Data/Plugin.pm ↑ Summary