WebEditor/OldFeatures/CustomPublish.pm

filter: Statementstmt 23.6% 18 / 76 Branchbran 2.5% 1 / 40 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 1 totaltotal 16.8% 25 / 148 CC 29 SCAR 56.3
CC
29
Cov
15%
__ANON__
462.0
do_publish
48.5
BEGIN
6.8
CRAP 279.6
« WebEditor/OldFeatures/MakeHTML.pm ↑ Summary WebEditor/OldFeatures/SystemInfo.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: CustomPublish.pm,v 1.3 2004/06/07 06:58:55 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2004 Slaven Rezic. All rights reserved.
8 #
9  
10 package WebEditor::OldFeatures::CustomPublish;
11  
12 # This serves as a template for custom rsync-based publishing.
13  
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
17  
18 1 ▶use mixin::with 'WebEditor::OldController';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=19.2
21 1 ▶ if ($] < 5.006) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.006") 0 1 1
22 0 $INC{"warnings.pm"}++;
23 0 eval q{
24 package warnings;
25 sub unimport { }
26 0 ▶ }; die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
27 }
28 }
29  
30 0 ▶sub do_publish {
Subroutine do_publish: not called CC=7 SCAR=38.8
Pod undocumented
31 0 my($self, %args) = @_;
32  
33 0 require File::Basename;
34 0 require File::Spec;
35 0 require File::Find;
36 0 require File::Temp;
37  
38 1 ▶ no warnings; # # in qw()
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 0 my $c = $self->C;
41 0 ▶ my $v = delete $args{-verbose} || 0;
Condition0%0/2
delete $args{'-verbose'} || 0
l!l
00
MC/DC0%0/1
delete $args{'-verbose'} || 0
delete $args{'-verbose'}
Truth table0%0/2
A
A= delete $args{'-verbose'}
Aresult
11
00
42  
43 0 my @files;
44  
45 0 my $rootdir = $c->paths->uprootdir;
46 0 my $projectname = $c->project->name;
47  
48 0 my $dbg = 1;
49  
50 # Can't use "follow => 1", because this will skip files if they
51 # are already listed though their symlink. However, the semantics of
52 # follow_fast is not totally clear.
53 File::Find::find({follow_fast => 1, # needed for common/perl
54 follow_skip => 2, # do not die on duplicates
55 0 ▶ wanted => sub {
Subroutine __ANON__: not called CC=21 SCAR=61.4
56 0 ▶ $File::Find::prune = 1, return if $_ =~ m{^( core\..*
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /^( core\..* | \.core | \#.* | \.\#.* | ,.* | \.cvsignore | \.AppleDouble | .*\.bak | .*~ )$/x 0 0 0
57 | \.core
58 | \#.*
59 | \.\#.*
60 | ,.*
61 | \.cvsignore
62 | \.AppleDouble
63 | .*\.bak
64 | .*~
65 )$}x;
66 0 ▶ return if -d $_;
Branch: 1 branch
BranchTrueFalseTotal
if -d $_ 0 0 0
67 0 my $path = substr($File::Find::name, length($rootdir)+1);
68 0 ▶ print STDERR "$path " if $dbg;
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
69 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
unless ($path =~ m[^( cgi-bin/ | etc/ | lib/ | htdocs/ | we_data/ | conf/ | common/ )]x) 0 0 0
70 0 $File::Find::prune = 1;
71 0 goto CLEANUP;
72 } if $path !~ m{^( cgi-bin/
73 | etc/
74 | lib/
75 | htdocs/
76 | we_data/
77 | conf/
78 | common/
79 )}x;
80 0 ▶ print STDERR "1" if $dbg;
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
81 0 ▶ goto CLEANUP if $path =~ m{( ^htdocs/index\.html$
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[( ^htdocs/index\.html$ | ^cgi-bin/we_redisys\.cgi$ | ^cgi-bin/WEsiteinfo_$projectname\.pm$ | ^cgi-bin/WEsiteinfo\.pm$ )]x 0 0 0
82 | ^cgi-bin/we_redisys\.cgi$
83 | ^cgi-bin/WEsiteinfo_$projectname\.pm$
84 | ^cgi-bin/WEsiteinfo\.pm$
85 )}x;
86 0 ▶ print STDERR "2" if $dbg;
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
87 0 ▶ goto CLEANUP if ($path =~ m{^htdocs/we/} &&
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[^htdocs/we/] and not $path =~ m[^htdocs/we/${projectname}_templates/search_result] 0 0 0
Condition0%0/3
$path =~ m[^htdocs/we/] and not $path =~ m[^htdocs/we/${projectname}_templates/search_result]
!ll&&!rl&&r
000
MC/DC0%0/2
$path =~ m[^htdocs/we/] and not $path =~ m[^htdocs/we/${projectname}_templates/search_result]
$path =~ m[^htdocs/we/] not $path =~ m[^htdocs/we/${projectname}_templates/search_result]
Truth table0%0/3
A and not(B)
A= $path =~ m[^htdocs/we/]B= not $path =~ m[^htdocs/we/${projectname}_templates/search_result]
ABresult
0X0
100
111
88 $path !~ m{^htdocs/we/${projectname}_templates/search_result});
89 0 ▶ print STDERR "3" if $dbg;
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
90 0 ▶ goto CLEANUP if ($path =~ m{^we_data/} &&
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[^we_data/] and not $path =~ m[^we_data/[^/]+\.db] 0 0 0
Condition0%0/3
$path =~ m[^we_data/] and not $path =~ m[^we_data/[^/]+\.db]
!ll&&!rl&&r
000
MC/DC0%0/2
$path =~ m[^we_data/] and not $path =~ m[^we_data/[^/]+\.db]
$path =~ m[^we_data/] not $path =~ m[^we_data/[^/]+\.db]
Truth table0%0/3
A and not(B)
A= $path =~ m[^we_data/]B= not $path =~ m[^we_data/[^/]+\.db]
ABresult
0X0
100
111
91 $path !~ m{^we_data/[^/]+\.db});
92 0 ▶ print STDERR "4" if $dbg;
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
93 0 ▶ goto CLEANUP if ($path =~ m{^conf/} &&
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[^conf/] and not $path =~ m[^conf/htdig\.tpl\.conf$] 0 0 0
Condition0%0/3
$path =~ m[^conf/] and not $path =~ m[^conf/htdig\.tpl\.conf$]
!ll&&!rl&&r
000
MC/DC0%0/2
$path =~ m[^conf/] and not $path =~ m[^conf/htdig\.tpl\.conf$]
$path =~ m[^conf/] not $path =~ m[^conf/htdig\.tpl\.conf$]
Truth table0%0/3
A and not(B)
A= $path =~ m[^conf/]B= not $path =~ m[^conf/htdig\.tpl\.conf$]
ABresult
0X0
100
111
94 $path !~ m{^conf/htdig\.tpl\.conf$});
95 0 ▶ print STDERR "5" if $dbg;
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
96 0 ▶ goto CLEANUP if ($path =~ m{^etc/} &&
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[^etc/] and not $path =~ m[^etc/run_indexer$] 0 0 0
Condition0%0/3
$path =~ m[^etc/] and not $path =~ m[^etc/run_indexer$]
!ll&&!rl&&r
000
MC/DC0%0/2
$path =~ m[^etc/] and not $path =~ m[^etc/run_indexer$]
$path =~ m[^etc/] not $path =~ m[^etc/run_indexer$]
Truth table0%0/3
A and not(B)
A= $path =~ m[^etc/]B= not $path =~ m[^etc/run_indexer$]
ABresult
0X0
100
111
97 $path !~ m{^etc/run_indexer$});
98 0 ▶ print STDERR "6" if $dbg;
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
99 0 push @files, $path;
100 0 ▶ CLEANUP:
Branch: 1 branch
BranchTrueFalseTotal
if $dbg 0 0 0
101 print STDERR "\n" if $dbg;
102 0 }}, $rootdir);
103  
104 0 my %dir;
105 0 for my $f (@files) {
106 0 my @dirs = File::Spec->splitdir($f);
107 0 pop @dirs;
108 0 for my $d_i (0 .. $#dirs) {
109 0 $dir{ File::Spec->catdir(@dirs[0 .. $d_i]) }++;
110 }
111 }
112  
113 0 my($fh, $file) = File::Temp::tempfile(SUFFIX => ".rsync.txt",
114 #UNLINK => 1,
115 );
116 0 print $fh join("\n", map { "/$_" } sort (keys(%dir), @files)), "\n";
117  
118 0 local $ENV{PATH} = "$ENV{PATH}:/usr/bin:/usr/local/bin";
119 1 ▶ no warnings 'qw'; # no perl 5.00503 compat here
Subroutine BEGIN: called CC=1 SCAR=0.0
120  
121 0 my @common_rsync_args =
122 (qw(rsync -rptgoD -vz --copy-unsafe-links),
123 "-e", "ssh",
124 );
125 0 my @common_exc =
126 qw(--cvs-exclude
127 --exclude core --exclude #* --exclude .#*
128 --exclude ,* --exclude .cvsignore
129 --exclude .AppleDouble/);
130 0 my @cmds =
131 (
132 {label => "HTML-Seiten, CGI-Skripte, Perl-Libraries, Datenbank, htdig-conf",
133 cmd => [@common_rsync_args, @common_exc,
134 ("--include-from=$file", "--exclude=**"),
135 $c->paths->uprootdir . "/",
136 $c->staging->host . ":" . File::Basename::dirname($c->staging->directory) . "/",
137 ]
138 },
139 );
140 0 for my $cmddef (@cmds) {
141 0 my $label = $cmddef->{label};
142 0 my @cmd = @{ $cmddef->{cmd} };
143 0 print "--- $label ---\n";
144 0 ▶ print "@cmd\n\n" if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
145 0 warn "@cmd\n";
146 0 system(@cmd);
147 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
148 0 warn "\n\nWarnung: es wurden Fehler bei der Übetragung festgestellt!\n";
149 }
150 }
151 }
152  
153 1 1;
154  
155 __END__
« WebEditor/OldFeatures/MakeHTML.pm ↑ Summary WebEditor/OldFeatures/SystemInfo.pm »