File Coverage

blib/lib/Egg/Helper/View/Mail.pm
Criterion Covered Total %
statement 6 25 24.0
branch 0 8 0.0
condition 0 6 0.0
subroutine 2 4 50.0
pod n/a
total 8 43 18.6


line stmt bran cond sub pod time code
1             package Egg::Helper::View::Mail;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: Mail.pm 285 2008-02-28 04:20:55Z lushe $
6             #
7 1     1   722 use strict;
  1         2  
  1         39  
8 1     1   5 use warnings;
  1         3  
  1         436  
9              
10             our $VERSION= '0.01';
11              
12             sub _start_helper {
13 0     0     my($self)= @_;
14 0           my $c= $self->config;
15 0 0         $c->{helper_option}{project_root} || return $self->_helper_help
16             ('I want you to start from helper of the project.');
17 0   0       my $comp_name= ucfirst( shift( @ARGV ) )
18             || return $self->_helper_help('I want component name.');
19 0 0         $comp_name=~m{^[A-Z][A-Za-z0-9\_]+$}
20             || return $self->_helper_help('Bad format of component name.');
21 0           my $o= $self->_helper_get_options;
22 0   0       my $version= $self->helper_valid_version_number($o->{version}) || return 0;
23 0           my $param= $self->helper_prepare_param({
24             module_version=> $version,
25             created=> __PACKAGE__. " v$VERSION",
26             });
27 0           $self->helper_prepare_param_module
28             ($param, $self->project_name, qw/ View Mail /, $comp_name);
29 0           my $comp_path= $param->{module_output_filepath}=
30             "$param->{output_path}/lib/$param->{module_filepath}";
31 0 0         -e $comp_path
32             and return $self->_helper_help("'$comp_path' already exists.");
33 0           $self->helper_generate_files(
34             param => $param,
35             chdir => [$param->{output_path}],
36             create_files => [$self->helper_yaml_load(join '', <DATA>)],
37             errors => { unlink=> [$comp_path] },
38             complete_msg => "\nMail controller generate is completed.\n\n"
39             . "output path : $comp_path\n\n"
40             );
41 0           $self;
42             }
43             sub _helper_help {
44 0     0     my $self = shift;
45 0   0       my $msg = shift || "";
46 0           my $pname= lc $self->project_name;
47 0 0         $msg= "ERROR: ${msg}\n\n" if $msg;
48 0           print <<END_HELP;
49             ${msg}% perl ${pname}_helper.pl V::Mail [COMPONENT_NAME]
50              
51             END_HELP
52 0           0;
53             }
54              
55             1;
56              
57             =head1 NAME
58              
59             Egg::Helper::Model::Session - Helper who generates MAIL controller.
60              
61             =head1 SYNOPSIS
62              
63             % cd /path/to/MyApp/bin
64             % ./myapp_helper.pl V::Mail MyController
65             ..........
66             ......
67              
68             =head1 DESCRIPTION
69              
70             It is a helper who generates the MAIL controller to use it with L<Egg::View::Mail>
71             under the control of 'lib' directory of the project.
72              
73             It starts specifying the View::Mail mode and the generated module name for the
74             helper script of the project to use it.
75              
76             % ./myapp_helper.pl View::Mail [MODULE_NAME]
77              
78             Then, /path/to/MyApp/lib/MyApp/View/Mail/[MODULE_NAME].pm is generated.
79              
80             It is corrected that the configuration and the component, etc. are set up in this
81             module after it generates it and uses it.
82              
83             =head1 SEE ALSO
84              
85             L<Egg::Release>,
86             L<Egg::View::Mail>,
87             L<Egg::View::Mail::Base>,
88              
89             =head1 AUTHOR
90              
91             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
92              
93             =head1 COPYRIGHT AND LICENSE
94              
95             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved.
96              
97             This library is free software; you can redistribute it and/or modify
98             it under the same terms as Perl itself, either Perl version 5.8.6 or,
99             at your option, any later version of Perl 5 you may have available.
100              
101             =cut
102              
103              
104             __DATA__
105             filename: <e.module_output_filepath>
106             value: |
107             package <e.module_distname>;
108             use strict;
109             use warnings;
110             use base qw/ Egg::View::Mail::Base /;
111            
112             our $VERSION= '<e.module_version>';
113            
114             __PACKAGE__->config(
115             # label_name => 'mail_label',
116             smtp_host => 'localhost',
117             # timeout => 3,
118             # to => 'myname@mydomain',
119             # from => 'myname@mydomain',
120             # reply_to => 'myname@mydomain',
121             # return_path=> 'myname@mydomain',
122             # subject => 'It inquires.',
123             );
124            
125             __PACKAGE__->setup_plugin(qw/
126             EmbAgent
127             Signature
128             /);
129            
130             __PACKAGE__->setup_mailer( SMTP => qw/
131             MIME::Entity
132             /);
133            
134             # __PACKAGE__->setup_template( Mason => 'mail/inquiry.tt' );
135            
136             1;
137            
138             __END__
139             <e.document>