lib/Rex/Apache/Build/tgz.pm

filter: Statementstmt 39.2% 22 / 56 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 32.5% 29 / 89 CC 9 SCAR 32.4
CC
9
Cov
30%
build
56.0
new
12.0
BEGIN
1.0
CRAP 25.6
« lib/Rex/Apache/Inject/Command.pm ↑ Summary lib/Rex/Apache/Deploy/Tomcat7.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4 # vim: set ts=2 sw=2 tw=0:
5 # vim: set expandtab:
6  
7 =head1 NAME
8  
9 Rex::Apache::Build::tgz - Build tgz packages
10  
11 =head1 DESCRIPTION
12  
13 With this module you can build TGZ packages to distribute your application.
14  
15 =head1 SYNOPSIS
16  
17 build "my-software",
18 type => "tgz",
19 version => "1.0",
20 source => "/path/to/your/software",
21 # below this, it is all optional
22 exclude => [qw/file1 file2/];
23  
24  
25 =cut
26  
27  
28 package Rex::Apache::Build::tgz;
29  
30 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 1 ▶use Cwd qw(getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use Rex -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶use Rex::Apache::Build::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use base qw(Rex::Apache::Build::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
41 0 my $that = shift;
42 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
43 0 my $self = $proto->SUPER::new(@_);
44  
45 0 bless($self, $proto);
46  
47 # compatibility for < 0.11
48 0 ▶ if($self->{source} eq ".") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"source"} eq ".") 0 0 0
49 0 $self->{source} = undef;
50 0 delete $self->{source};
51 }
52  
53 0 $self->{exclude} = [".git", ".svn", ".*.sw*", "*~", "yuicompressor.jar", "._yuicompressor.jar"];
54  
55 0 return $self;
56 }
57  
58 0 ▶sub build {
Subroutine build: not called CC=7 SCAR=40.3
Pod undocumented
59 0 my ($self, $name) = @_;
60  
61 0 ▶ $name ||= $self->{name};
Condition0%0/3
$name ||= $self->{"name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$name ||= $self->{"name"}
$name $self->{"name"}
Truth table0%0/3
A ||= B
A= $nameB= $self->{"name"}
ABresult
1X1
011
000
62  
63 0 my $old_dir = getcwd();
64  
65 0 my $excludes = "";
66 0 ▶ if(exists $self->{exclude}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"exclude"}) 0 0 0
67 0 ▶ if($^O =~ m/^MSWin/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /^MSWin/) { } 0 0 0
68 0 $excludes = " --exclude \"" . join("\" --exclude \"", @{$self->{exclude}}) . "\"";
69 }
70 else {
71 0 $excludes = " --exclude '" . join("' --exclude '", @{$self->{exclude}}) . "'";
72 }
73 }
74  
75 0 my $version = $self->version;
76  
77 0 my $dir = getcwd();
78  
79 # compatibility for < 0.11 versions
80 0 ▶ if(exists $self->{path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"path"}) 0 0 0
81 0 $dir = $self->{path};
82 }
83  
84 # if source is present, this will overwrite path parameter
85 # because path can also be used in deploy() with an other meaning (prefix)
86 0 ▶ if(exists $self->{source}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"source"}) 0 0 0
87 0 $dir = $self->{source};
88 }
89  
90 0 chdir($dir);
91  
92 0 my $package_name = "$name-$version.tar.gz";
93  
94 0 Rex::Logger::info("Building: $package_name");
95 0 ▶ if($^O =~ m/^MSWin/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /^MSWin/i) { } 0 0 0
96 0 run "tar -c $excludes --exclude \"$name-*.tar.gz\" --exclude \".*.sw*\" --exclude \"*~\" --exclude Rexfile.lock --exclude Rexfile --exclude $package_name -z -f $old_dir/$package_name .";
97 }
98 else {
99 0 run "tar -c $excludes --exclude '$name-*.tar.gz' --exclude '.*.sw*' --exclude '*~' --exclude Rexfile.lock --exclude Rexfile --exclude $package_name -z -f $old_dir/$package_name .";
100 }
101 0 Rex::Logger::info("Your build is now available: $name-$version.tar.gz");
102  
103 0 chdir($old_dir);
104  
105 0 return $package_name;
106 }
107  
108 1 1;
« lib/Rex/Apache/Inject/Command.pm ↑ Summary lib/Rex/Apache/Deploy/Tomcat7.pm »