line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Generate::Hash; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
136143
|
use 5.006; |
|
2
|
|
|
|
|
17
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
106
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1069
|
use Module::Generate; |
|
2
|
|
|
|
|
603504
|
|
|
2
|
|
|
|
|
89
|
|
10
|
2
|
|
|
2
|
|
19
|
use base 'Import::Export'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1003
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %EX = ( |
13
|
|
|
|
|
|
|
generate => [qw/all/] |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub generate { |
17
|
1
|
50
|
|
1
|
1
|
346
|
my (%generate) = scalar @_ > 1 ? @_ : %{$_[0]}; |
|
0
|
|
|
|
|
0
|
|
18
|
1
|
|
|
|
|
7
|
my $gen = Module::Generate->start; |
19
|
|
|
|
|
|
|
$generate{$_} && $gen->$_($generate{$_}) |
20
|
1
|
|
66
|
|
|
12
|
for (qw/dist lib author email version/); |
21
|
1
|
|
|
|
|
35
|
_build_classes($gen, $generate{classes}); |
22
|
1
|
|
|
|
|
3
|
$gen->generate; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build_classes { |
26
|
2
|
|
|
2
|
|
6
|
my ($gen, $classes, $mod) = @_; |
27
|
2
|
|
|
|
|
3
|
for my $class (keys %{$classes}) { |
|
2
|
|
|
|
|
12
|
|
28
|
2
|
100
|
|
|
|
7
|
my $kls = $mod ? do { |
29
|
|
|
|
|
|
|
$classes->{$class}{base} = $classes->{$class}{base} ? [ |
30
|
1
|
0
|
|
|
|
3
|
(ref $classes->{$class}{base} ? @{$classes->{$class}{base}} : $classes->{$class}{base}), |
|
0
|
50
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
$mod |
32
|
|
|
|
|
|
|
] : $mod; |
33
|
1
|
|
|
|
|
6
|
sprintf( '%s::%s', $mod, $class ); |
34
|
|
|
|
|
|
|
} : $class; |
35
|
|
|
|
|
|
|
my ($cls, $new, $subs, $accessors, $subclass) = ( |
36
|
|
|
|
|
|
|
$gen->class($kls)->new, |
37
|
|
|
|
|
|
|
delete $classes->{$class}{new}, |
38
|
|
|
|
|
|
|
delete $classes->{$class}{subs}, |
39
|
|
|
|
|
|
|
delete $classes->{$class}{accessors}, |
40
|
|
|
|
|
|
|
delete $classes->{$class}{subclass} |
41
|
2
|
|
|
|
|
9
|
); |
42
|
2
|
|
|
|
|
321
|
_itterate_keys($cls, $classes->{$class}); |
43
|
2
|
|
|
|
|
13
|
_itterate_keys($cls, $new); |
44
|
2
|
|
|
|
|
8
|
$cls->accessor($_) for (@{$accessors}); |
|
2
|
|
|
|
|
11
|
|
45
|
2
|
|
|
|
|
261
|
while (scalar @{$subs}) { |
|
7
|
|
|
|
|
43
|
|
46
|
5
|
|
|
|
|
9
|
my ($key, $value) = (shift @{$subs}, shift @{$subs}); |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
9
|
|
47
|
5
|
|
|
|
|
12
|
my $sub = $cls->sub($key); |
48
|
5
|
|
|
|
|
38
|
_itterate_keys($sub, $value); |
49
|
|
|
|
|
|
|
} |
50
|
2
|
100
|
|
|
|
13
|
_build_classes($gen, $subclass, $kls) if ($subclass); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _itterate_keys { |
55
|
9
|
|
|
9
|
|
16
|
my ($m, $value) = @_; |
56
|
9
|
|
|
|
|
11
|
for my $key (keys %{$value}) { |
|
9
|
|
|
|
|
27
|
|
57
|
15
|
|
100
|
|
|
95
|
my $ref = ref $value->{$key} || "SCALAR"; |
58
|
|
|
|
|
|
|
$m->$key( |
59
|
|
|
|
|
|
|
$ref eq 'ARRAY' |
60
|
0
|
|
|
|
|
|
? @{$value->{$key}} |
61
|
15
|
50
|
|
|
|
46
|
: $value->{$key} |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Module::Generate::Hash - Assisting with module generation. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Version 0.06 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use Module::Generate::Hash qw/all/; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
generate( |
81
|
|
|
|
|
|
|
dist => 'Planes', |
82
|
|
|
|
|
|
|
author => 'LNATION', |
83
|
|
|
|
|
|
|
email => 'email@lnation.org', |
84
|
|
|
|
|
|
|
version => '0.01', |
85
|
|
|
|
|
|
|
classes => { |
86
|
|
|
|
|
|
|
Planes => { |
87
|
|
|
|
|
|
|
abstract => 'Over my head.', |
88
|
|
|
|
|
|
|
our => '$type', |
89
|
|
|
|
|
|
|
begin => sub { |
90
|
|
|
|
|
|
|
$type = 'boeing'; |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
accessors => [qw/ |
93
|
|
|
|
|
|
|
airline |
94
|
|
|
|
|
|
|
/], |
95
|
|
|
|
|
|
|
subs => [ |
96
|
|
|
|
|
|
|
type => { |
97
|
|
|
|
|
|
|
code => sub { $type }, |
98
|
|
|
|
|
|
|
pod => 'Returns the type of plane.', |
99
|
|
|
|
|
|
|
example => '$plane->type' |
100
|
|
|
|
|
|
|
}, |
101
|
|
|
|
|
|
|
altitude => { |
102
|
|
|
|
|
|
|
code => sub { |
103
|
|
|
|
|
|
|
$_[1] / $_[2]; |
104
|
|
|
|
|
|
|
... |
105
|
|
|
|
|
|
|
}, |
106
|
|
|
|
|
|
|
pod => 'Discover the altitude of the plane.', |
107
|
|
|
|
|
|
|
example => '$plane->altitude(100, 100)' |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
] |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 Exports |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 generate |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This module exports a single method generate which accepts a hash that is a distribution specification. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
generate(%spec); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
LNATION, C<< <email at lnation.org> >> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 BUGS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-module-generate-hash at rt.cpan.org>, or through |
129
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Generate-Hash>. I will be notified, and then you'll |
130
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SUPPORT |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
perldoc Module::Generate::Hash |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
You can also look for information at: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over 4 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Generate-Hash> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Module-Generate-Hash> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * CPAN Ratings |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/Module-Generate-Hash> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * Search CPAN |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L<https://metacpan.org/release/Module-Generate-Hash> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by LNATION. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This is free software, licensed under: |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; # End of Module::Generate::Hash |