line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
624
|
use 5.006; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
287
|
|
2
|
10
|
|
|
10
|
|
34
|
use strict; |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
256
|
|
3
|
10
|
|
|
10
|
|
37
|
use warnings; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
513
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Util::ExpandINI::Writer; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.003001'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: An order-preserving INI Writer |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
4179
|
use Config::INI::Writer 0.024; |
|
10
|
|
|
|
|
39783
|
|
|
10
|
|
|
|
|
248
|
|
14
|
10
|
|
|
10
|
|
402
|
use parent 'Config::INI::Writer'; |
|
10
|
|
|
|
|
248
|
|
|
10
|
|
|
|
|
61
|
|
15
|
10
|
|
|
10
|
|
541
|
use Carp qw(croak); |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
3651
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub is_valid_section_name { |
22
|
145
|
|
|
145
|
0
|
104
|
my ( undef, $name ) = @_; |
23
|
145
|
|
|
|
|
1346
|
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
|
22527
|
my ( undef, $input_data ) = @_; |
38
|
9
|
|
|
|
|
14
|
my @out; |
39
|
9
|
|
|
|
|
14
|
my $i = 0; |
40
|
9
|
|
|
|
|
11
|
for my $ini_record ( @{$input_data} ) { |
|
9
|
|
|
|
|
20
|
|
41
|
145
|
|
|
|
|
94
|
$i++; |
42
|
145
|
100
|
66
|
|
|
476
|
if ( $ini_record->{name} and '_' eq $ini_record->{name} ) { |
43
|
9
|
|
|
|
|
16
|
push @out, '_', $ini_record; |
44
|
9
|
|
|
|
|
12
|
next; |
45
|
|
|
|
|
|
|
} |
46
|
136
|
50
|
|
|
|
175
|
if ( not $ini_record->{package} ) { |
47
|
0
|
|
|
|
|
0
|
croak("Entry $i lacks package component"); |
48
|
|
|
|
|
|
|
} |
49
|
136
|
|
|
|
|
109
|
my $kn = $ini_record->{package}; |
50
|
136
|
100
|
66
|
|
|
350
|
if ( $ini_record->{name} and $ini_record->{package} ne $ini_record->{name} ) { |
51
|
135
|
|
|
|
|
174
|
$kn .= q[ / ] . $ini_record->{name}; |
52
|
|
|
|
|
|
|
} |
53
|
136
|
|
|
|
|
131
|
push @out, $kn, $ini_record; |
54
|
136
|
|
|
|
|
129
|
next; |
55
|
|
|
|
|
|
|
} |
56
|
9
|
|
|
|
|
30
|
return \@out; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub validate_input { |
60
|
9
|
|
|
9
|
1
|
32
|
my ( $self, $input ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
9
|
my %seen; |
63
|
|
|
|
|
|
|
|
64
|
9
|
|
|
|
|
12
|
my @input_copy = @{$input}; |
|
9
|
|
|
|
|
39
|
|
65
|
|
|
|
|
|
|
|
66
|
9
|
|
|
|
|
24
|
while (@input_copy) { |
67
|
145
|
|
|
|
|
254
|
my ( $name, $ini_record ) = splice @input_copy, 0, 2; |
68
|
|
|
|
|
|
|
|
69
|
145
|
50
|
|
|
|
354
|
if ( $seen{$name}++ ) { |
70
|
0
|
|
|
|
|
0
|
Carp::croak "multiple declarations found of $name"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
145
|
50
|
|
|
|
141
|
Carp::croak "illegal section name '$name'" |
74
|
|
|
|
|
|
|
if not $self->is_valid_section_name($name); |
75
|
|
|
|
|
|
|
|
76
|
145
|
|
|
|
|
117
|
my @props_copy = @{ $ini_record->{lines} }; |
|
145
|
|
|
|
|
193
|
|
77
|
|
|
|
|
|
|
|
78
|
145
|
|
|
|
|
263
|
while (@props_copy) { |
79
|
54
|
|
|
|
|
231
|
my ( $property, $value ) = splice @props_copy, 0, 2; |
80
|
|
|
|
|
|
|
|
81
|
54
|
50
|
|
|
|
114
|
Carp::croak "property name '$property' contains illegal character" |
82
|
|
|
|
|
|
|
if not $self->is_valid_property_name($property); |
83
|
|
|
|
|
|
|
|
84
|
54
|
50
|
33
|
|
|
445
|
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
|
|
|
|
|
88
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub stringify_section_data { |
93
|
145
|
|
|
145
|
1
|
3624
|
my ( $self, $ini_record ) = @_; |
94
|
145
|
|
|
|
|
94
|
my $output = q[]; |
95
|
145
|
|
|
|
|
104
|
$output .= q[;] . $_ . qq[\n] for @{ $ini_record->{comment_lines} }; |
|
145
|
|
|
|
|
262
|
|
96
|
145
|
|
|
|
|
277
|
$output .= $self->SUPER::stringify_section_data( $ini_record->{lines} ); |
97
|
145
|
|
|
|
|
921
|
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.003001 |
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) 2015 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 |