line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAX::Builder; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
20696
|
use strict; |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
94
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
393
|
use YAX::Text; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
64
|
|
6
|
3
|
|
|
3
|
|
700
|
use YAX::Element; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
60
|
|
7
|
3
|
|
|
3
|
|
837
|
use YAX::Fragment; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1153
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
0
|
0
|
my ( $class ) = @_; |
11
|
0
|
|
|
|
|
0
|
my $self = bless { }, $class; |
12
|
0
|
|
|
|
|
0
|
$self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub build { |
16
|
5
|
|
|
5
|
1
|
13
|
my ( $self, @specs ) = @_; |
17
|
5
|
|
|
|
|
11
|
my @nodes = map { $self->node( $_ ) } @specs; |
|
6
|
|
|
|
|
117
|
|
18
|
5
|
50
|
|
|
|
40
|
return wantarray ? @nodes : $nodes[0]; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub node { |
22
|
10
|
|
|
10
|
1
|
60
|
my ( $self, $spec ) = @_; |
23
|
10
|
100
|
|
|
|
56
|
if ( ref $spec eq 'ARRAY' ) { |
|
|
100
|
|
|
|
|
|
24
|
5
|
|
|
|
|
14
|
my @copy = @$spec; |
25
|
5
|
|
|
|
|
14
|
my $name = splice @copy, 0, 1; |
26
|
5
|
100
|
|
|
|
20
|
my %atts = ref $copy[0] eq 'HASH' ? %{ splice @copy, 0, 1 } : ( ); |
|
2
|
|
|
|
|
11
|
|
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
20
|
my $node = $self->element( $name, %atts ); |
29
|
5
|
|
|
|
|
20
|
$node->append( $_ ) for $self->build( @copy ); |
30
|
5
|
|
|
|
|
23
|
return $node; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif ( UNIVERSAL::isa( $spec, 'YAX::Node' ) ) { |
33
|
2
|
|
|
|
|
10
|
return $spec; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
3
|
|
|
|
|
24
|
return $self->text( $spec ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub text { |
41
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
42
|
3
|
|
|
|
|
40
|
YAX::Text->new(@_); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub element { |
46
|
5
|
|
|
5
|
0
|
13
|
my ( $self, $name, %atts ) = @_; |
47
|
5
|
|
|
|
|
29
|
YAX::Element->new( $name, %atts ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub fragment { |
51
|
0
|
|
|
0
|
1
|
|
my ( $self, @kids ) = @_; |
52
|
0
|
|
|
|
|
|
YAX::Fragment->new( $self->build( @kids ) ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
__END__ |