lib/Egg/Helper/View/Mail.pm

filter: Statementstmt 77.7% 21 / 27 Branchbran 37.5% 3 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 3 / 4 Podpod n/a totaltotal 60.4% 29 / 48 CC 8 SCAR 19.4
CC
8
Cov
63%
_helper_help
12.0
_start_helper
6.4
BEGIN
1.0
CRAP 6.9
« blib/lib/Egg/View/Mail/Plugin/SaveBody.pm ↑ Summary blib/lib/Egg/View/Mail/Encode/ISO2022JP.pm »
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 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION= '0.01';
11  
12 1 ▶sub _start_helper {
Subroutine _start_helper: called CC=6 SCAR=18.5
13 1 my($self)= @_;
14 1 my $c= $self->config;
15 1 ▶ $c->{helper_option}{project_root} || return $self->_helper_help
Branch: 1 branch
BranchTrueFalseTotal
$c->{"helper_option"}{"project_root"} or return $self->_helper_help("I want you to start from helper of the project.") 1 0 1
16 ('I want you to start from helper of the project.');
17 1 ▶ my $comp_name= ucfirst( shift( @ARGV ) )
Condition50%1/2
ucfirst shift @ARGV || (return $self->_helper_help('I want component name.'))
l!l
10
MC/DC0%0/1
ucfirst shift @ARGV || (return $self->_helper_help('I want component name.'))
ucfirst shift @ARGV
Truth table50%1/2
A
A= ucfirst shift @ARGV
Aresult
11
00
18 || return $self->_helper_help('I want component name.');
19 1 ▶ $comp_name=~m{^[A-Z][A-Za-z0-9\_]+$}
Branch: 1 branch
BranchTrueFalseTotal
$comp_name =~ /^[A-Z][A-Za-z0-9\_]+$/ or return $self->_helper_help("Bad format of component name.") 1 0 1
20 || return $self->_helper_help('Bad format of component name.');
21 1 my $o= $self->_helper_get_options;
22 1 ▶ my $version= $self->helper_valid_version_number($o->{version}) || return 0;
Condition50%1/2
$self->helper_valid_version_number($o->{'version'}) || (return 0)
l!l
10
MC/DC0%0/1
$self->helper_valid_version_number($o->{'version'}) || (return 0)
$self->helper_valid_version_number($o->{'version'})
Truth table50%1/2
A
A= $self->helper_valid_version_number($o->{'version'})
Aresult
11
00
23 1 my $param= $self->helper_prepare_param({
24 module_version=> $version,
25 created=> __PACKAGE__. " v$VERSION",
26 });
27 1 $self->helper_prepare_param_module
28 ($param, $self->project_name, qw/ View Mail /, $comp_name);
29 my $comp_path= $param->{module_output_filepath}=
30 1 "$param->{output_path}/lib/$param->{module_filepath}";
31 1 ▶ -e $comp_path
Branch: 1 branch
BranchTrueFalseTotal
-e $comp_path and return $self->_helper_help("'${comp_path}' already exists.") 0 1 1
32 and return $self->_helper_help("'$comp_path' already exists.");
33 $self->helper_generate_files(
34 param => $param,
35 1 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 1 $self;
42 }
43 0 ▶sub _helper_help {
Subroutine _helper_help: not called CC=3 SCAR=24.8
44 0 my $self = shift;
45 0 ▶ my $msg = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
46 0 my $pname= lc $self->project_name;
47 0 ▶ $msg= "ERROR: ${msg}\n\n" if $msg;
Branch: 1 branch
BranchTrueFalseTotal
if $msg 0 0 0
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 2 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__
« blib/lib/Egg/View/Mail/Plugin/SaveBody.pm ↑ Summary blib/lib/Egg/View/Mail/Encode/ISO2022JP.pm »