| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Module::Build::Notes; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# A class for persistent hashes |
|
4
|
|
|
|
|
|
|
|
|
5
|
293
|
|
|
293
|
|
2094
|
use strict; |
|
|
293
|
|
|
|
|
639
|
|
|
|
293
|
|
|
|
|
8698
|
|
|
6
|
293
|
|
|
293
|
|
2011
|
use warnings; |
|
|
293
|
|
|
|
|
663
|
|
|
|
293
|
|
|
|
|
14254
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.42_33'; |
|
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
9
|
293
|
|
|
293
|
|
1702
|
use Data::Dumper; |
|
|
293
|
|
|
|
|
549
|
|
|
|
293
|
|
|
|
|
13282
|
|
|
10
|
293
|
|
|
293
|
|
1753
|
use Module::Build::Dumper; |
|
|
293
|
|
|
|
|
559
|
|
|
|
293
|
|
|
|
|
299907
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
3360
|
|
|
3360
|
0
|
20850
|
my ($class, %args) = @_; |
|
14
|
3360
|
50
|
|
|
|
13881
|
my $file = delete $args{file} or die "Missing required parameter 'file' to new()"; |
|
15
|
3360
|
|
|
|
|
55600
|
my $self = bless { |
|
16
|
|
|
|
|
|
|
disk => {}, |
|
17
|
|
|
|
|
|
|
new => {}, |
|
18
|
|
|
|
|
|
|
file => $file, |
|
19
|
|
|
|
|
|
|
%args, |
|
20
|
|
|
|
|
|
|
}, $class; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub restore { |
|
24
|
2862
|
|
|
2862
|
0
|
8017
|
my $self = shift; |
|
25
|
|
|
|
|
|
|
|
|
26
|
2862
|
50
|
|
|
|
145259
|
open(my $fh, '<', $self->{file}) or die "Can't read $self->{file}: $!"; |
|
27
|
2862
|
|
|
|
|
10308
|
$self->{disk} = eval do {local $/; <$fh>}; |
|
|
2862
|
|
|
|
|
16517
|
|
|
|
2862
|
|
|
|
|
409993
|
|
|
28
|
2862
|
50
|
|
|
|
20207
|
die $@ if $@; |
|
29
|
2862
|
|
|
|
|
42167
|
close $fh; |
|
30
|
2862
|
|
|
|
|
23597
|
$self->{new} = {}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub access { |
|
34
|
127
|
|
|
127
|
0
|
359
|
my $self = shift; |
|
35
|
127
|
100
|
|
|
|
814
|
return $self->read() unless @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
44
|
|
|
|
|
267
|
my $key = shift; |
|
38
|
44
|
100
|
|
|
|
201
|
return $self->read($key) unless @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
25
|
|
|
|
|
96
|
my $value = shift; |
|
41
|
25
|
|
|
|
|
254
|
$self->write({ $key => $value }); |
|
42
|
25
|
|
|
|
|
112
|
return $self->read($key); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub has_data { |
|
46
|
183
|
|
|
183
|
0
|
496
|
my $self = shift; |
|
47
|
183
|
|
|
|
|
352
|
return keys %{$self->read()} > 0; |
|
|
183
|
|
|
|
|
536
|
|
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub exists { |
|
51
|
2
|
|
|
2
|
0
|
11
|
my ($self, $key) = @_; |
|
52
|
2
|
|
33
|
|
|
34
|
return exists($self->{new}{$key}) || exists($self->{disk}{$key}); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub read { |
|
56
|
467
|
|
|
467
|
0
|
1274
|
my $self = shift; |
|
57
|
|
|
|
|
|
|
|
|
58
|
467
|
100
|
|
|
|
1561
|
if (@_) { |
|
59
|
|
|
|
|
|
|
# Return 1 key as a scalar |
|
60
|
44
|
|
|
|
|
89
|
my $key = shift; |
|
61
|
44
|
100
|
|
|
|
169
|
return $self->{new}{$key} if exists $self->{new}{$key}; |
|
62
|
42
|
|
|
|
|
392
|
return $self->{disk}{$key}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Return all data |
|
66
|
423
|
|
|
|
|
2551
|
my $out = (keys %{$self->{new}} |
|
67
|
7
|
|
|
|
|
171
|
? {%{$self->{disk}}, %{$self->{new}}} |
|
|
7
|
|
|
|
|
132
|
|
|
68
|
423
|
100
|
|
|
|
745
|
: $self->{disk}); |
|
69
|
423
|
100
|
|
|
|
3211
|
return wantarray ? %$out : $out; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _same { |
|
73
|
95
|
|
|
95
|
|
381
|
my ($self, $x, $y) = @_; |
|
74
|
95
|
0
|
33
|
|
|
615
|
return 1 if !defined($x) and !defined($y); |
|
75
|
95
|
100
|
66
|
|
|
764
|
return 0 if !defined($x) or !defined($y); |
|
76
|
93
|
|
|
|
|
649
|
return $x eq $y; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub write { |
|
80
|
252
|
|
|
252
|
1
|
906
|
my ($self, $href) = @_; |
|
81
|
252
|
|
100
|
|
|
1237
|
$href ||= {}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
252
|
|
|
|
|
1169
|
@{$self->{new}}{ keys %$href } = values %$href; # Merge |
|
|
252
|
|
|
|
|
1102
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Do some optimization to avoid unnecessary writes |
|
86
|
252
|
|
|
|
|
626
|
foreach my $key (keys %{ $self->{new} }) { |
|
|
252
|
|
|
|
|
1315
|
|
|
87
|
233
|
100
|
|
|
|
1144
|
next if ref $self->{new}{$key}; |
|
88
|
230
|
100
|
66
|
|
|
2490
|
next if ref $self->{disk}{$key} or !exists $self->{disk}{$key}; |
|
89
|
95
|
100
|
|
|
|
618
|
delete $self->{new}{$key} if $self->_same($self->{new}{$key}, $self->{disk}{$key}); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
252
|
50
|
|
|
|
1408
|
if (my $file = $self->{file}) { |
|
93
|
252
|
|
|
|
|
7430
|
my ($vol, $dir, $base) = File::Spec->splitpath($file); |
|
94
|
252
|
|
|
|
|
3401
|
$dir = File::Spec->catpath($vol, $dir, ''); |
|
95
|
252
|
100
|
66
|
|
|
7888
|
return unless -e $dir && -d $dir; # The user needs to arrange for this |
|
96
|
|
|
|
|
|
|
|
|
97
|
224
|
100
|
100
|
|
|
3155
|
return if -e $file and !keys %{ $self->{new} }; # Nothing to do |
|
|
221
|
|
|
|
|
1988
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
102
|
|
|
|
|
287
|
@{$self->{disk}}{ keys %{$self->{new}} } = values %{$self->{new}}; # Merge |
|
|
102
|
|
|
|
|
390
|
|
|
|
102
|
|
|
|
|
267
|
|
|
|
102
|
|
|
|
|
396
|
|
|
100
|
102
|
|
|
|
|
724
|
$self->_dump($file, $self->{disk}); |
|
101
|
|
|
|
|
|
|
|
|
102
|
102
|
|
|
|
|
751
|
$self->{new} = {}; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
102
|
|
|
|
|
674
|
return $self->read; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _dump { |
|
108
|
102
|
|
|
102
|
|
338
|
my ($self, $file, $data) = @_; |
|
109
|
|
|
|
|
|
|
|
|
110
|
102
|
50
|
|
|
|
14849
|
open(my $fh, '>', $file) or die "Can't create '$file': $!"; |
|
111
|
102
|
|
|
|
|
552
|
print {$fh} Module::Build::Dumper->_data_dump($data); |
|
|
102
|
|
|
|
|
2231
|
|
|
112
|
102
|
|
|
|
|
31092
|
close $fh; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $orig_template = do { local $/; }; |
|
116
|
|
|
|
|
|
|
close DATA; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub write_config_data { |
|
119
|
1
|
|
|
1
|
0
|
31
|
my ($self, %args) = @_; |
|
120
|
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
9
|
my $template = $orig_template; |
|
122
|
1
|
|
|
|
|
45
|
$template =~ s/NOTES_NAME/$args{config_module}/g; |
|
123
|
1
|
|
|
|
|
25
|
$template =~ s/MODULE_NAME/$args{module}/g; |
|
124
|
1
|
|
|
|
|
20
|
$template =~ s/=begin private\n//; |
|
125
|
1
|
|
|
|
|
28
|
$template =~ s/=end private/=cut/; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# strip out private POD markers we use to keep pod from being |
|
128
|
|
|
|
|
|
|
# recognized for *this* source file |
|
129
|
1
|
|
|
|
|
46
|
$template =~ s{$_\n}{} for '=begin private', '=end private'; |
|
130
|
|
|
|
|
|
|
|
|
131
|
1
|
50
|
|
|
|
84
|
open(my $fh, '>', $args{file}) or die "Can't create '$args{file}': $!"; |
|
132
|
1
|
|
|
|
|
5
|
print {$fh} $template; |
|
|
1
|
|
|
|
|
14
|
|
|
133
|
1
|
|
|
|
|
3
|
print {$fh} "\n__DATA__\n"; |
|
|
1
|
|
|
|
|
7
|
|
|
134
|
1
|
|
|
|
|
4
|
print {$fh} Module::Build::Dumper->_data_dump([$args{config_data}, $args{feature}, $args{auto_features}]); |
|
|
1
|
|
|
|
|
12
|
|
|
135
|
1
|
|
|
|
|
196
|
close $fh; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 NAME |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Module::Build::Notes - Create persistent distribution configuration modules |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This module is used internally by Module::Build to create persistent |
|
148
|
|
|
|
|
|
|
configuration files that can be installed with a distribution. See |
|
149
|
|
|
|
|
|
|
L for an example. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 AUTHOR |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Ken Williams |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (c) 2001-2006 Ken Williams. All rights reserved. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
|
160
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
perl(1), L(3) |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
__DATA__ |