line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TOML::Dumper::Context::Table; |
2
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
59
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use Class::Accessor::Lite ro => [qw/name tree inline/]; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
870
|
use TOML::Dumper::Name; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
57
|
|
8
|
2
|
|
|
2
|
|
749
|
use TOML::Dumper::Context::Array; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
9
|
2
|
|
|
2
|
|
767
|
use TOML::Dumper::Context::Value; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1011
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
9
|
|
|
9
|
0
|
13
|
my ($class, %args) = @_; |
13
|
9
|
|
|
|
|
11
|
my ($name, $tree) = @args{qw/name tree/}; |
14
|
9
|
|
|
|
|
16
|
my $self = bless { |
15
|
|
|
|
|
|
|
name => $name, |
16
|
|
|
|
|
|
|
tree => {}, |
17
|
|
|
|
|
|
|
} => $class; |
18
|
9
|
|
|
|
|
18
|
for my $name (keys %$tree) { |
19
|
25
|
|
|
|
|
42
|
$self->set($name => $tree->{$name}); |
20
|
|
|
|
|
|
|
} |
21
|
9
|
|
|
|
|
21
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
7
|
|
|
7
|
0
|
3
|
sub depth { scalar @{ shift->{name} } } |
|
7
|
|
|
|
|
14
|
|
25
|
7
|
|
|
7
|
0
|
16
|
sub priority { 0 } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub set { |
28
|
25
|
|
|
25
|
0
|
23
|
my ($self, $name, $object) = @_; |
29
|
25
|
50
|
|
|
|
31
|
my @name = defined $self->{name} ? (@{ $self->{name} }, $name) : ($name); |
|
25
|
|
|
|
|
34
|
|
30
|
25
|
100
|
|
|
|
42
|
if (ref $object eq 'HASH') { |
|
|
100
|
|
|
|
|
|
31
|
3
|
|
|
|
|
6
|
$self->{tree}->{$name} = TOML::Dumper::Context::Table->new(name => \@name, tree => $object); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif (ref $object eq 'ARRAY') { |
34
|
5
|
|
|
|
|
18
|
$self->{tree}->{$name} = TOML::Dumper::Context::Array->new(name => \@name, objects => $object); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
17
|
|
|
|
|
33
|
$self->{tree}->{$name} = TOML::Dumper::Context::Value->new(name => \@name, atom => $object); |
38
|
|
|
|
|
|
|
} |
39
|
25
|
|
|
|
|
24
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub remove { |
43
|
0
|
|
|
0
|
0
|
0
|
my ($self, $name) = @_; |
44
|
0
|
|
|
|
|
0
|
delete $self->{tree}->{$name}; |
45
|
0
|
|
|
|
|
0
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub objects { |
49
|
9
|
|
|
9
|
0
|
6
|
my $self = shift; |
50
|
9
|
50
|
66
|
|
|
7
|
return sort { $a->depth <=> $b->depth || $b->priority <=> $a->priority || $a->name->[-1] cmp $b->name->[-1] } values %{ $self->{tree} }; |
|
33
|
|
|
|
|
103
|
|
|
9
|
|
|
|
|
24
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub as_string { |
54
|
4
|
|
|
4
|
0
|
2
|
my $self = shift; |
55
|
4
|
|
|
|
|
5
|
my $name = $self->{name}; |
56
|
4
|
100
|
|
|
|
10
|
my $body = @$name ? "\n".'['.TOML::Dumper::Name::join(@$name).']'."\n" : ''; |
57
|
4
|
|
|
|
|
7
|
$body .= join "\n", map { $_->as_string() } $self->objects; |
|
13
|
|
|
|
|
31
|
|
58
|
4
|
|
|
|
|
13
|
return $body; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |