| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
10
|
|
|
10
|
|
615
|
use 5.006; |
|
|
10
|
|
|
|
|
26
|
|
|
2
|
10
|
|
|
10
|
|
34
|
use strict; |
|
|
10
|
|
|
|
|
13
|
|
|
|
10
|
|
|
|
|
192
|
|
|
3
|
10
|
|
|
10
|
|
30
|
use warnings; |
|
|
10
|
|
|
|
|
14
|
|
|
|
10
|
|
|
|
|
1126
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Util::ExpandINI::Writer; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.003003'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: An order-preserving INI Writer |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
|
12
|
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
4604
|
use Config::INI::Writer 0.024; |
|
|
10
|
|
|
|
|
42397
|
|
|
|
10
|
|
|
|
|
256
|
|
|
14
|
10
|
|
|
10
|
|
463
|
use parent 'Config::INI::Writer'; |
|
|
10
|
|
|
|
|
225
|
|
|
|
10
|
|
|
|
|
65
|
|
|
15
|
10
|
|
|
10
|
|
562
|
use Carp qw(croak); |
|
|
10
|
|
|
|
|
14
|
|
|
|
10
|
|
|
|
|
4089
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub is_valid_section_name { |
|
22
|
145
|
|
|
145
|
0
|
115
|
my ( undef, $name ) = @_; |
|
23
|
145
|
|
|
|
|
1234
|
return $name !~ m{ |
|
24
|
|
|
|
|
|
|
(?: # Dont capture |
|
25
|
|
|
|
|
|
|
\n # Newlines may not occur in a section name |
|
26
|
|
|
|
|
|
|
| |
|
27
|
|
|
|
|
|
|
\s; # Comments may not occur in a section name |
|
28
|
|
|
|
|
|
|
| |
|
29
|
|
|
|
|
|
|
^\s # Leading whitespace is illegal in a section name |
|
30
|
|
|
|
|
|
|
| |
|
31
|
|
|
|
|
|
|
\s$ # Trailing whitespace is illegal in a section name |
|
32
|
|
|
|
|
|
|
) |
|
33
|
|
|
|
|
|
|
}msx; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub preprocess_input { |
|
37
|
9
|
|
|
9
|
1
|
24362
|
my ( undef, $input_data ) = @_; |
|
38
|
9
|
|
|
|
|
41
|
my @out; |
|
39
|
9
|
|
|
|
|
14
|
my $i = 0; |
|
40
|
9
|
|
|
|
|
13
|
for my $ini_record ( @{$input_data} ) { |
|
|
9
|
|
|
|
|
26
|
|
|
41
|
145
|
|
|
|
|
108
|
$i++; |
|
42
|
145
|
100
|
66
|
|
|
509
|
if ( $ini_record->{name} and '_' eq $ini_record->{name} ) { |
|
43
|
9
|
|
|
|
|
18
|
push @out, '_', $ini_record; |
|
44
|
9
|
|
|
|
|
16
|
next; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
136
|
50
|
|
|
|
188
|
if ( not $ini_record->{package} ) { |
|
47
|
0
|
|
|
|
|
0
|
croak("Entry $i lacks package component"); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
136
|
|
|
|
|
117
|
my $kn = $ini_record->{package}; |
|
50
|
136
|
100
|
66
|
|
|
371
|
if ( $ini_record->{name} and $ini_record->{package} ne $ini_record->{name} ) { |
|
51
|
135
|
|
|
|
|
250
|
$kn .= q[ / ] . $ini_record->{name}; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
136
|
|
|
|
|
141
|
push @out, $kn, $ini_record; |
|
54
|
136
|
|
|
|
|
136
|
next; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
9
|
|
|
|
|
34
|
return \@out; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub validate_input { |
|
60
|
9
|
|
|
9
|
1
|
36
|
my ( $self, $input ) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
24
|
my %seen; |
|
63
|
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
14
|
my @input_copy = @{$input}; |
|
|
9
|
|
|
|
|
43
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
9
|
|
|
|
|
28
|
while (@input_copy) { |
|
67
|
145
|
|
|
|
|
260
|
my ( $name, $ini_record ) = splice @input_copy, 0, 2; |
|
68
|
|
|
|
|
|
|
|
|
69
|
145
|
50
|
|
|
|
338
|
if ( $seen{$name}++ ) { |
|
70
|
0
|
|
|
|
|
0
|
Carp::croak "multiple declarations found of $name"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
145
|
50
|
|
|
|
160
|
Carp::croak "illegal section name '$name'" |
|
74
|
|
|
|
|
|
|
if not $self->is_valid_section_name($name); |
|
75
|
|
|
|
|
|
|
|
|
76
|
145
|
|
|
|
|
108
|
my @props_copy = @{ $ini_record->{lines} }; |
|
|
145
|
|
|
|
|
214
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
145
|
|
|
|
|
276
|
while (@props_copy) { |
|
79
|
54
|
|
|
|
|
243
|
my ( $property, $value ) = splice @props_copy, 0, 2; |
|
80
|
|
|
|
|
|
|
|
|
81
|
54
|
50
|
|
|
|
118
|
Carp::croak "property name '$property' contains illegal character" |
|
82
|
|
|
|
|
|
|
if not $self->is_valid_property_name($property); |
|
83
|
|
|
|
|
|
|
|
|
84
|
54
|
50
|
33
|
|
|
486
|
Carp::croak "value for $name.$property contains illegal character" |
|
85
|
|
|
|
|
|
|
if defined $value and not $self->is_valid_value($value); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
9
|
|
|
|
|
94
|
return; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub stringify_section_data { |
|
93
|
145
|
|
|
145
|
1
|
3626
|
my ( $self, $ini_record ) = @_; |
|
94
|
145
|
|
|
|
|
143
|
my $output = q[]; |
|
95
|
145
|
|
|
|
|
95
|
$output .= q[;] . $_ . qq[\n] for @{ $ini_record->{comment_lines} }; |
|
|
145
|
|
|
|
|
263
|
|
|
96
|
145
|
|
|
|
|
310
|
$output .= $self->SUPER::stringify_section_data( $ini_record->{lines} ); |
|
97
|
145
|
|
|
|
|
978
|
return $output; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=pod |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=encoding UTF-8 |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Dist::Zilla::Util::ExpandINI::Writer - An order-preserving INI Writer |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 VERSION |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
version 0.003003 |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=for Pod::Coverage is_valid_section_name |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
126
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |