| 1 | package OPM::Maker::Command::sopm; | ||||||||||||||||||||||||||||||||||
| 2 | 33 | $OPM::Maker::Command::sopm::VERSION = '1.2.0'; | |||||||||||||||||||||||||||||||||
| 3 | 33 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 33 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 33 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | # ABSTRACT: Build .sopm file based on metadata | ||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 33 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 33 | ▶ | use File::Find::Rule; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 33 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 33 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 33 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 33 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 33 | ▶ | use List::Util qw(first max); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | 33 | ▶ | use Path::Class (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | 33 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | 33 | ▶ | use XML::LibXML::PrettyPrint; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 33 | ▶ | use OPM::Maker -command; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | 33 | ▶ | use OPM::Maker::Utils::OTRS3; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 23 | 33 | ▶ | use OPM::Maker::Utils::OTRS4; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub abstract { | ||||||||||||||||||||||||||||||||
|
Subroutine
abstract: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 26 | 0 | return "build sopm file based on metadata"; | |||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub usage_desc { | ||||||||||||||||||||||||||||||||
|
Subroutine
usage_desc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 30 | 0 | return "opmbuild sopm [--config <json_file>] [--cvs] <path_to_module>"; | |||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 34 | return ( | ||||||||||||||||||||||||||||||||||
| 35 | 0 | [ 'config=s', 'JSON file that provides all the metadata' ], | |||||||||||||||||||||||||||||||||
| 36 | [ 'cvs' , 'Add CVS tag to .sopm' ], | ||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub validate_args { | ||||||||||||||||||||||||||||||||
|
Subroutine
validate_args: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 41 | 0 | my ($self, $opt, $args) = @_; | |||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ( !$opt->{config} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my @json_files = File::Find::Rule->file->name( '*.json' )->in( $args->[0] || '.' ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->[0] || '.'
MC/DC0%0/1
$args->[0] || '.'
$args->[0]
Truth table0%0/2
A
A= $args->[0]
| |||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | @json_files > 1 ? | ||||||||||||||||||||||||||||||||||
| 47 | $self->usage_error( 'found more than one json file, please specify the config file to use' ) : | ||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | do{ $opt->{config} = $json_files[0] }; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( !$opt->{config} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->usage_error( 'Please specify the config file to use' ); | |||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | 0 | my $config = Path::Class::File->new( $opt->{config} ); | |||||||||||||||||||||||||||||||||
| 56 | 0 | my $json = JSON->new->relaxed; | |||||||||||||||||||||||||||||||||
| 57 | 0 | my $json_text = $config->slurp; | |||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $self->usage_error( 'config file has to be in JSON format: ' . $@ ) if ! eval{ $json->decode( $json_text ); 1; }; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 36 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=71 SCAR=43.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 62 | 36 | my ($self, $opt, $args) = @_; | |||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 36 | ▶ | if ( !$opt->{config} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 65 | 0 | print $self->usage->text; | |||||||||||||||||||||||||||||||||
| 66 | 0 | return; | |||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 36 | my $config = Path::Class::File->new( $opt->{config} ); | |||||||||||||||||||||||||||||||||
| 70 | 36 | my $json_text = $config->slurp; | |||||||||||||||||||||||||||||||||
| 71 | 36 | my $object = JSON->new->relaxed; | |||||||||||||||||||||||||||||||||
| 72 | 36 | my $json = $object->decode( $json_text ); | |||||||||||||||||||||||||||||||||
| 73 | 36 | my $name = $json->{name}; | |||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | 36 | ▶ | chdir $args->[0] if $args->[0]; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | # check needed info | ||||||||||||||||||||||||||||||||||
| 78 | 36 | for my $needed (qw(name version framework)) { | |||||||||||||||||||||||||||||||||
| 79 | 108 | ▶ | if ( !$json->{$needed} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 80 | 0 | carp "Need $needed in config file"; | |||||||||||||||||||||||||||||||||
| 81 | 0 | exit 1; | |||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||
| 85 | 36 | my @xml_parts; | |||||||||||||||||||||||||||||||||
| 86 | my %major_versions; | ||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||
| 89 | 36 | for my $framework ( @{ $json->{framework} } ) { | |||||||||||||||||||||||||||||||||
| 90 | 61 | my $version = $framework; | |||||||||||||||||||||||||||||||||
| 91 | 61 | my $min = ''; | |||||||||||||||||||||||||||||||||
| 92 | 61 | my $max = ''; | |||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | 61 | ▶ | if ( 'HASH' eq ref $framework ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 95 | 3 | $version = $framework->{version}; | |||||||||||||||||||||||||||||||||
| 96 | 3 | $min = $framework->{min}; | |||||||||||||||||||||||||||||||||
| 97 | 3 | $max = $framework->{max}; | |||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | 61 | ▶ | push @xml_parts, sprintf " <Framework%s%s>%s</Framework>", | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 101 | ( $min ? qq~ Minimum="$min"~ : '' ), | ||||||||||||||||||||||||||||||||||
| 102 | ( $max ? qq~ Maximum="$max"~ : '' ), | ||||||||||||||||||||||||||||||||||
| 103 | $version; | ||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | 61 | my $major_version = (split /\./, $version)[0]; | |||||||||||||||||||||||||||||||||
| 106 | 61 | $major_versions{$major_version}++; | |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | 36 | ▶ | if ( 2 <= keys %major_versions ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 110 | 2 | carp "Two major versions declared in framework settings. Those might be incompatible.\n"; | |||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | 36 | my %utils_versions = ( | |||||||||||||||||||||||||||||||||
| 115 | OTRS => { | ||||||||||||||||||||||||||||||||||
| 116 | '3' => 'OTRS3', | ||||||||||||||||||||||||||||||||||
| 117 | '4' => 'OTRS4', | ||||||||||||||||||||||||||||||||||
| 118 | '5' => 'OTRS4', | ||||||||||||||||||||||||||||||||||
| 119 | '6' => 'OTRS4', | ||||||||||||||||||||||||||||||||||
| 120 | '7' => 'OTRS4', | ||||||||||||||||||||||||||||||||||
| 121 | }, | ||||||||||||||||||||||||||||||||||
| 122 | KIX => { | ||||||||||||||||||||||||||||||||||
| 123 | '5' => 'OTRS4', | ||||||||||||||||||||||||||||||||||
| 124 | }, | ||||||||||||||||||||||||||||||||||
| 125 | OTOBO => { | ||||||||||||||||||||||||||||||||||
| 126 | '10' => 'OTRS4', | ||||||||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | 36 | my ($max) = max keys %major_versions; | |||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||
| 132 | 36 | ▶ | my $product = uc ( $json->{product} // 'OTRS' ); | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$json->{"product"} // "OTRS"
MC/DC100%1/1
$json->{"product"} // "OTRS"
$json->{"product"}
Truth table100%2/2
A
A= $json->{"product"}
| |||||||||||||||||||||||||||||||||||
| 133 | 36 | ▶ | if ( $product eq 'KIX' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 134 | 1 | $max = 5; | |||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 36 | ▶ | my $mod = $utils_versions{$product}->{$max} || $utils_versions{OTRS}->{4}; | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$utils_versions{$product}{$max} || $utils_versions{'OTRS'}{'4'}
MC/DC0%0/2
$utils_versions{$product}{$max} || $utils_versions{'OTRS'}{'4'}
$utils_versions{$product}{$max}
$utils_versions{'OTRS'}{'4'}
Truth table33%1/3
A || B
A= $utils_versions{$product}{$max}B= $utils_versions{'OTRS'}{'4'}
| |||||||||||||||||||||||||||||||||||
| 138 | 36 | my $utils = 'OPM::Maker::Utils::' . $mod; | |||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | 36 | ▶ | if ( $json->{requires} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||
| 142 | 16 | for my $name ( sort keys %{ $json->{requires}->{package} } ) { | |||||||||||||||||||||||||||||||||
| 143 | 16 | push @xml_parts, sprintf ' <PackageRequired Version="%s">%s</PackageRequired>', $json->{requires}->{package}->{$name}, $name; | |||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||
| 148 | 16 | for my $name ( sort keys %{ $json->{requires}->{module} } ) { | |||||||||||||||||||||||||||||||||
| 149 | 16 | push @xml_parts, sprintf ' <ModuleRequired Version="%s">%s</ModuleRequired>', $json->{requires}->{module}->{$name}, $name; | |||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||
| 154 | 36 | ▶ | push @xml_parts, sprintf " <Vendor>%s</Vendor>", $json->{vendor}->{name} || ''; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$json->{'vendor'}{'name'} || ''
MC/DC0%0/1
$json->{'vendor'}{'name'} || ''
$json->{'vendor'}{'name'}
Truth table50%1/2
A
A= $json->{'vendor'}{'name'}
| |||||||||||||||||||||||||||||||||||
| 155 | 36 | ▶ | push @xml_parts, sprintf " <URL>%s</URL>", $json->{vendor}->{url} || ''; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$json->{'vendor'}{'url'} || ''
MC/DC0%0/1
$json->{'vendor'}{'url'} || ''
$json->{'vendor'}{'url'}
Truth table50%1/2
A
A= $json->{'vendor'}{'url'}
| |||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | 36 | ▶ | if ( $json->{description} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 158 | 36 | for my $lang ( sort keys %{ $json->{description} } ) { | |||||||||||||||||||||||||||||||||
| 159 | 36 | push @xml_parts, sprintf ' <Description Lang="%s">%s</Description>', $lang, $json->{description}->{$lang}; | |||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | 36 | ▶ | if ( $json->{license} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 164 | 36 | push @xml_parts, sprintf ' <License>%s</License>', $json->{license}; | |||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||
| 167 | # create filelist | ||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||
| 169 | 36 | my @files = File::Find::Rule->file->in( '.' ); | |||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | # remove "hidden" files from list; and do not list .sopm | ||||||||||||||||||||||||||||||||||
| 172 | @files = grep{ | ||||||||||||||||||||||||||||||||||
| 173 | 36 | ( substr( $_, 0, 1 ) ne '.' ) && | |||||||||||||||||||||||||||||||||
| 174 | $_ !~ m{[\\/]\.} && | ||||||||||||||||||||||||||||||||||
| 175 | 166 | ▶ | $_ ne $json->{name} . '.sopm' | ||||||||||||||||||||||||||||||||
|
Condition50%3/6
substr($_, 0, 1) ne '.' && !($_ =~ m[[\\/]\.]) && $_ ne $json->{'name'} . '.sopm'
substr($_, 0, 1) ne "." and not $_ =~ m[[\\/]\.]
MC/DC33%1/3
substr($_, 0, 1) ne '.' && !($_ =~ m[[\\/]\.]) && $_ ne $json->{'name'} . '.sopm'
substr($_, 0, 1) ne "."
not $_ =~ m[[\\/]\.]
$_ ne $json->{'name'} . '.sopm'
Truth table50%2/4
A and not(B) && C
A= substr($_, 0, 1) ne "."B= not $_ =~ m[[\\/]\.]C= $_ ne $json->{'name'} . '.sopm'
| |||||||||||||||||||||||||||||||||||
| 176 | }sort @files; | ||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | 36 | ▶ | if ( $json->{exclude_files} and 'ARRAY' eq ref $json->{exclude_files} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$json->{"exclude_files"} and "ARRAY" eq ref $json->{"exclude_files"}
MC/DC50%1/2
$json->{"exclude_files"} and "ARRAY" eq ref $json->{"exclude_files"}
$json->{"exclude_files"}
"ARRAY" eq ref $json->{"exclude_files"}
Truth table66%2/3
A and B
A= $json->{"exclude_files"}B= "ARRAY" eq ref $json->{"exclude_files"}
| |||||||||||||||||||||||||||||||||||
| 179 | # ignore ignore file ;-) | ||||||||||||||||||||||||||||||||||
| 180 | 1 | my $ignore_name = '.opmbuild_filetest_ignore'; | |||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | push @{ $json->{exclude_files} }, $ignore_name if !grep{ $_ eq $ignore_name } @{ $json->{exclude_files} }; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||
| 183 | 1 | for my $index ( reverse 0 .. $#files ) { | |||||||||||||||||||||||||||||||||
| 184 | 2 | my $file = $files[$index]; | |||||||||||||||||||||||||||||||||
| 185 | 3 | ▶ | my $excluded = first { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 186 | 3 | eval{ $file =~ /$_\z/ }; | |||||||||||||||||||||||||||||||||
| 187 | 2 | }@{ $json->{exclude_files} }; | |||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | 2 | ▶ | splice @files, $index, 1 if $excluded; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | # create ignore file | ||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | my $fh = IO::File->new( $ignore_name, 'w' ) or die $!; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 194 | 1 | my $ignore_files = join "\n", @{ $json->{exclude_files} }; | |||||||||||||||||||||||||||||||||
| 195 | 1 | $fh->print( $ignore_files ); | |||||||||||||||||||||||||||||||||
| 196 | 1 | $fh->close; | |||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||
| 199 | 36 | $utils->filecheck( \@files ); | |||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||
| 201 | push @xml_parts, | ||||||||||||||||||||||||||||||||||
| 202 | sprintf " <Filelist>\n%s\n </Filelist>", | ||||||||||||||||||||||||||||||||||
| 203 | 36 | ▶ | join "\n", map{ my $permission = $_ =~ /^bin/ ? 755 : 644; qq~ <File Permission="$permission" Location="$_" />~ }@files; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||
| 206 | 36 | ▶ | if ( $json->{changes_file} && -f $config->dir . "/" . $json->{changes_file} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$json->{"changes_file"} and -f $config->dir . '/' . $json->{"changes_file"}
MC/DC50%1/2
$json->{"changes_file"} and -f $config->dir . '/' . $json->{"changes_file"}
$json->{"changes_file"}
-f $config->dir . '/' . $json->{"changes_file"}
Truth table66%2/3
A and B
A= $json->{"changes_file"}B= -f $config->dir . '/' . $json->{"changes_file"}
| |||||||||||||||||||||||||||||||||||
| 207 | 1 | my $changes_file = Path::Class::File->new( $config->dir, $json->{changes_file} ); | |||||||||||||||||||||||||||||||||
| 208 | 1 | my $lines = $changes_file->slurp( iomode => '<:encoding(UTF-8)' ); | |||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||
| 210 | 1 | ▶ | my @entries = grep{ ( $_ // '' ) ne '' }split m{ | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ // ""
MC/DC0%0/1
$_ // ""
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||
| 211 | (?:\s+)? | ||||||||||||||||||||||||||||||||||
| 212 | ( # headline with version and date | ||||||||||||||||||||||||||||||||||
| 213 | ^ | ||||||||||||||||||||||||||||||||||
| 214 | \d+\.\d+ (?:\.\d+)? # version | ||||||||||||||||||||||||||||||||||
| 215 | \s+ - \s+ | ||||||||||||||||||||||||||||||||||
| 216 | \d{4}-\d{2}-\d{2} \s # date | ||||||||||||||||||||||||||||||||||
| 217 | \d{2}:\d{2}:\d{2} # time | ||||||||||||||||||||||||||||||||||
| 218 | ) | ||||||||||||||||||||||||||||||||||
| 219 | \s+ | ||||||||||||||||||||||||||||||||||
| 220 | }xms, $lines; | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | while ( @entries ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 223 | 2 | my ($header, $desc) = ( shift(@entries), shift(@entries) ); | |||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | my ($version, $date) = split /\s+-\s+/, $header // ''; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$header // ""
MC/DC0%0/1
$header // ""
$header
Truth table50%1/2
A
A= $header
| |||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||
| 227 | 2 | $desc =~ s{\s+\z}{}; | |||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 2 | push @xml_parts, sprintf qq~ <ChangeLog Version="%s" Date="%s"><![CDATA[ %s ]]></ChangeLog>~, $version, $date, $desc; | |||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||
| 233 | # changelog | ||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||
| 235 | 36 | CHANGE: | |||||||||||||||||||||||||||||||||
| 236 | 36 | ▶ | for my $change ( @{ $json->{changes} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$json->{'changes'} || []
MC/DC100%1/1
$json->{'changes'} || []
$json->{'changes'}
Truth table100%2/2
A
A= $json->{'changes'}
| |||||||||||||||||||||||||||||||||||
| 237 | 2 | my $version = ''; | |||||||||||||||||||||||||||||||||
| 238 | 2 | my $date = ''; | |||||||||||||||||||||||||||||||||
| 239 | 2 | my $info = ''; | |||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | if ( !ref $change ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 242 | 1 | $info = $change; | |||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||
| 244 | elsif ( 'HASH' eq ref $change ) { | ||||||||||||||||||||||||||||||||||
| 245 | 1 | $info = $change->{message}; | |||||||||||||||||||||||||||||||||
| 246 | 1 | ▶ | $version = sprintf( ' Version="%s"', $change->{version} ) if $change->{version}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | $date = sprintf( ' Date="%s"', $change->{date} ) if $change->{date}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | next CHANGE if !length $info; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||
| 252 | 2 | push @xml_parts, sprintf " <ChangeLog%s%s>%s</ChangeLog>", $version, $date, $info; | |||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||
| 256 | 36 | my %actions = ( | |||||||||||||||||||||||||||||||||
| 257 | Install => 'post', | ||||||||||||||||||||||||||||||||||
| 258 | Uninstall => 'pre', | ||||||||||||||||||||||||||||||||||
| 259 | Upgrade => 'post', | ||||||||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||
| 262 | 36 | my %action_code = ( | |||||||||||||||||||||||||||||||||
| 263 | TableCreate => \&_TableCreate, | ||||||||||||||||||||||||||||||||||
| 264 | Insert => \&_Insert, | ||||||||||||||||||||||||||||||||||
| 265 | TableDrop => \&_TableDrop, | ||||||||||||||||||||||||||||||||||
| 266 | ColumnAdd => \&_ColumnAdd, | ||||||||||||||||||||||||||||||||||
| 267 | ColumnDrop => \&_ColumnDrop, | ||||||||||||||||||||||||||||||||||
| 268 | ColumnChange => \&_ColumnChange, | ||||||||||||||||||||||||||||||||||
| 269 | ForeignKeyCreate => \&_ForeignKeyCreate, | ||||||||||||||||||||||||||||||||||
| 270 | ForeignKeyDrop => \&_ForeignKeyDrop, | ||||||||||||||||||||||||||||||||||
| 271 | UniqueDrop => \&_UniqueDrop, | ||||||||||||||||||||||||||||||||||
| 272 | UniqueCreate => \&_UniqueCreate, | ||||||||||||||||||||||||||||||||||
| 273 | ); | ||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | 36 | my %tables_to_delete; | |||||||||||||||||||||||||||||||||
| 276 | my %own_tables; | ||||||||||||||||||||||||||||||||||
| 277 | 36 | my @columns_to_delete; | |||||||||||||||||||||||||||||||||
| 278 | 36 | my %db_actions; | |||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||
| 280 | 36 | my $table_counter = 0; | |||||||||||||||||||||||||||||||||
| 281 | 36 | my $column_counter; | |||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||
| 283 | ACTION: | ||||||||||||||||||||||||||||||||||
| 284 | 36 | ▶ | for my $action ( @{ $json->{database} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$json->{'database'} || []
MC/DC100%1/1
$json->{'database'} || []
$json->{'database'}
Truth table100%2/2
A
A= $json->{'database'}
| |||||||||||||||||||||||||||||||||||
| 285 | 32 | my $tmp_version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 286 | 32 | ▶ | my @versions = ref $tmp_version ? @{$tmp_version} : ($tmp_version); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||
| 288 | VERSION: | ||||||||||||||||||||||||||||||||||
| 289 | 32 | for my $version ( @versions ) { | |||||||||||||||||||||||||||||||||
| 290 | 40 | ▶ | my $action_type = $version ? 'Upgrade' : 'Install'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 291 | 40 | my $op = $action->{type}; | |||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||
| 293 | 40 | ▶ | if ( $action->{uninstall} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 294 | 1 | $action_type = 'Uninstall'; | |||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||
| 297 | 40 | ▶ | next VERSION if !$action_code{$op}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||
| 299 | 40 | ▶ | my $phase = $action->{phase} || $actions{ $action_type }; | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
$action->{'phase'} || $actions{$action_type}
MC/DC0%0/2
$action->{'phase'} || $actions{$action_type}
$action->{'phase'}
$actions{$action_type}
Truth table66%2/3
A || B
A= $action->{'phase'}B= $actions{$action_type}
| |||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||
| 301 | 40 | ▶ | if ( $op eq 'TableCreate' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 302 | 15 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 303 | 15 | $tables_to_delete{$table} = $table_counter++; | |||||||||||||||||||||||||||||||||
| 304 | 15 | $own_tables{$table} = 1; | |||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||
| 306 | elsif ( $op eq 'TableDrop' ) { | ||||||||||||||||||||||||||||||||||
| 307 | 0 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 308 | 0 | delete $tables_to_delete{$table}; | |||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||
| 311 | 40 | ▶ | if ( $op eq 'ColumnAdd' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 312 | 3 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 313 | 3 | ▶ | if ( !$own_tables{$table} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 314 | unshift @columns_to_delete, +{ | ||||||||||||||||||||||||||||||||||
| 315 | name => $table, | ||||||||||||||||||||||||||||||||||
| 316 | 2 | ▶ | columns => [ map { $_->{name} } @{ $action->{columns} || [] } ], | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'columns'} || []
MC/DC0%0/1
$action->{'columns'} || []
$action->{'columns'}
Truth table50%1/2
A
A= $action->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 317 | }; | ||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||
| 321 | 40 | $action->{version} = $version; | |||||||||||||||||||||||||||||||||
| 322 | 40 | push @{ $db_actions{$action_type}->{$phase} }, $action_code{$op}->($action); | |||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||
| 326 | 33 | for my $columns_delete ( @columns_to_delete ) { | |||||||||||||||||||||||||||||||||
| 327 | 1 | push @{ $db_actions{Uninstall}->{pre} }, _ColumnDrop($columns_delete); | |||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||
| 330 | 33 | ▶ | if ( %tables_to_delete ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 331 | 11 | for my $table ( sort { $tables_to_delete{$b} <=> $tables_to_delete{$a} }keys %tables_to_delete ) { | |||||||||||||||||||||||||||||||||
| 332 | 14 | push @{ $db_actions{Uninstall}->{pre} }, _TableDrop({ name => $table }); | |||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | 33 | for my $action_type ( qw/Install Upgrade Uninstall/ ) { | |||||||||||||||||||||||||||||||||
| 337 | 99 | for my $phase ( qw/pre post/ ) { | |||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||
| 339 | 198 | ▶ | next if !$db_actions{$action_type}->{$phase}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||
| 341 | push @xml_parts, | ||||||||||||||||||||||||||||||||||
| 342 | sprintf qq~ <Database$action_type Type="$phase"> | ||||||||||||||||||||||||||||||||||
| 343 | %s | ||||||||||||||||||||||||||||||||||
| 344 | 34 | </Database$action_type>~, join "\n", @{ $db_actions{$action_type}->{$phase} }; | |||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||
| 348 | CODE: | ||||||||||||||||||||||||||||||||||
| 349 | 33 | ▶ | for my $code ( @{ $json->{code} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$json->{'code'} || []
MC/DC100%1/1
$json->{'code'} || []
$json->{'code'}
Truth table100%2/2
A
A= $json->{'code'}
| |||||||||||||||||||||||||||||||||||
| 350 | 30 | ▶ | if ( !ref $code ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 351 | 4 | ▶ | $code = { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 352 | type => $code, | ||||||||||||||||||||||||||||||||||
| 353 | version => 0, | ||||||||||||||||||||||||||||||||||
| 354 | phase => ( $code eq 'Uninstall' ? 'pre' : 'post' ), | ||||||||||||||||||||||||||||||||||
| 355 | }; | ||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||
| 358 | 30 | $code->{type} = 'Code' . $code->{type}; | |||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||
| 360 | 30 | ▶ | if ( $code->{inline} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 361 | 1 | push @xml_parts, _InlineCode( $code ); | |||||||||||||||||||||||||||||||||
| 362 | 1 | next CODE; | |||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||
| 365 | push @xml_parts, $utils->packagesetup( | ||||||||||||||||||||||||||||||||||
| 366 | $code->{type}, | ||||||||||||||||||||||||||||||||||
| 367 | $code->{version}, | ||||||||||||||||||||||||||||||||||
| 368 | $code->{function} || $code->{type}, | ||||||||||||||||||||||||||||||||||
| 369 | $code->{phase}, | ||||||||||||||||||||||||||||||||||
| 370 | $code->{package}, | ||||||||||||||||||||||||||||||||||
| 371 | 29 | ▶ | ); | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
$code->{'function'} || $code->{'type'}
MC/DC0%0/2
$code->{'function'} || $code->{'type'}
$code->{'function'}
$code->{'type'}
Truth table66%2/3
A || B
A= $code->{'function'}B= $code->{'type'}
| |||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||
| 374 | 33 | ▶ | for my $intro ( @{ $json->{intro} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$json->{'intro'} || []
MC/DC100%1/1
$json->{'intro'} || []
$json->{'intro'}
Truth table100%2/2
A
A= $json->{'intro'}
| |||||||||||||||||||||||||||||||||||
| 375 | 2 | push @xml_parts, _IntroTemplate( $intro ); | |||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||
| 378 | 33 | my $cvs = ""; | |||||||||||||||||||||||||||||||||
| 379 | 33 | ▶ | if ( $opt->{cvs} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 380 | 1 | $cvs = sprintf qq~\n <CVS>\$Id: %s.sopm,v 1.1.1.1 2011/04/15 07:49:58 rb Exp \$</CVS>~, $name; | |||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||
| 383 | 33 | my %product_start_tags = ( | |||||||||||||||||||||||||||||||||
| 384 | OTRS => 'otrs_package', | ||||||||||||||||||||||||||||||||||
| 385 | KIX => 'otrs_package', | ||||||||||||||||||||||||||||||||||
| 386 | OTOBO => 'otobo_package', | ||||||||||||||||||||||||||||||||||
| 387 | ); | ||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||
| 389 | 33 | my $start_tag = $product_start_tags{$product}; | |||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||
| 391 | my $xml = sprintf q~<?xml version="1.0" encoding="utf-8" ?> | ||||||||||||||||||||||||||||||||||
| 392 | <%s version="1.0"> | ||||||||||||||||||||||||||||||||||
| 393 | <!-- GENERATED WITH OPM::Maker::Command::sopm (%s) -->%s | ||||||||||||||||||||||||||||||||||
| 394 | <Name>%s</Name> | ||||||||||||||||||||||||||||||||||
| 395 | <Version>%s</Version> | ||||||||||||||||||||||||||||||||||
| 396 | %s | ||||||||||||||||||||||||||||||||||
| 397 | </%s> | ||||||||||||||||||||||||||||||||||
| 398 | ~, | ||||||||||||||||||||||||||||||||||
| 399 | $start_tag, | ||||||||||||||||||||||||||||||||||
| 400 | __PACKAGE__->VERSION(), | ||||||||||||||||||||||||||||||||||
| 401 | $cvs, | ||||||||||||||||||||||||||||||||||
| 402 | $name, | ||||||||||||||||||||||||||||||||||
| 403 | $json->{version}, | ||||||||||||||||||||||||||||||||||
| 404 | 33 | join( "\n", @xml_parts ), | |||||||||||||||||||||||||||||||||
| 405 | $start_tag; | ||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||
| 407 | 33 | ▶ | my $fh = IO::File->new( $name . '.sopm', 'w' ) or die $!; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 408 | 33 | $fh->print( $xml ); | |||||||||||||||||||||||||||||||||
| 409 | 33 | $fh->close; | |||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||
| 412 | 1 | ▶ | sub _InlineCode { | ||||||||||||||||||||||||||||||||
|
Subroutine
_InlineCode: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||
| 413 | 1 | my ($code) = @_; | |||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||
| 415 | 1 | my @parts = split /::/, $code->{inline}; | |||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||
| 417 | 1 | my $method = pop @parts; | |||||||||||||||||||||||||||||||||
| 418 | 1 | $parts[-1] .= '.pm'; | |||||||||||||||||||||||||||||||||
| 419 | 1 | my $file = Path::Class::File->new( @parts ); | |||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||
| 421 | 1 | my $content = $file->slurp( iomode => '<:encoding(utf-8)' ); | |||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||
| 423 | 1 | my ($method_body) = $content =~ m{ | |||||||||||||||||||||||||||||||||
| 424 | ^sub \s+ \Q$method\E \s* \{ \s+ | ||||||||||||||||||||||||||||||||||
| 425 | (.*?) | ||||||||||||||||||||||||||||||||||
| 426 | ^\}\s+ | ||||||||||||||||||||||||||||||||||
| 427 | }xms; | ||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||
| 429 | my $version = $code->{version} ? | ||||||||||||||||||||||||||||||||||
| 430 | 1 | ▶ | ' Version="' . $code->{version} . '"' : | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 431 | ''; | ||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | my $xml = sprintf q~ <%s Type="%s"%s><![CDATA[ | ||||||||||||||||||||||||||||||||||
| 434 | %s | ||||||||||||||||||||||||||||||||||
| 435 | 1 | ▶ | ]]></%s>~, $code->{type}, $code->{phase} // 'post', $version, $method_body, $code->{type}; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$code->{"phase"} // "post"
MC/DC0%0/1
$code->{"phase"} // "post"
$code->{"phase"}
Truth table50%1/2
A
A= $code->{"phase"}
| |||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||
| 437 | 1 | return $xml; | |||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||
| 440 | 2 | ▶ | sub _IntroTemplate { | ||||||||||||||||||||||||||||||||
|
Subroutine
_IntroTemplate: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 441 | 2 | my ($intro) = @_; | |||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||
| 443 | 2 | ▶ | my $version = $intro->{version} ? ' Version="' . $intro->{version} . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 444 | 2 | my $type = $intro->{type}; | |||||||||||||||||||||||||||||||||
| 445 | 2 | ▶ | my $text = ref $intro->{text} ? join( "<br />\n", @{ $intro->{text} } ) : $intro->{text}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 446 | 2 | ▶ | my $phase = $intro->{time} || "post"; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$intro->{'time'} || 'post'
MC/DC100%1/1
$intro->{'time'} || 'post'
$intro->{'time'}
Truth table100%2/2
A
A= $intro->{'time'}
| |||||||||||||||||||||||||||||||||||
| 447 | 2 | ▶ | my $lang = $intro->{lang} ? ' Lang="' . $intro->{lang} . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 448 | 2 | ▶ | my $title = $intro->{title} ? ' Title="' . $intro->{title} . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||
| 450 | 2 | return qq~ <Intro$type Type="$phase"$lang$title$version><![CDATA[ | |||||||||||||||||||||||||||||||||
| 451 | $text | ||||||||||||||||||||||||||||||||||
| 452 | ]]></Intro$type>~; | ||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||
| 455 | 16 | ▶ | sub _Insert { | ||||||||||||||||||||||||||||||||
|
Subroutine
_Insert: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||
| 456 | 16 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||
| 459 | 16 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 460 | 16 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||
| 462 | 16 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||
| 464 | 16 | my $string = ' <Insert Table="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||
| 466 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 467 | 16 | ▶ | for my $column ( @{ $action->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'columns'} || []
MC/DC0%0/1
$action->{'columns'} || []
$action->{'columns'}
Truth table50%1/2
A
A= $action->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 468 | 112 | ▶ | my $value = ref $column->{value} ? join( "\n", @{ $column->{value} } ) : $column->{value}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 469 | 112 | ▶ | $value //= ''; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$value //= ""
MC/DC0%0/1
$value //= ""
$value
Truth table50%1/2
A
A= $value
| |||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||
| 471 | $string .= sprintf ' <Data Key="%s"%s>%s</Data>' . "\n", | ||||||||||||||||||||||||||||||||||
| 472 | $column->{name}, | ||||||||||||||||||||||||||||||||||
| 473 | ( $column->{type} ? | ||||||||||||||||||||||||||||||||||
| 474 | 112 | ▶ | (' Type="' . $column->{type} . '"', '<![CDATA[' . $value . ']]>' ) : | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 475 | ("", $value) | ||||||||||||||||||||||||||||||||||
| 476 | ); | ||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||
| 479 | 16 | $string .= ' </Insert>'; | |||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||
| 481 | 16 | return $string; | |||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||
| 484 | 14 | ▶ | sub _TableDrop { | ||||||||||||||||||||||||||||||||
|
Subroutine
_TableDrop: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 485 | 14 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||
| 487 | 14 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||
| 489 | 14 | return ' <TableDrop Name="' . $table . '" />'; | |||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||
| 492 | 15 | ▶ | sub _TableCreate { | ||||||||||||||||||||||||||||||||
|
Subroutine
_TableCreate: called CC=17 SCAR=28.6
| |||||||||||||||||||||||||||||||||||
| 493 | 15 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||
| 495 | 15 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 496 | 15 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||
| 498 | 15 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||
| 500 | 15 | my $string = ' <TableCreate Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||
| 502 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 503 | 15 | ▶ | for my $column ( @{ $action->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'columns'} || []
MC/DC0%0/1
$action->{'columns'} || []
$action->{'columns'}
Truth table50%1/2
A
A= $action->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 504 | 43 | my $type = _TypeCheck( $column->{type}, 'TableCreate' ); | |||||||||||||||||||||||||||||||||
| 505 | $string .= sprintf ' <Column Name="%s" Required="%s" Type="%s"%s%s%s />' . "\n", | ||||||||||||||||||||||||||||||||||
| 506 | $column->{name}, | ||||||||||||||||||||||||||||||||||
| 507 | $column->{required}, | ||||||||||||||||||||||||||||||||||
| 508 | $type, | ||||||||||||||||||||||||||||||||||
| 509 | ( $column->{size} ? ' Size="' . $column->{size} . '"' : "" ), | ||||||||||||||||||||||||||||||||||
| 510 | ( $column->{auto_increment} ? ' AutoIncrement="true"' : "" ), | ||||||||||||||||||||||||||||||||||
| 511 | 42 | ▶ | ( $column->{primary_key} ? ' PrimaryKey="true"' : "" ), | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||
| 514 | UNIQUE: | ||||||||||||||||||||||||||||||||||
| 515 | 14 | ▶ | for my $unique ( @{ $action->{unique} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$action->{'unique'} || []
MC/DC100%1/1
$action->{'unique'} || []
$action->{'unique'}
Truth table100%2/2
A
A= $action->{'unique'}
| |||||||||||||||||||||||||||||||||||
| 516 | 4 | my $table = $unique->{name}; | |||||||||||||||||||||||||||||||||
| 517 | 4 | ▶ | $string .= ' <Unique Name="' . ($unique->{id} || join( "_", @{$unique->{columns} || ["unique$table"] } ) ) . '">' . "\n"; | ||||||||||||||||||||||||||||||||
|
Condition60%3/5
$unique->{'id'} || join('_', @{$unique->{'columns'} or ["unique$table"];})
$unique->{'columns'} || ["unique$table"]
MC/DC0%0/2
$unique->{'id'} || join('_', @{$unique->{'columns'} or ["unique$table"];})
$unique->{'id'}
join('_', @{$unique->{'columns'} or ["unique$table"];})
MC/DC0%0/1
$unique->{'columns'} || ["unique$table"]
$unique->{'columns'}
Truth table66%2/3
A || B
A= $unique->{'id'}B= join('_', @{$unique->{'columns'} or ["unique$table"];})
Truth table50%1/2
A
A= $unique->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||
| 519 | 4 | ▶ | for my $column ( @{ $unique->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$unique->{'columns'} || []
MC/DC0%0/1
$unique->{'columns'} || []
$unique->{'columns'}
Truth table50%1/2
A
A= $unique->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 520 | 8 | $string .= ' <UniqueColumn Name="' . $column . '" />' . "\n"; | |||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||
| 523 | 4 | $string .= ' </Unique>' . "\n"; | |||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||
| 526 | KEY: | ||||||||||||||||||||||||||||||||||
| 527 | 14 | ▶ | for my $key ( @{ $action->{keys} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$action->{'keys'} || []
MC/DC100%1/1
$action->{'keys'} || []
$action->{'keys'}
Truth table100%2/2
A
A= $action->{'keys'}
| |||||||||||||||||||||||||||||||||||
| 528 | 10 | my $table = $key->{name}; | |||||||||||||||||||||||||||||||||
| 529 | 10 | $string .= ' <ForeignKey ForeignTable="' . $table . '">' . "\n"; | |||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||
| 531 | 10 | ▶ | for my $reference ( @{ $key->{references} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$key->{'references'} || []
MC/DC0%0/1
$key->{'references'} || []
$key->{'references'}
Truth table50%1/2
A
A= $key->{'references'}
| |||||||||||||||||||||||||||||||||||
| 532 | 10 | my $local = $reference->{local}; | |||||||||||||||||||||||||||||||||
| 533 | 10 | my $foreign = $reference->{foreign}; | |||||||||||||||||||||||||||||||||
| 534 | 10 | $string .= ' <Reference Local="' . $local . '" Foreign="' . $foreign . '" />' . "\n"; | |||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||
| 537 | 10 | $string .= ' </ForeignKey>' . "\n"; | |||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||
| 540 | 14 | $string .= ' </TableCreate>'; | |||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||
| 542 | 14 | return $string; | |||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||
| 545 | 3 | ▶ | sub _ColumnAdd { | ||||||||||||||||||||||||||||||||
|
Subroutine
_ColumnAdd: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||
| 546 | 3 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||
| 548 | 3 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 549 | 3 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||
| 551 | 3 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||
| 553 | 3 | my $string = ' <TableAlter Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||
| 555 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 556 | 3 | ▶ | for my $column ( @{ $action->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'columns'} || []
MC/DC0%0/1
$action->{'columns'} || []
$action->{'columns'}
Truth table50%1/2
A
A= $action->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 557 | 3 | my $type = _TypeCheck( $column->{type}, 'ColumnAdd' ); | |||||||||||||||||||||||||||||||||
| 558 | $string .= sprintf ' <ColumnAdd Name="%s" Required="%s" Type="%s"%s%s%s />' . "\n", | ||||||||||||||||||||||||||||||||||
| 559 | $column->{name}, | ||||||||||||||||||||||||||||||||||
| 560 | $column->{required}, | ||||||||||||||||||||||||||||||||||
| 561 | $type, | ||||||||||||||||||||||||||||||||||
| 562 | ( $column->{size} ? ' Size="' . $column->{size} . '"' : "" ), | ||||||||||||||||||||||||||||||||||
| 563 | ( $column->{auto_increment} ? ' AutoIncrement="true"' : "" ), | ||||||||||||||||||||||||||||||||||
| 564 | 2 | ▶ | ( $column->{primary_key} ? ' PrimaryKey="true"' : "" ), | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||
| 567 | 2 | $string .= ' </TableAlter>'; | |||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||
| 569 | 2 | return $string; | |||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||
| 572 | 2 | ▶ | sub _ColumnDrop { | ||||||||||||||||||||||||||||||||
|
Subroutine
_ColumnDrop: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||
| 573 | 2 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||
| 575 | 2 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 576 | 2 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||
| 578 | 2 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||
| 580 | 2 | my $string = ' <TableAlter Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||
| 582 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 583 | 2 | ▶ | for my $column ( @{ $action->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'columns'} || []
MC/DC0%0/1
$action->{'columns'} || []
$action->{'columns'}
Truth table50%1/2
A
A= $action->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 584 | 2 | $string .= sprintf qq~ <ColumnDrop Name="%s" />\n~, $column; | |||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||
| 587 | 2 | $string .= ' </TableAlter>'; | |||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||
| 589 | 2 | return $string; | |||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||
| 592 | 1 | ▶ | sub _ForeignKeyCreate { | ||||||||||||||||||||||||||||||||
|
Subroutine
_ForeignKeyCreate: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||
| 593 | 1 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||
| 595 | 1 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 596 | 1 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||
| 598 | 1 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||
| 600 | 1 | my $string = ' <TableAlter Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||
| 602 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 603 | 1 | ▶ | for my $reference ( @{ $action->{references} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'references'} || []
MC/DC0%0/1
$action->{'references'} || []
$action->{'references'}
Truth table50%1/2
A
A= $action->{'references'}
| |||||||||||||||||||||||||||||||||||
| 604 | $string .= sprintf ' <ForeignKeyCreate ForeignTable="%s"> | ||||||||||||||||||||||||||||||||||
| 605 | <Reference Local="%s" Foreign="%s" /> | ||||||||||||||||||||||||||||||||||
| 606 | </ForeignKeyCreate>' . "\n", | ||||||||||||||||||||||||||||||||||
| 607 | $reference->{name}, | ||||||||||||||||||||||||||||||||||
| 608 | $reference->{local}, | ||||||||||||||||||||||||||||||||||
| 609 | 2 | $reference->{foreign}; | |||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||
| 612 | 1 | $string .= ' </TableAlter>'; | |||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||
| 614 | 1 | return $string; | |||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||
| 617 | 1 | ▶ | sub _ForeignKeyDrop { | ||||||||||||||||||||||||||||||||
|
Subroutine
_ForeignKeyDrop: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||
| 618 | 1 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||
| 620 | 1 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 621 | 1 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||
| 623 | 1 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||
| 625 | 1 | my $string = ' <TableAlter Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||
| 627 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 628 | 1 | ▶ | for my $reference ( @{ $action->{references} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'references'} || []
MC/DC0%0/1
$action->{'references'} || []
$action->{'references'}
Truth table50%1/2
A
A= $action->{'references'}
| |||||||||||||||||||||||||||||||||||
| 629 | $string .= sprintf ' <ForeignKeyDrop ForeignTable="%s"> | ||||||||||||||||||||||||||||||||||
| 630 | <Reference Local="%s" Foreign="%s" /> | ||||||||||||||||||||||||||||||||||
| 631 | </ForeignKeyDrop>' . "\n", | ||||||||||||||||||||||||||||||||||
| 632 | $reference->{name}, | ||||||||||||||||||||||||||||||||||
| 633 | $reference->{local}, | ||||||||||||||||||||||||||||||||||
| 634 | 2 | $reference->{foreign}; | |||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||
| 637 | 1 | $string .= ' </TableAlter>'; | |||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||
| 639 | 1 | return $string; | |||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||
| 642 | 1 | ▶ | sub _UniqueCreate { | ||||||||||||||||||||||||||||||||
|
Subroutine
_UniqueCreate: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||
| 643 | 1 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||
| 645 | 1 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 646 | 1 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||
| 648 | 1 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||
| 650 | 1 | my $string = ' <TableAlter Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 651 | 1 | $string .= sprintf qq~ <UniqueCreate Name="%s">\n~, $action->{unique_name}; | |||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||
| 653 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 654 | 1 | ▶ | for my $column ( @{ $action->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'columns'} || []
MC/DC0%0/1
$action->{'columns'} || []
$action->{'columns'}
Truth table50%1/2
A
A= $action->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 655 | 2 | $string .= sprintf qq~ <UniqueColumn Name="%s" />\n~, | |||||||||||||||||||||||||||||||||
| 656 | $column; | ||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||
| 659 | 1 | $string .= qq~ </UniqueCreate>\n~; | |||||||||||||||||||||||||||||||||
| 660 | 1 | $string .= ' </TableAlter>'; | |||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||
| 662 | 1 | return $string; | |||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||
| 665 | 1 | ▶ | sub _UniqueDrop { | ||||||||||||||||||||||||||||||||
|
Subroutine
_UniqueDrop: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||
| 666 | 1 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||
| 668 | 1 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 669 | 1 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||
| 671 | 1 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||
| 673 | 1 | my $string = ' <TableAlter Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||
| 675 | $string .= sprintf qq~ <UniqueDrop Name="%s" />\n~, | ||||||||||||||||||||||||||||||||||
| 676 | 1 | $action->{unique_name}; | |||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||
| 678 | 1 | $string .= ' </TableAlter>'; | |||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||
| 680 | 1 | return $string; | |||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||
| 683 | 1 | ▶ | sub _ColumnChange { | ||||||||||||||||||||||||||||||||
|
Subroutine
_ColumnChange: called CC=7 SCAR=26.4
| |||||||||||||||||||||||||||||||||||
| 684 | 1 | my ($action) = @_; | |||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||
| 686 | 1 | my $table = $action->{name}; | |||||||||||||||||||||||||||||||||
| 687 | 1 | my $version = $action->{version}; | |||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||
| 689 | 1 | ▶ | my $version_string = $version ? ' Version="' . $version . '"' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||
| 691 | 1 | my $string = ' <TableAlter Name="' . $table . '"' . $version_string . ">\n"; | |||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||
| 693 | COLUMN: | ||||||||||||||||||||||||||||||||||
| 694 | 1 | ▶ | for my $column ( @{ $action->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$action->{'columns'} || []
MC/DC0%0/1
$action->{'columns'} || []
$action->{'columns'}
Truth table50%1/2
A
A= $action->{'columns'}
| |||||||||||||||||||||||||||||||||||
| 695 | 1 | my $type = _TypeCheck( $column->{type}, 'ColumnChange' ); | |||||||||||||||||||||||||||||||||
| 696 | $string .= sprintf ' <ColumnChange NameNew="%s" NameOld="%s" Required="%s" Type="%s"%s%s%s />' . "\n", | ||||||||||||||||||||||||||||||||||
| 697 | $column->{new_name}, | ||||||||||||||||||||||||||||||||||
| 698 | $column->{old_name}, | ||||||||||||||||||||||||||||||||||
| 699 | $column->{required}, | ||||||||||||||||||||||||||||||||||
| 700 | $type, | ||||||||||||||||||||||||||||||||||
| 701 | ( $column->{size} ? ' Size="' . $column->{size} . '"' : "" ), | ||||||||||||||||||||||||||||||||||
| 702 | ( $column->{auto_increment} ? ' AutoIncrement="true"' : "" ), | ||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | ( $column->{primary_key} ? ' PrimaryKey="true"' : "" ), | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||
| 706 | 0 | $string .= ' </TableAlter>'; | |||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||
| 708 | 0 | return $string; | |||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||
| 711 | 47 | ▶ | sub _TypeCheck { | ||||||||||||||||||||||||||||||||
|
Subroutine
_TypeCheck: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 712 | 47 | my ($type, $action) = @_; | |||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||
| 714 | 47 | my %types = ( | |||||||||||||||||||||||||||||||||
| 715 | DATE => 1, | ||||||||||||||||||||||||||||||||||
| 716 | SMALLINT => 1, | ||||||||||||||||||||||||||||||||||
| 717 | BIGINT => 1, | ||||||||||||||||||||||||||||||||||
| 718 | INTEGER => 1, | ||||||||||||||||||||||||||||||||||
| 719 | DECIMAL => 1, | ||||||||||||||||||||||||||||||||||
| 720 | VARCHAR => 1, | ||||||||||||||||||||||||||||||||||
| 721 | LONGBLOB => 1, | ||||||||||||||||||||||||||||||||||
| 722 | ); | ||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||
| 724 | 47 | ▶ | if ( !$types{$type} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 725 | 3 | croak "$type is not allowed in $action. Allowed types: ", join ', ', sort keys %types; | |||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||
| 728 | 44 | return $type; | |||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||
| 731 | 33 | ▶ | sub VERSION { | ||||||||||||||||||||||||||||||||
|
Subroutine
VERSION: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 732 | 33 | ▶ | return $OPM::Maker::Command::sopm::VERSION || '1.0.0'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$OPM::Maker::Command::sopm::VERSION || '1.0.0'
MC/DC0%0/1
$OPM::Maker::Command::sopm::VERSION || '1.0.0'
$OPM::Maker::Command::sopm::VERSION
Truth table50%1/2
A
A= $OPM::Maker::Command::sopm::VERSION
| |||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||
| 735 | 33 | 1; | |||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||
| 737 | __END__ | ||||||||||||||||||||||||||||||||||