line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 tw=78 et si: |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
package GeNUScreen::Config::Diff; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
141
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
6
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
7
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
373
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $re_cfgval = qr/\S.*/; |
10
|
|
|
|
|
|
|
my $re_cfgvar = qr/[0-9a-z_]+/i; |
11
|
|
|
|
|
|
|
my $re_cfgpath = qr/$re_cfgvar(?:\.$re_cfgvar)*/; |
12
|
|
|
|
|
|
|
my $re_marker = qr/[a-z]+/i; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
2550
|
use Class::Std; |
|
2
|
|
|
|
|
30754
|
|
|
2
|
|
|
|
|
15
|
|
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
# storage for attributes |
17
|
|
|
|
|
|
|
my %diff : ATTR; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub BUILD { |
20
|
1
|
|
|
1
|
0
|
61
|
my ($self, $ident, $args_ref) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
10
|
$diff{ident $self} = {}; |
23
|
|
|
|
|
|
|
} # BUILD() |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub compare { |
26
|
1
|
|
|
1
|
1
|
2
|
my ($self,$this,$that) = @_; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
2
|
my %d; |
29
|
1
|
|
|
|
|
3
|
my %all_keys = (); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
foreach my $k ($this->get_keys()) {$all_keys{$k} = 1}; |
|
262
|
|
|
|
|
385
|
|
32
|
1
|
|
|
|
|
17
|
foreach my $k ($that->get_keys()) {$all_keys{$k} = 1}; |
|
262
|
|
|
|
|
296
|
|
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
40
|
foreach my $k (keys %all_keys) { |
35
|
262
|
|
|
|
|
668
|
my $thisval = $this->get_value($k); |
36
|
262
|
|
|
|
|
666
|
my $thatval = $that->get_value($k); |
37
|
|
|
|
|
|
|
|
38
|
262
|
50
|
66
|
|
|
2284
|
unless ((not defined $thisval and not defined $thatval) |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
39
|
|
|
|
|
|
|
or (defined $thisval and defined $thatval |
40
|
|
|
|
|
|
|
and $thisval eq $thatval) |
41
|
|
|
|
|
|
|
) { |
42
|
0
|
|
|
|
|
0
|
$d{$k}->{this} = $thisval; |
43
|
0
|
|
|
|
|
0
|
$d{$k}->{that} = $thatval; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
1
|
|
|
|
|
41
|
$diff{ident $self} = \%d; |
47
|
|
|
|
|
|
|
} # compare() |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get_keys { |
50
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
return keys %{$diff{ident $self}}; |
|
0
|
|
|
|
|
0
|
|
53
|
|
|
|
|
|
|
} # get_keys() |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_that_value { |
56
|
0
|
|
|
0
|
1
|
0
|
my ($self,$key) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
return $diff{ident $self}->{$key}->{that}; |
59
|
|
|
|
|
|
|
} # get_that_value() |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_this_value { |
62
|
0
|
|
|
0
|
1
|
0
|
my ($self,$key) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
return $diff{ident $self}->{$key}->{this}; |
65
|
|
|
|
|
|
|
} # get_this_value() |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub is_empty { |
68
|
1
|
|
|
1
|
1
|
7
|
my ($self) = @_; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
3
|
return 0 == scalar keys %{$diff{ident $self}}; |
|
1
|
|
|
|
|
11
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} # package GeNUScreen::Config::Diff |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
76
|
|
|
|
|
|
|
__END__ |