BBackupd.pm

filter: Statementstmt 40.4% 17 / 42 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 33.3% 5 / 15 Podpod 0.0% 0 / 9 totaltotal 22.2% 22 / 99 CC 12 SCAR 40.4
CC
12
Cov
25%
AUTOLOAD
132.0
new
6.0
getServerPidFile
2.0
CRAP 56.9
↑ Summary Accounts.pm »
1 #!/usr/bin/perl -w
2  
3 package BoxBackup::Config::BBackupd;
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Config::Scoped;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use vars '$AUTOLOAD';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 our $VERSION = v0.03;
10  
11 1 ▶use subs qw(getStoreHostName
Subroutine BEGIN: called CC=1 SCAR=0.0
12 setStoreHostName
13 getAccountNumber
14 setAccountNumber
15 getKeysFile
16 setKeysFile
17 getCertificateFile
18 setCertificateFile
19 getPrivateKeyFile
20 setPrivateKeyFile
21 getTrustedCAsFile
22 setTrustedCAsFile
23 getDataDirectory
24 setDataDirectory
25 getNotifyScript
26 setNotifyScript
27 getAutomaticBackup
28 setAutomaticBackup
29 getUpdateStoreInterval
30 setUpdateStoreInterval
31 getMinimumFileAge
32 setMinimumFileAge
33 getMaxUploadWait
34 setMaxUploadWait
35 getFileTrackingSizeThreshold
36 setFileTrackingSizeThreshold
37 getDiffingUploadSizeThreshold
38 setDiffingUploadSizeThreshold
39 getMaximumDiffingTime
40 setMaximumDiffingTime
41 getExtendedLogging
42 setExtendedLogging
43 getCommandSocket
44 setCommandSocket
45 1 );
46  
47 sub new
48 0 ▶{
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
49 0 my ($self, @args) = @_;
50 0 ▶ my $bbackupdFile = $args[0] || "/etc/box/bbackupd.conf";
Condition0%0/2
$args[0] || '/etc/box/bbackupd.conf'
l!l
00
MC/DC0%0/1
$args[0] || '/etc/box/bbackupd.conf'
$args[0]
Truth table0%0/2
A
A= $args[0]
Aresult
11
00
51  
52 0 my $parser = Config::Scoped->new( file => $bbackupdFile );
53  
54 0 $self = $parser->parse;
55  
56 0 return bless $self;
57  
58 }
59  
60 sub save
61 0 ▶{
Subroutine save: not called CC=1 SCAR=0.0
Pod undocumented
62 }
63  
64 sub getServerPidFile
65 0 ▶{
Subroutine getServerPidFile: not called CC=1 SCAR=6.9
Pod undocumented
66 # This is a bit of an odd man out, since there is a section
67 # wrapped around the PidFile, but there is no real chance of
68 # multiple 'Server' sections, at least not at this time.
69 0 my $self = shift;
70
71 0 return($self->{"Server"}{"PidFile"});
72
73 }
74  
75 sub setServerPidFile
76 0 ▶{
Subroutine setServerPidFile: not called CC=1 SCAR=6.9
Pod undocumented
77 # This is a bit of an odd man out, since there is a section
78 # wrapped around the PidFile, but there is no real chance of
79 # multiple 'Server' sections, at least not at this time.
80 0 my $self = shift;
81 0 my $pidFile = shift;
82
83 0 return($self->{"Server"}{"PidFile"} = shift);
84
85 }
86  
87  
88 # Shamelessly copied from Ben's distribution bbackupd.conf
89 #
90 # BackupLocations specifies which locations on disc should be backed up. Each
91 # directory is in the format
92 #
93 # name
94 # {
95 # Path = /path/of/directory
96 # (optional exclude directives)
97 # }
98 #
99 # 'name' is derived from the Path by the config script, but should merely be
100 # unique.
101 #
102 # The exclude directives are of the form
103 #
104 # [Exclude|AlwaysInclude][File|Dir][|sRegex] = regex or full pathname
105 #
106 # (The regex suffix is shown as 'sRegex' to make File or Dir plural)
107 #
108 # For example:
109 #
110 # ExcludeDir = /home/guest-user
111 # ExcludeFilesRegex = *.(mp3|MP3)$
112 # AlwaysIncludeFile = /home/username/veryimportant.mp3
113 #
114 # This excludes the directory /home/guest-user from the backup along with all mp3
115 # files, except one MP3 file in particular.
116 #
117 # In general, Exclude excludes a file or directory, unless the directory is
118 # explicitly mentioned in a AlwaysInclude directive.
119  
120  
121  
122  
123 sub getListOfBackupLocations
124 0 ▶{
Subroutine getListOfBackupLocations: not called CC=1 SCAR=0.0
Pod undocumented
125 }
126  
127 sub getBackupLocationPath
128 0 ▶{
Subroutine getBackupLocationPath: not called CC=1 SCAR=0.0
Pod undocumented
129 }
130  
131 sub setBackupLocationPath
132 0 ▶{
Subroutine setBackupLocationPath: not called CC=1 SCAR=0.0
Pod undocumented
133 }
134  
135 sub addBackupLocation
136 0 ▶{
Subroutine addBackupLocation: not called CC=1 SCAR=0.0
Pod undocumented
137 }
138  
139 sub removeBackupLocation
140 0 ▶{
Subroutine removeBackupLocation: not called CC=1 SCAR=0.0
Pod undocumented
141 }
142  
143 # The AUTOLOAD method handles all getters and setters.
144 #
145 # It's a little hairy, because it also handles getters/setters
146 # for the 'BackupLocations' sections.
147 sub AUTOLOAD
148 0 ▶{
Subroutine AUTOLOAD: not called CC=11 SCAR=48.8
149 0 my $self = shift;
150
151 0 ▶ croak "$self not an object" unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
152
153 0 ▶ return if $AUTOLOAD =~ /::DESTROY$/;
Branch: 1 branch
BranchTrueFalseTotal
if $BoxBackup::Config::BBackupd::AUTOLOAD =~ /::DESTROY$/ 0 0 0
154
155 0 ▶ if($AUTOLOAD =~ /.*::get(\w+)/) # this is a getter
Branch: 1 branch
BranchTrueFalseTotal
if ($BoxBackup::Config::BBackupd::AUTOLOAD =~ /.*::get(\w+)/) 0 0 0
156 {
157 0 my $name = $1;
158 # For the 'BackupLocations' section we have to get the location
159 # in question, before we know which parameter value to get.
160 0 ▶ if($name =~ /AlwaysInclude/ || $name =~ /Exclude/ || $name =~ /Path/)
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /AlwaysInclude/ or $name =~ /Exclude/ or $name =~ /Path/) { } 0 0 0
Condition0%0/6
$name =~ /AlwaysInclude/ or $name =~ /Exclude/ or $name =~ /Path/
l!l&&r!l&&!r
000
$name =~ /AlwaysInclude/ or $name =~ /Exclude/
l!l&&r!l&&!r
000
MC/DC0%0/3
$name =~ /AlwaysInclude/ or $name =~ /Exclude/ or $name =~ /Path/
$name =~ /AlwaysInclude/ $name =~ /Exclude/ $name =~ /Path/
Truth table0%0/4
A or B or C
A= $name =~ /AlwaysInclude/B= $name =~ /Exclude/C= $name =~ /Path/
ABCresult
1XX1
01X1
0011
0000
161 {
162 0 my $backupLocation = shift;
163 0 return($self->{"BackupLocations"}{$backupLocation}{$name});
164 }
165 else
166 {
167 0 return($self->{$name});
168 }
169 }
170
171 0 ▶ if($AUTOLOAD =~ /.*::set(\w+)/) # this is a setter
Branch: 1 branch
BranchTrueFalseTotal
if ($BoxBackup::Config::BBackupd::AUTOLOAD =~ /.*::set(\w+)/) 0 0 0
172 {
173
174 0 my $name = $1;
175 0 ▶ if($name =~ /AlwaysInclude/ || $name =~ /Exclude/ || $name =~ /Path/)
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /AlwaysInclude/ or $name =~ /Exclude/ or $name =~ /Path/) { } 0 0 0
Condition0%0/6
$name =~ /AlwaysInclude/ or $name =~ /Exclude/ or $name =~ /Path/
l!l&&r!l&&!r
000
$name =~ /AlwaysInclude/ or $name =~ /Exclude/
l!l&&r!l&&!r
000
MC/DC0%0/3
$name =~ /AlwaysInclude/ or $name =~ /Exclude/ or $name =~ /Path/
$name =~ /AlwaysInclude/ $name =~ /Exclude/ $name =~ /Path/
Truth table0%0/4
A or B or C
A= $name =~ /AlwaysInclude/B= $name =~ /Exclude/C= $name =~ /Path/
ABCresult
1XX1
01X1
0011
0000
176 {
177 0 my $backupLocation = shift;
178 0 return($self->{"BackupLocations"}{$backupLocation}{$name} = shift);
179 }
180 else
181 {
182 0 return($self->{$name} = shift);
183 }
184 }
185
186 }
187  
188 1 1;
↑ Summary Accounts.pm »