| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Moonshine::Magic; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
108825
|
use strict; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
113
|
|
|
4
|
5
|
|
|
5
|
|
14
|
use warnings; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
96
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
1886
|
use BEGIN::Lift; |
|
|
5
|
|
|
|
|
20612
|
|
|
|
5
|
|
|
|
|
115
|
|
|
7
|
5
|
|
|
5
|
|
2297
|
use Moonshine::Element; |
|
|
5
|
|
|
|
|
114838
|
|
|
|
5
|
|
|
|
|
211
|
|
|
8
|
5
|
|
|
5
|
|
2068
|
use Moonshine::Util "assert_valid_html5_tag" => { -as => "assert_valid_tag" }; |
|
|
5
|
|
|
|
|
77011
|
|
|
|
5
|
|
|
|
|
94
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
3097
|
use MOP::Class; |
|
|
5
|
|
|
|
|
75040
|
|
|
|
5
|
|
|
|
|
153
|
|
|
11
|
5
|
|
|
5
|
|
27
|
use MOP::Role; |
|
|
5
|
|
|
|
|
5
|
|
|
|
5
|
|
|
|
|
119
|
|
|
12
|
5
|
|
|
5
|
|
16
|
use Carp qw/croak/; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
475
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Moonshine::Magic - d[ o_0 ]b - has, extends, lazy_components |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Version 0.06 |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Moonshine::Magic; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 Imports |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 extends |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
extends 'Moonshine::Component'; |
|
35
|
|
|
|
|
|
|
# BEGIN { @ISA = ('Moonshine::Component') } |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 has |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has ( |
|
40
|
|
|
|
|
|
|
'modify_spec' => sub { { switch => 0, switch_base => 0 } }, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# BEGIN { @HAS = ( 'modify_spec' => sub { { switch => 0, switch_base => 0 } } } |
|
44
|
|
|
|
|
|
|
# $self->modify_spec |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 with |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
with 'Moonshine::Component::Glyphicon'; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 lazy_components |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
lazy_components (qw/p span h1/); |
|
53
|
|
|
|
|
|
|
# $self->span() - |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub import { |
|
58
|
13
|
|
|
13
|
|
1074
|
my $caller = caller; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
BEGIN::Lift::install( |
|
61
|
|
|
|
|
|
|
( $caller, 'extends' ) => sub { |
|
62
|
5
|
|
|
5
|
|
18
|
no strict 'refs'; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
701
|
|
|
63
|
10
|
|
|
10
|
|
800
|
my @extends = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
unshift @extends, 'UNIVERSAL::Object' |
|
66
|
10
|
100
|
|
|
|
16
|
unless grep { $_ eq 'UNIVERSAL::Object' } @extends; |
|
|
10
|
|
|
|
|
39
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
10
|
|
|
|
|
17
|
for (@extends) { |
|
69
|
15
|
|
|
|
|
570
|
eval "require $_"; |
|
70
|
15
|
100
|
|
|
|
451
|
croak $@ if $@; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
8
|
|
|
|
|
8
|
@{"${caller}::ISA"} = @extends; |
|
|
8
|
|
|
|
|
403
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
13
|
|
|
|
|
72
|
); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
BEGIN::Lift::install( |
|
78
|
|
|
|
|
|
|
( $caller, 'has' ) => sub { |
|
79
|
2
|
|
|
2
|
|
14
|
my %args = @_; |
|
80
|
5
|
|
|
5
|
|
61
|
no strict 'refs'; |
|
|
5
|
|
|
|
|
5
|
|
|
|
5
|
|
|
|
|
129
|
|
|
81
|
5
|
|
|
5
|
|
16
|
no warnings 'once'; |
|
|
5
|
|
|
|
|
4
|
|
|
|
5
|
|
|
|
|
2444
|
|
|
82
|
2
|
|
|
|
|
5
|
%{"${caller}::HAS"} = %args; |
|
|
2
|
|
|
|
|
9
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
10
|
my $class = MOP::Class->new($caller); |
|
85
|
2
|
|
|
|
|
64
|
for my $arg ( keys %args ) { |
|
86
|
4
|
|
|
0
|
|
59
|
$class->add_method( $arg, sub { return $args{$arg}->(); } ); |
|
|
0
|
|
|
0
|
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
13
|
|
|
|
|
1051
|
); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
BEGIN::Lift::install( |
|
92
|
|
|
|
|
|
|
( $caller, 'with' ) => sub { |
|
93
|
5
|
|
|
5
|
|
391
|
my @roles = @_; |
|
94
|
5
|
50
|
|
|
|
10
|
croak "No roles supplied!" unless @roles; |
|
95
|
5
|
|
|
|
|
14
|
my $class = MOP::Class->new($caller); |
|
96
|
5
|
|
|
|
|
147
|
for my $r (@roles) { |
|
97
|
7
|
|
|
|
|
405
|
eval "require $r"; |
|
98
|
7
|
50
|
|
|
|
649
|
croak $@ if $@; |
|
99
|
|
|
|
|
|
|
|
|
100
|
7
|
|
|
|
|
19
|
my $role = MOP::Class->new($r); |
|
101
|
7
|
|
|
|
|
200
|
for my $meth ( $role->all_methods ) { |
|
102
|
18
|
50
|
|
|
|
956
|
next if $meth->name eq '__ANON__'; |
|
103
|
18
|
|
|
|
|
147
|
$class->add_method( $meth->name, $meth->body ); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
7
|
|
|
|
|
167
|
for my $slot ( $role->all_slots ) { |
|
107
|
7
|
50
|
|
|
|
293
|
next if $class->has_slot($slot->name); |
|
108
|
7
|
|
|
|
|
157
|
$class->alias_slot( $slot->name, $slot->initializer ); |
|
109
|
7
|
100
|
|
|
|
361
|
next if $class->has_method($slot->name); |
|
110
|
2
|
|
|
|
|
27
|
$class->add_method( $slot->name, $slot->initializer ); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
13
|
|
|
|
|
823
|
); |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
BEGIN::Lift::install( |
|
117
|
|
|
|
|
|
|
( $caller, 'lazy_components' ) => sub { |
|
118
|
0
|
|
|
0
|
|
|
my @lazy_components = @_; |
|
119
|
0
|
|
|
|
|
|
my $class = MOP::Class->new($caller); |
|
120
|
0
|
|
|
|
|
|
for my $component (@lazy_components) { |
|
121
|
0
|
0
|
|
|
|
|
next unless assert_valid_tag($component); |
|
122
|
|
|
|
|
|
|
$class->add_method( |
|
123
|
|
|
|
|
|
|
$component, |
|
124
|
|
|
|
|
|
|
sub { |
|
125
|
0
|
|
|
|
|
|
my $self = shift; |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my ( $base_args, $build_args ) = (); |
|
128
|
0
|
0
|
|
|
|
|
if ( $self->can('validate_build') ) { |
|
129
|
|
|
|
|
|
|
( $base_args, $build_args ) = $self->validate_build( |
|
130
|
|
|
|
|
|
|
{ |
|
131
|
|
|
|
|
|
|
params => $_[0] // {}, |
|
132
|
|
|
|
|
|
|
spec => { |
|
133
|
|
|
|
|
|
|
tag => { default => $component }, |
|
134
|
|
|
|
|
|
|
data => 0, |
|
135
|
0
|
0
|
0
|
|
|
|
( $_[1] ? %{ $_[1] } : () ) |
|
|
0
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
else { |
|
141
|
0
|
|
|
|
|
|
$base_args = { tag => $component, %{ $_[0] } }; |
|
|
0
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
return Moonshine::Element->new($base_args); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
|
|
|
|
|
); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
} |
|
149
|
13
|
|
|
|
|
781
|
); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHOR |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Robert Acock, C<< >> |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 BUGS |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
159
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
160
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SUPPORT |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
perldoc Moonshine::Magic |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
You can also look for information at: |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=over 4 |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
L |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * Search CPAN |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
L |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=back |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Copyright 2017 Robert Acock. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
199
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
200
|
|
|
|
|
|
|
copy of the full license at: |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
L |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
|
205
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
|
206
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
|
207
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
|
210
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
|
211
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
|
214
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
|
217
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
|
218
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
|
219
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
|
220
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
|
221
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
|
222
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
|
223
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
|
226
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
|
227
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
228
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
|
229
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
|
230
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
|
231
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
|
232
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; # End of Moonshine::Magic |