| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Moonshine::Component; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
58417
|
use strict; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
70
|
|
|
4
|
3
|
|
|
3
|
|
9
|
use warnings; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
62
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1282
|
use Moonshine::Element; |
|
|
3
|
|
|
|
|
61422
|
|
|
|
3
|
|
|
|
|
81
|
|
|
7
|
3
|
|
|
3
|
|
1211
|
use Moonshine::Magic; |
|
|
3
|
|
|
|
|
15215
|
|
|
|
3
|
|
|
|
|
14
|
|
|
8
|
3
|
|
|
3
|
|
1181
|
use Params::Validate qw(:all); |
|
|
3
|
|
|
|
|
7252
|
|
|
|
3
|
|
|
|
|
528
|
|
|
9
|
3
|
|
|
3
|
|
14
|
use Ref::Util qw(:all); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
479
|
|
|
10
|
3
|
|
|
3
|
|
12
|
use feature qw/switch/; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
239
|
|
|
11
|
3
|
|
|
3
|
|
11
|
no if $] >= 5.017011, warnings => 'experimental::smartmatch'; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
extends "UNIVERSAL::Object"; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN { |
|
18
|
3
|
|
|
3
|
|
696
|
my $fields = $Moonshine::Element::HAS{"attribute_list"}->(); |
|
19
|
3
|
|
|
|
|
8
|
my %html_spec = map { $_ => 0 } @{$fields}, qw/data tag/; |
|
|
447
|
|
|
|
|
466
|
|
|
|
3
|
|
|
|
|
8
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has ( |
|
22
|
|
|
|
|
|
|
html_spec => sub { \%html_spec }, |
|
23
|
|
|
|
|
|
|
modifier_spec => sub { { } }, |
|
24
|
3
|
|
|
|
|
87
|
); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub validate_build { |
|
28
|
407
|
|
|
407
|
0
|
573814
|
my $self = shift; |
|
29
|
407
|
|
|
|
|
5365
|
my %args = validate_with( |
|
30
|
|
|
|
|
|
|
params => $_[0], |
|
31
|
|
|
|
|
|
|
spec => { |
|
32
|
|
|
|
|
|
|
params => { type => HASHREF }, |
|
33
|
|
|
|
|
|
|
spec => { type => HASHREF }, |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
407
|
|
|
|
|
1114
|
my %html_spec = %{ $self->html_spec }; |
|
|
407
|
|
|
|
|
783
|
|
|
38
|
407
|
|
|
|
|
1917
|
my %html_params = (); |
|
39
|
|
|
|
|
|
|
|
|
40
|
407
|
|
|
|
|
292
|
my %modifier_spec = %{ $self->modifier_spec }; |
|
|
407
|
|
|
|
|
623
|
|
|
41
|
407
|
|
|
|
|
426
|
my %modifier_params = (); |
|
42
|
|
|
|
|
|
|
|
|
43
|
407
|
|
|
|
|
262
|
my %combine = ( %{ $args{params} }, %{ $args{'spec'} } ); |
|
|
407
|
|
|
|
|
709
|
|
|
|
407
|
|
|
|
|
775
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
407
|
|
|
|
|
810
|
for my $key ( keys %combine ) { |
|
46
|
1222
|
|
|
|
|
1031
|
my $spec = $args{spec}->{$key}; |
|
47
|
1222
|
100
|
|
|
|
1759
|
if ( is_hashref($spec) ) { |
|
48
|
408
|
50
|
|
|
|
589
|
defined $spec->{build} and next; |
|
49
|
408
|
50
|
|
|
|
529
|
if ( exists $spec->{base} ) { |
|
50
|
0
|
|
|
|
|
0
|
my $param = delete $args{params}->{$key}; |
|
51
|
0
|
|
|
|
|
0
|
my $spec = delete $args{spec}->{$key}; |
|
52
|
0
|
0
|
|
|
|
0
|
$html_params{$key} = $param if $param; |
|
53
|
0
|
0
|
|
|
|
0
|
$html_spec{$key} = $spec if $spec; |
|
54
|
0
|
|
|
|
|
0
|
next; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
1222
|
100
|
|
|
|
1310
|
if ( exists $html_spec{$key} ) { |
|
|
|
50
|
|
|
|
|
|
|
59
|
1220
|
100
|
|
|
|
1561
|
if ( defined $spec ) { |
|
60
|
813
|
|
|
|
|
982
|
$html_spec{$key} = delete $args{spec}->{$key}; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
1220
|
100
|
|
|
|
1658
|
if ( exists $args{params}->{$key} ) { |
|
63
|
407
|
|
|
|
|
489
|
$html_params{$key} = delete $args{params}->{$key}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
1220
|
|
|
|
|
1326
|
next; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
elsif ( exists $modifier_spec{$key} ) { |
|
68
|
2
|
50
|
|
|
|
4
|
if ( defined $spec ) { |
|
69
|
2
|
|
|
|
|
3
|
$modifier_spec{$key} = delete $args{spec}->{$key}; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
2
|
100
|
|
|
|
3
|
if ( exists $args{params}->{$key} ) { |
|
72
|
1
|
|
|
|
|
3
|
my $params = $args{params}->{$key}; |
|
73
|
1
|
|
|
|
|
1
|
$modifier_params{$key} = delete $args{params}->{$key}; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
2
|
|
|
|
|
2
|
next; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
407
|
|
|
|
|
29427
|
my %base = validate_with( |
|
80
|
|
|
|
|
|
|
params => \%html_params, |
|
81
|
|
|
|
|
|
|
spec => \%html_spec, |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my %build = validate_with( |
|
85
|
|
|
|
|
|
|
params => $args{params}, |
|
86
|
|
|
|
|
|
|
spec => $args{spec}, |
|
87
|
407
|
|
|
|
|
4773
|
); |
|
88
|
|
|
|
|
|
|
|
|
89
|
407
|
|
|
|
|
2068
|
my %modifier = validate_with( |
|
90
|
|
|
|
|
|
|
params => \%modifier_params, |
|
91
|
|
|
|
|
|
|
spec => \%modifier_spec, |
|
92
|
|
|
|
|
|
|
); |
|
93
|
|
|
|
|
|
|
|
|
94
|
407
|
|
|
|
|
706
|
for my $element (qw/before_element after_element children/) { |
|
95
|
1221
|
50
|
|
|
|
1714
|
if ( defined $modifier{$element} ) { |
|
96
|
0
|
|
|
|
|
0
|
my @elements = $self->build_elements( @{ $modifier{$element} } ); |
|
|
0
|
|
|
|
|
0
|
|
|
97
|
0
|
|
|
|
|
0
|
$base{$element} = \@elements; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
407
|
100
|
66
|
|
|
842
|
if (scalar keys %modifier and $self->can('modify')) { |
|
102
|
1
|
|
|
|
|
4
|
return $self->modify(\%base, \%build, \%modifier); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
406
|
|
|
|
|
3890
|
return \%base, \%build, \%modifier; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub build_elements { |
|
109
|
5
|
|
|
5
|
0
|
2862
|
my $self = shift; |
|
110
|
5
|
|
|
|
|
8
|
my @elements_build_instructions = @_; |
|
111
|
|
|
|
|
|
|
|
|
112
|
5
|
|
|
|
|
3
|
my @elements; |
|
113
|
5
|
|
|
|
|
8
|
for my $build (@elements_build_instructions) { |
|
114
|
5
|
|
|
|
|
4
|
my $element; |
|
115
|
5
|
100
|
66
|
|
|
30
|
if ( is_blessed_ref($build) and $build->isa('Moonshine::Element') ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
1
|
$element = $build; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
elsif ( my $action = delete $build->{action} ) { |
|
119
|
1
|
50
|
33
|
|
|
9
|
$self->can($action) and $element = $self->$action($build) |
|
120
|
|
|
|
|
|
|
or die "cannot find action - $action"; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
elsif ( defined $build->{tag} ) { |
|
123
|
1
|
|
|
|
|
9
|
$element = Moonshine::Element->new($build); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
else { |
|
126
|
|
|
|
|
|
|
my $error_string = |
|
127
|
2
|
|
|
|
|
3
|
join( ", ", map { "$_: $build->{$_}" } keys %{$build} ); |
|
|
3
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
4
|
|
|
128
|
2
|
|
|
|
|
17
|
die sprintf "no instructions to build the element: %s", |
|
129
|
|
|
|
|
|
|
$error_string; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
3
|
|
|
|
|
1211
|
push @elements, $element; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
3
|
|
|
|
|
11
|
return @elements; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__END__ |