line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TOML::Dumper::Context::Array; |
2
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
53
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
60
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
8
|
use Class::Accessor::Lite ro => [qw/name objects inline/]; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
904
|
use TOML::Dumper::Context::Table::Inline; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
8
|
2
|
|
|
2
|
|
769
|
use TOML::Dumper::Context::Array::Inline; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
9
|
2
|
|
|
2
|
|
793
|
use TOML::Dumper::Context::Value::Inline; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
10
|
2
|
|
|
2
|
|
10
|
use TOML::Dumper::Name; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
1073
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
15
|
|
|
15
|
0
|
22
|
my ($class, %args) = @_; |
14
|
15
|
|
|
|
|
11
|
my ($name, $objects) = @args{qw/name objects/}; |
15
|
15
|
|
|
|
|
24
|
my $self = bless { |
16
|
|
|
|
|
|
|
name => $name, |
17
|
|
|
|
|
|
|
objects => [], |
18
|
|
|
|
|
|
|
type => undef, |
19
|
|
|
|
|
|
|
} => $class; |
20
|
15
|
|
|
|
|
13
|
for my $object (@$objects) { |
21
|
28
|
|
|
|
|
37
|
$self->add($object); |
22
|
|
|
|
|
|
|
} |
23
|
15
|
|
|
|
|
18
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
12
|
|
|
12
|
0
|
7
|
sub depth { scalar @{ shift->{name} } } |
|
12
|
|
|
|
|
24
|
|
27
|
12
|
100
|
66
|
12
|
0
|
51
|
sub priority { defined $_[0]->{type} && $_[0]->{type} eq 'table' ? 0 : 1 } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub add { |
30
|
28
|
|
|
28
|
0
|
23
|
my ($self, $object) = @_; |
31
|
28
|
|
|
|
|
24
|
my $type = $self->{type}; |
32
|
28
|
100
|
|
|
|
40
|
if (ref $object eq 'HASH') { |
|
|
100
|
|
|
|
|
|
33
|
5
|
|
|
|
|
6
|
$self->{type} = 'table'; |
34
|
5
|
|
|
|
|
24
|
push @{ $self->{objects} } => TOML::Dumper::Context::Table::Inline->new(name => $self->{name}, tree => $object); |
|
5
|
|
|
|
|
31
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif (ref $object eq 'ARRAY') { |
37
|
10
|
|
|
|
|
11
|
$self->{type} = 'array'; |
38
|
10
|
|
|
|
|
5
|
push @{ $self->{objects} } => TOML::Dumper::Context::Array::Inline->new(name => undef, objects => $object); |
|
10
|
|
|
|
|
43
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
13
|
|
|
|
|
26
|
my $object = TOML::Dumper::Context::Value::Inline->new(name => undef, atom => $object); |
42
|
13
|
|
|
|
|
22
|
$self->{type} = $object->type; |
43
|
13
|
|
|
|
|
39
|
push @{ $self->{objects} } => $object; |
|
13
|
|
|
|
|
13
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
28
|
50
|
66
|
|
|
63
|
if (defined $type && $self->{type} ne $type) { |
47
|
0
|
|
|
|
|
0
|
my $name = TOML::Dumper::Name::join(@{ $self->{name} }); |
|
0
|
|
|
|
|
0
|
|
48
|
0
|
|
|
|
|
0
|
die "TOML array can contain each type of all values. ($name = $type)"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
28
|
|
|
|
|
21
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub as_string { |
55
|
5
|
|
|
5
|
0
|
4
|
my $self = shift; |
56
|
5
|
100
|
66
|
|
|
18
|
if (defined $self->{type} && $self->{type} eq 'table') { |
57
|
2
|
|
|
|
|
3
|
my $name = TOML::Dumper::Name::join(@{ $self->{name} }); |
|
2
|
|
|
|
|
6
|
|
58
|
2
|
|
|
|
|
2
|
my $body = "\n"; |
59
|
2
|
|
|
|
|
2
|
for my $object (@{ $self->{objects} }) { |
|
2
|
|
|
|
|
4
|
|
60
|
4
|
|
|
|
|
6
|
$body .= "\n[[$name]]\n"; |
61
|
4
|
|
|
|
|
12
|
$body .= join "\n", map { $_->as_string() } $object->objects; |
|
12
|
|
|
|
|
41
|
|
62
|
4
|
|
|
|
|
5
|
$body .= "\n"; |
63
|
|
|
|
|
|
|
} |
64
|
2
|
|
|
|
|
4
|
return $body; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
3
|
|
|
|
|
6
|
my $name = TOML::Dumper::Name::format($self->{name}->[-1]); |
68
|
3
|
|
|
|
|
7
|
my $body = $self->TOML::Dumper::Context::Array::Inline::as_string(); |
69
|
3
|
|
|
|
|
10
|
return "$name = $body\n"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |