| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Module::Build::Notes; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# A class for persistent hashes |
|
4
|
|
|
|
|
|
|
|
|
5
|
296
|
|
|
296
|
|
2078
|
use strict; |
|
|
296
|
|
|
|
|
699
|
|
|
|
296
|
|
|
|
|
8698
|
|
|
6
|
296
|
|
|
296
|
|
1504
|
use warnings; |
|
|
296
|
|
|
|
|
691
|
|
|
|
296
|
|
|
|
|
13602
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.42_35'; |
|
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
9
|
296
|
|
|
296
|
|
1649
|
use Data::Dumper; |
|
|
296
|
|
|
|
|
580
|
|
|
|
296
|
|
|
|
|
13964
|
|
|
10
|
296
|
|
|
296
|
|
1698
|
use Module::Build::Dumper; |
|
|
296
|
|
|
|
|
593
|
|
|
|
296
|
|
|
|
|
290739
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
3432
|
|
|
3432
|
0
|
15030
|
my ($class, %args) = @_; |
|
14
|
3432
|
50
|
|
|
|
11540
|
my $file = delete $args{file} or die "Missing required parameter 'file' to new()"; |
|
15
|
3432
|
|
|
|
|
37318
|
my $self = bless { |
|
16
|
|
|
|
|
|
|
disk => {}, |
|
17
|
|
|
|
|
|
|
new => {}, |
|
18
|
|
|
|
|
|
|
file => $file, |
|
19
|
|
|
|
|
|
|
%args, |
|
20
|
|
|
|
|
|
|
}, $class; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub restore { |
|
24
|
2934
|
|
|
2934
|
0
|
5525
|
my $self = shift; |
|
25
|
|
|
|
|
|
|
|
|
26
|
2934
|
50
|
|
|
|
104058
|
open(my $fh, '<', $self->{file}) or die "Can't read $self->{file}: $!"; |
|
27
|
2934
|
|
|
|
|
7878
|
$self->{disk} = eval do {local $/; <$fh>}; |
|
|
2934
|
|
|
|
|
12259
|
|
|
|
2934
|
|
|
|
|
290014
|
|
|
28
|
2934
|
50
|
|
|
|
14053
|
die $@ if $@; |
|
29
|
2934
|
|
|
|
|
32465
|
close $fh; |
|
30
|
2934
|
|
|
|
|
16760
|
$self->{new} = {}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub access { |
|
34
|
127
|
|
|
127
|
0
|
322
|
my $self = shift; |
|
35
|
127
|
100
|
|
|
|
635
|
return $self->read() unless @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
44
|
|
|
|
|
168
|
my $key = shift; |
|
38
|
44
|
100
|
|
|
|
159
|
return $self->read($key) unless @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
25
|
|
|
|
|
70
|
my $value = shift; |
|
41
|
25
|
|
|
|
|
179
|
$self->write({ $key => $value }); |
|
42
|
25
|
|
|
|
|
102
|
return $self->read($key); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub has_data { |
|
46
|
183
|
|
|
183
|
0
|
378
|
my $self = shift; |
|
47
|
183
|
|
|
|
|
268
|
return keys %{$self->read()} > 0; |
|
|
183
|
|
|
|
|
457
|
|
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub exists { |
|
51
|
2
|
|
|
2
|
0
|
9
|
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
|
1380
|
my $self = shift; |
|
57
|
|
|
|
|
|
|
|
|
58
|
467
|
100
|
|
|
|
1335
|
if (@_) { |
|
59
|
|
|
|
|
|
|
# Return 1 key as a scalar |
|
60
|
44
|
|
|
|
|
84
|
my $key = shift; |
|
61
|
44
|
100
|
|
|
|
129
|
return $self->{new}{$key} if exists $self->{new}{$key}; |
|
62
|
42
|
|
|
|
|
264
|
return $self->{disk}{$key}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Return all data |
|
66
|
423
|
|
|
|
|
2158
|
my $out = (keys %{$self->{new}} |
|
67
|
7
|
|
|
|
|
82
|
? {%{$self->{disk}}, %{$self->{new}}} |
|
|
7
|
|
|
|
|
63
|
|
|
68
|
423
|
100
|
|
|
|
858
|
: $self->{disk}); |
|
69
|
423
|
100
|
|
|
|
2964
|
return wantarray ? %$out : $out; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _same { |
|
73
|
95
|
|
|
95
|
|
270
|
my ($self, $x, $y) = @_; |
|
74
|
95
|
0
|
33
|
|
|
415
|
return 1 if !defined($x) and !defined($y); |
|
75
|
95
|
100
|
66
|
|
|
666
|
return 0 if !defined($x) or !defined($y); |
|
76
|
93
|
|
|
|
|
541
|
return $x eq $y; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub write { |
|
80
|
252
|
|
|
252
|
1
|
784
|
my ($self, $href) = @_; |
|
81
|
252
|
|
100
|
|
|
1060
|
$href ||= {}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
252
|
|
|
|
|
999
|
@{$self->{new}}{ keys %$href } = values %$href; # Merge |
|
|
252
|
|
|
|
|
997
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Do some optimization to avoid unnecessary writes |
|
86
|
252
|
|
|
|
|
666
|
foreach my $key (keys %{ $self->{new} }) { |
|
|
252
|
|
|
|
|
1218
|
|
|
87
|
233
|
100
|
|
|
|
952
|
next if ref $self->{new}{$key}; |
|
88
|
230
|
100
|
66
|
|
|
1969
|
next if ref $self->{disk}{$key} or !exists $self->{disk}{$key}; |
|
89
|
95
|
100
|
|
|
|
489
|
delete $self->{new}{$key} if $self->_same($self->{new}{$key}, $self->{disk}{$key}); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
252
|
50
|
|
|
|
1239
|
if (my $file = $self->{file}) { |
|
93
|
252
|
|
|
|
|
6276
|
my ($vol, $dir, $base) = File::Spec->splitpath($file); |
|
94
|
252
|
|
|
|
|
3009
|
$dir = File::Spec->catpath($vol, $dir, ''); |
|
95
|
252
|
100
|
66
|
|
|
5939
|
return unless -e $dir && -d $dir; # The user needs to arrange for this |
|
96
|
|
|
|
|
|
|
|
|
97
|
224
|
100
|
100
|
|
|
2525
|
return if -e $file and !keys %{ $self->{new} }; # Nothing to do |
|
|
221
|
|
|
|
|
1816
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
102
|
|
|
|
|
236
|
@{$self->{disk}}{ keys %{$self->{new}} } = values %{$self->{new}}; # Merge |
|
|
102
|
|
|
|
|
424
|
|
|
|
102
|
|
|
|
|
287
|
|
|
|
102
|
|
|
|
|
276
|
|
|
100
|
102
|
|
|
|
|
701
|
$self->_dump($file, $self->{disk}); |
|
101
|
|
|
|
|
|
|
|
|
102
|
102
|
|
|
|
|
637
|
$self->{new} = {}; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
102
|
|
|
|
|
526
|
return $self->read; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _dump { |
|
108
|
102
|
|
|
102
|
|
336
|
my ($self, $file, $data) = @_; |
|
109
|
|
|
|
|
|
|
|
|
110
|
102
|
50
|
|
|
|
20727
|
open(my $fh, '>', $file) or die "Can't create '$file': $!"; |
|
111
|
102
|
|
|
|
|
411
|
print {$fh} Module::Build::Dumper->_data_dump($data); |
|
|
102
|
|
|
|
|
1869
|
|
|
112
|
102
|
|
|
|
|
27401
|
close $fh; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $orig_template = do { local $/; }; |
|
116
|
|
|
|
|
|
|
close DATA; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub write_config_data { |
|
119
|
1
|
|
|
1
|
0
|
23
|
my ($self, %args) = @_; |
|
120
|
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
8
|
my $template = $orig_template; |
|
122
|
1
|
|
|
|
|
29
|
$template =~ s/NOTES_NAME/$args{config_module}/g; |
|
123
|
1
|
|
|
|
|
27
|
$template =~ s/MODULE_NAME/$args{module}/g; |
|
124
|
1
|
|
|
|
|
18
|
$template =~ s/=begin private\n//; |
|
125
|
1
|
|
|
|
|
19
|
$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
|
|
|
|
|
30
|
$template =~ s{$_\n}{} for '=begin private', '=end private'; |
|
130
|
|
|
|
|
|
|
|
|
131
|
1
|
50
|
|
|
|
68
|
open(my $fh, '>', $args{file}) or die "Can't create '$args{file}': $!"; |
|
132
|
1
|
|
|
|
|
3
|
print {$fh} $template; |
|
|
1
|
|
|
|
|
14
|
|
|
133
|
1
|
|
|
|
|
7
|
print {$fh} "\n__DATA__\n"; |
|
|
1
|
|
|
|
|
4
|
|
|
134
|
1
|
|
|
|
|
2
|
print {$fh} Module::Build::Dumper->_data_dump([$args{config_data}, $args{feature}, $args{auto_features}]); |
|
|
1
|
|
|
|
|
11
|
|
|
135
|
1
|
|
|
|
|
158
|
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__ |