line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Egg::Helper::Config::YAML; |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# $Id: YAML.pm 337 2008-05-14 12:30:09Z lushe $ |
6
|
|
|
|
|
|
|
# |
7
|
1
|
|
|
1
|
|
383
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
4
|
use base qw/ Egg::Plugin::File::Rotate /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
351
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION= '3.00'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _start_helper { |
14
|
0
|
|
|
0
|
|
|
my($self)= @_; |
15
|
0
|
|
|
|
|
|
my $o= $self->_helper_get_options; |
16
|
0
|
0
|
|
|
|
|
$o->{help} and return $self->_helper_help; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $project= $self->project_name; |
19
|
0
|
|
|
|
|
|
my $param= $self->helper_prepare_param; |
20
|
0
|
|
|
|
|
|
$param->{yaml_name}= lc($project). '.yaml'; |
21
|
0
|
0
|
|
|
|
|
if (my $basepath= $o->{output_path}) { |
22
|
0
|
|
|
|
|
|
$param->{yaml_path}= "$basepath/$param->{yaml_name}"; |
23
|
|
|
|
|
|
|
} else { |
24
|
0
|
|
|
|
|
|
$param->{yaml_path}= $self->path_to('etc', $param->{yaml_name}); |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
$self->rotate($param->{yaml_path}); |
27
|
0
|
|
|
|
|
|
my $template= $self->helper_yaml_load(join '', <DATA>); |
28
|
0
|
|
|
|
|
|
eval { $self->helper_create_file($template, $param) }; |
|
0
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if (my $err= $@) { |
30
|
0
|
|
|
|
|
|
$self->rotate($param->{yaml_path}, reverse=> 1 ); |
31
|
0
|
|
|
|
|
|
$self->_helper_help($err); |
32
|
|
|
|
|
|
|
} else { |
33
|
0
|
|
|
|
|
|
print <<END_EXEC; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
... completed. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
output-path: $param->{yaml_path} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
>>> Please edit the 'Controller' as follows. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package $project; |
42
|
|
|
|
|
|
|
use Egg qw/ ...... /; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__PACKAGE__->egg_startup(\\'$param->{yaml_path}'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
* Passing YAML is given by the SCALAR reference. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
END_EXEC |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
sub _helper_help { |
54
|
0
|
|
|
0
|
|
|
my $self = shift; |
55
|
0
|
|
0
|
|
|
|
my $msg = shift || ""; |
56
|
0
|
|
|
|
|
|
my $pname= lc $self->project_name; |
57
|
0
|
0
|
|
|
|
|
$msg= "ERROR: ${msg}\n\n" if $msg; |
58
|
0
|
|
|
|
|
|
print <<END_HELP; |
59
|
|
|
|
|
|
|
${msg}% perl ${pname}_helper.pl Config::YAML [-o OUTPUT_PATH] |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
END_HELP |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Egg::Helper::Config::YAML - The configuration of the YAML format is output. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
% cd /path/to/MyApp/bin |
73
|
|
|
|
|
|
|
% ./myapp_helper.pl Config::YAML |
74
|
|
|
|
|
|
|
...... |
75
|
|
|
|
|
|
|
... |
76
|
|
|
|
|
|
|
% vi ./etc/myapp.yaml |
77
|
|
|
|
|
|
|
....... |
78
|
|
|
|
|
|
|
.... |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
And, the controller is edited. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
% cd /path/to/MyApp |
83
|
|
|
|
|
|
|
% vi ./lib/myapp.pm |
84
|
|
|
|
|
|
|
package MyApp; |
85
|
|
|
|
|
|
|
........ |
86
|
|
|
|
|
|
|
.... |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__PACKAGE__->egg_startup(\'/path/to/MyApp/etc/myapp.yaml'); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
It is a helper who output the sample of the configuration of YAML format. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The file is output to 'etc' directory of the project. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
To pass passing this file to 'egg_startup' by the SCALAR reference after it |
97
|
|
|
|
|
|
|
outputs it, the controller is edited. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
When the project is started by this, the configuration of the YAML form comes to |
100
|
|
|
|
|
|
|
be read. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
It is L<Egg::Plugin::ConfigLoader> in the plugin. Please do not forget to specify. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
If the great this file already exists when outputting it, the file rotation is done. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<Egg::Release>, |
109
|
|
|
|
|
|
|
L<Egg::Helper>, |
110
|
|
|
|
|
|
|
L<Egg::Plugin::ConfigLoader>, |
111
|
|
|
|
|
|
|
L<Egg::Plugin::File::Rotate>, |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
122
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
123
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
__DATA__ |
130
|
|
|
|
|
|
|
filename: <e.yaml_path> |
131
|
|
|
|
|
|
|
value: | |
132
|
|
|
|
|
|
|
# |
133
|
|
|
|
|
|
|
# <e.project_name> project - <e.yaml_name> |
134
|
|
|
|
|
|
|
# |
135
|
|
|
|
|
|
|
# output date: <e.gmtime_string> GMT |
136
|
|
|
|
|
|
|
# |
137
|
|
|
|
|
|
|
# $Id: YAML.pm 337 2008-05-14 12:30:09Z lushe $ |
138
|
|
|
|
|
|
|
# |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
title: <e.project_name> |
141
|
|
|
|
|
|
|
root: <e.project_root> |
142
|
|
|
|
|
|
|
static_uri: / |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
dir: |
145
|
|
|
|
|
|
|
lib: \<e.root>/lib |
146
|
|
|
|
|
|
|
htdocs: \<e.root>/htdocs |
147
|
|
|
|
|
|
|
etc: \<e.root>/etc |
148
|
|
|
|
|
|
|
cache: \<e.root>/cache |
149
|
|
|
|
|
|
|
tmp: \<e.root>/tmp |
150
|
|
|
|
|
|
|
template: \<e.root>/root |
151
|
|
|
|
|
|
|
comp: \<e.root>/comp |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Character code for processing. |
154
|
|
|
|
|
|
|
# character_in: euc |
155
|
|
|
|
|
|
|
# disable_encode_query: 0 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Template. |
158
|
|
|
|
|
|
|
# template_default_name: index |
159
|
|
|
|
|
|
|
# template_extension: .tt |
160
|
|
|
|
|
|
|
template_path: |
161
|
|
|
|
|
|
|
- \<e.dir.template> |
162
|
|
|
|
|
|
|
- \<e.dir.comp> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# Default content type and language. |
165
|
|
|
|
|
|
|
# charset_out: euc-jp |
166
|
|
|
|
|
|
|
# content_type: text/html |
167
|
|
|
|
|
|
|
# content_language: ja |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# Regular expression of Content-Type that doesn't send Content-Length. |
170
|
|
|
|
|
|
|
# no_content_length_regex: (?:^text/|/(?:rss\+)?xml) |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# Upper bound of request directory hierarchy. |
173
|
|
|
|
|
|
|
# max_snip_deep: 10 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# Accessor to stash. * Do not overwrite a regular method. |
176
|
|
|
|
|
|
|
# accessor_names: |
177
|
|
|
|
|
|
|
# - hoge |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Cookie default setup. |
180
|
|
|
|
|
|
|
# cookie_default: |
181
|
|
|
|
|
|
|
# domain: mydomain |
182
|
|
|
|
|
|
|
# path: / |
183
|
|
|
|
|
|
|
# expires: 0 |
184
|
|
|
|
|
|
|
# secure: 0 |
185
|
|
|
|
|
|
|
# }, |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# MODEL: |
188
|
|
|
|
|
|
|
# - |
189
|
|
|
|
|
|
|
# - DBI |
190
|
|
|
|
|
|
|
# - dsn: dbi:SQLite;dbname=\<e.dir.etc>/data.db |
191
|
|
|
|
|
|
|
# user: |
192
|
|
|
|
|
|
|
# password: |
193
|
|
|
|
|
|
|
# options: |
194
|
|
|
|
|
|
|
# AutoCommit: 1 |
195
|
|
|
|
|
|
|
# RaiseError: 1 |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# VIEW: |
198
|
|
|
|
|
|
|
# - |
199
|
|
|
|
|
|
|
# - Mason |
200
|
|
|
|
|
|
|
# - comp_root: |
201
|
|
|
|
|
|
|
# - |
202
|
|
|
|
|
|
|
# - main |
203
|
|
|
|
|
|
|
# - \<e.dir.template> |
204
|
|
|
|
|
|
|
# - |
205
|
|
|
|
|
|
|
# - private |
206
|
|
|
|
|
|
|
# - \<e.dir.comp> |
207
|
|
|
|
|
|
|
# data_dir: \<e.dir.tmp> |
208
|
|
|
|
|
|
|
# - |
209
|
|
|
|
|
|
|
# - HT |
210
|
|
|
|
|
|
|
# - path: |
211
|
|
|
|
|
|
|
# - \<e.dir.template> |
212
|
|
|
|
|
|
|
# - \<e.dir.comp> |
213
|
|
|
|
|
|
|
# global_vars: 1 |
214
|
|
|
|
|
|
|
# die_on_bad_params: 0 |
215
|
|
|
|
|
|
|
# cache: 1 |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# request: |
218
|
|
|
|
|
|
|
# DISABLE_UPLOADS: 0 |
219
|
|
|
|
|
|
|
# TEMP_DIR: \<e.dir.tmp> |
220
|
|
|
|
|
|
|
# POST_MAX: 10240 |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# * For ErrorDocument plugin. |
223
|
|
|
|
|
|
|
# plugin_error_document: |
224
|
|
|
|
|
|
|
# view_name: Mason |
225
|
|
|
|
|
|
|
# template: error/document.tt |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# * For FillInForm plugin. |
228
|
|
|
|
|
|
|
# plugin_fillinform: |
229
|
|
|
|
|
|
|
# ignore_fields: |
230
|
|
|
|
|
|
|
# - ticket |
231
|
|
|
|
|
|
|
# fill_password: 0 |
232
|
|
|
|
|
|
|
|