line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Admin::Config; |
2
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
45
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
46
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
2
|
|
|
2
|
|
6
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
6
|
|
6
|
2
|
|
|
2
|
|
39
|
use vars qw($config $DefaultClass @EXPORT @ISA $defaultconfig); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
550
|
|
7
|
|
|
|
|
|
|
@MySQL::Admin::Config::EXPORT = qw(loadConfig saveConfig $config); |
8
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
$MySQL::Admin::Config::VERSION = '1.1'; |
10
|
|
|
|
|
|
|
$DefaultClass = 'MySQL::Admin::Config' unless defined $MySQL::Admin::Config::DefaultClass; |
11
|
|
|
|
|
|
|
$defaultconfig = '%CONFIG%'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
MySQL::Admin::Config - config for MySQL::Admin |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
see L |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 EXPORT |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
loadConfig() saveConfig() $config |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 Public |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 new() |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
0
|
|
|
0
|
1
|
|
my ($class, @initializer) = @_; |
33
|
0
|
|
|
|
|
|
my $self = {}; |
34
|
0
|
|
0
|
|
|
|
bless $self, ref $class || $class || $DefaultClass; |
35
|
0
|
|
|
|
|
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 loadConfig() |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub loadConfig { |
43
|
0
|
|
|
0
|
1
|
|
my ($self, @p) = getSelf(@_); |
44
|
0
|
0
|
|
|
|
|
my $do = (defined $p[0]) ? $p[0] : $defaultconfig; |
45
|
0
|
0
|
|
|
|
|
if (-e $do) { do $do; } |
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 saveConfig() |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub saveConfig { |
53
|
0
|
|
|
0
|
1
|
|
my ($self, @p) = getSelf(@_); |
54
|
0
|
0
|
|
|
|
|
my $saveAs = defined $p[0] ? $p[0] : $defaultconfig; |
55
|
0
|
0
|
|
|
|
|
$config = defined $p[1] ? $p[1] : $config; |
56
|
0
|
0
|
|
|
|
|
my $var = defined $p[2] ? $p[2] : 'config'; |
57
|
2
|
|
|
2
|
|
1199
|
use Data::Dumper; |
|
2
|
|
|
|
|
12299
|
|
|
2
|
|
|
|
|
130
|
|
58
|
0
|
|
|
|
|
|
my $content = Dumper($config); |
59
|
0
|
|
|
|
|
|
$content .= "\$$var =\$VAR1;"; |
60
|
2
|
|
|
2
|
|
8
|
use Fcntl qw(:flock); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
155
|
|
61
|
2
|
|
|
2
|
|
769
|
use Symbol; |
|
2
|
|
|
|
|
1170
|
|
|
2
|
|
|
|
|
564
|
|
62
|
0
|
|
|
|
|
|
my $fh = gensym(); |
63
|
0
|
0
|
|
|
|
|
my $rsas = $saveAs =~ /^(\S+)$/ ? $1 : 0; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if ($rsas) { |
66
|
0
|
0
|
|
|
|
|
open $fh, ">$rsas.bak" |
67
|
|
|
|
|
|
|
or warn "$/MySQL::Admin::Config::saveConfig$/ $! $/ File: $rsas $/Caller: " |
68
|
|
|
|
|
|
|
. caller() |
69
|
|
|
|
|
|
|
. $/; |
70
|
0
|
|
|
|
|
|
flock $fh, 2; |
71
|
0
|
|
|
|
|
|
seek $fh, 0, 0; |
72
|
0
|
|
|
|
|
|
truncate $fh, 0; |
73
|
0
|
|
|
|
|
|
print $fh $content; |
74
|
0
|
|
|
|
|
|
close $fh; |
75
|
|
|
|
|
|
|
} |
76
|
0
|
0
|
|
|
|
|
if (-e "$rsas.bak") { |
77
|
0
|
0
|
|
|
|
|
rename "$rsas.bak", $rsas |
78
|
|
|
|
|
|
|
or warn "$/MySQL::Admin::Config::saveConfig$/ $! $/ File: $rsas $/Caller: " |
79
|
|
|
|
|
|
|
. caller() |
80
|
|
|
|
|
|
|
. $/; |
81
|
0
|
|
|
|
|
|
do $rsas; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 Private |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 getSelf() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
see L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub getSelf { |
94
|
0
|
0
|
0
|
0
|
1
|
|
return @_ if defined($_[0]) && (!ref($_[0])) && ($_[0] eq 'MySQL::Admin::Config'); |
|
|
|
0
|
|
|
|
|
95
|
0
|
0
|
0
|
|
|
|
return (defined($_[0]) |
96
|
|
|
|
|
|
|
&& (ref($_[0]) eq 'MySQL::Admin::Config' || UNIVERSAL::isa($_[0], 'MySQL::Admin::Config')) |
97
|
|
|
|
|
|
|
) |
98
|
|
|
|
|
|
|
? @_ |
99
|
|
|
|
|
|
|
: ($MySQL::Admin::Config::DefaultClass->new, @_); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 see Also |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L L L L L L |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Dirk Lindner |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (C) 2005-2015 by Hr. Dirk Lindner |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
115
|
|
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public License |
116
|
|
|
|
|
|
|
as published by the Free Software Foundation; |
117
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
118
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
119
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
120
|
|
|
|
|
|
|
GNU Lesser General Public License for more details. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |