line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Egg::Helper::Build::Plugin; |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# $Id: Plugin.pm 337 2008-05-14 12:30:09Z lushe $ |
6
|
|
|
|
|
|
|
# |
7
|
1
|
|
|
1
|
|
443
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
9
|
1
|
|
|
1
|
|
5
|
use base qw/ Egg::Helper::Build::Module /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
649
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION= '3.00'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _start_helper { |
14
|
0
|
|
|
0
|
|
|
my($self)= @_; |
15
|
0
|
|
|
|
|
|
my $c= $self->config; |
16
|
0
|
0
|
|
|
|
|
$c->{helper_option}{project_root} || return $self->_helper_help |
17
|
|
|
|
|
|
|
('I want you to start from helper of the project.'); |
18
|
0
|
|
0
|
|
|
|
my $plugin_name= shift(@ARGV) |
19
|
|
|
|
|
|
|
|| return $self->_helper_help('I want plugin name.'); |
20
|
0
|
0
|
|
|
|
|
if ($plugin_name=~m{^\+}) { |
|
|
0
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$plugin_name=~s{^\++} []; |
22
|
|
|
|
|
|
|
} elsif ($plugin_name!~m{^Egg(?:\:+|\-)Plugin}) { |
23
|
0
|
|
|
|
|
|
$plugin_name=~s{^(?:\:|\-)+} []; |
24
|
0
|
|
|
|
|
|
$plugin_name= "Egg::Plugin::$plugin_name"; |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
0
|
|
|
|
my $parts= $self->helper_mod_name_split($plugin_name) |
27
|
|
|
|
|
|
|
|| return $self->_helper_help('Bad format of plugin name.'); |
28
|
0
|
|
|
|
|
|
my $o= $self->_helper_get_options; |
29
|
0
|
|
0
|
|
|
|
my $version= $self->helper_valid_version_number($o->{version}) || return 0; |
30
|
0
|
|
0
|
|
|
|
my $param = $self->helper_prepare_param({ |
31
|
|
|
|
|
|
|
output_path => ($o->{output} || undef), |
32
|
|
|
|
|
|
|
module_version => $version, |
33
|
|
|
|
|
|
|
module_generator => __PACKAGE__, |
34
|
|
|
|
|
|
|
}); |
35
|
0
|
|
|
|
|
|
$self->helper_prepare_param_module($param, $parts); |
36
|
0
|
|
|
|
|
|
my $plugin_path= $param->{module_output_filepath}= |
37
|
|
|
|
|
|
|
"$param->{output_path}/lib/$param->{module_filepath}"; |
38
|
0
|
0
|
|
|
|
|
-e $plugin_path |
39
|
|
|
|
|
|
|
and return $self->_helper_help("$plugin_path A already exists."); |
40
|
0
|
|
|
|
|
|
$self->helper_generate_files( |
41
|
|
|
|
|
|
|
param => $param, |
42
|
|
|
|
|
|
|
chdir => [$param->{output_path}], |
43
|
|
|
|
|
|
|
create_files => [$self->helper_mod_template->[0]], |
44
|
|
|
|
|
|
|
errors => { unlink=> [$plugin_path] }, |
45
|
|
|
|
|
|
|
complete_msg => "\nPlugin generate is completed.\n\n" |
46
|
|
|
|
|
|
|
. "output path : $plugin_path\n" |
47
|
|
|
|
|
|
|
); |
48
|
0
|
|
|
|
|
|
$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
sub _helper_help { |
51
|
0
|
|
|
0
|
|
|
my $self = shift; |
52
|
0
|
|
0
|
|
|
|
my $msg = shift || ""; |
53
|
0
|
|
|
|
|
|
my $pname= lc $self->project_name; |
54
|
0
|
0
|
|
|
|
|
$msg= "ERROR: ${msg}\n\n" if $msg; |
55
|
0
|
|
|
|
|
|
print <<END_HELP; |
56
|
|
|
|
|
|
|
${msg}% perl ${pname}_helper.pl Build::Plugin [PLUGIN_NAME] [-o OUTPUT_PATH] [-v VERSION] |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
END_HELP |
59
|
0
|
|
|
|
|
|
0; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Egg::Helper::Build::Plugin - The template of the plugin module is generated. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
% cd /path/to/MyApp/bin |
73
|
|
|
|
|
|
|
% ./myapp_helper.pl Build::Plugin PluginName |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
It is a plugin to generate the templete of plugin module. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
The name of the option to start this module and the generated plugin is specified |
80
|
|
|
|
|
|
|
for the helper of the project. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
% ./myapp_helper.pl Build::Plugin [PLUGIN_NAME] |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
It is treated as a name of the plugin putting up 'Egg::Plugin' to the head of |
85
|
|
|
|
|
|
|
PLUGIN_NAME usually. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
When the full name is specified for the plug-in name, it specifies it applying |
88
|
|
|
|
|
|
|
'+' to the head. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
% ./myapp_helper.pl Build::Plugin +MyAApp::Plugin::Any |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The template of the module is generated by the subordinate of passing the library |
93
|
|
|
|
|
|
|
of the project. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
% vi /path/to/MyApp/lib/Egg/Plugin/PluginName.pm |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Please refer to the document of L<Egg> for the method of making the plugin module. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SEE ALSO |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<Egg::Release>, |
102
|
|
|
|
|
|
|
L<Egg::Helper>, |
103
|
|
|
|
|
|
|
L<Egg::Helper::Build::Module>, |
104
|
|
|
|
|
|
|
L<Egg>, |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
115
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
116
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|