File Coverage

blib/lib/Egg/Helper/Model/Cache.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::Model::Cache;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: Cache.pm 293 2008-02-28 11:00:55Z lushe $
6             #
7 2     2   574 use strict;
  2         3  
  2         62  
8 2     2   11 use warnings;
  2         4  
  2         834  
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/ Model Cache /, $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 => "\nCache 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 M::Cache
50              
51             END_HELP
52 0           0;
53             }
54              
55             1;
56              
57             =head1 NAME
58              
59             Egg::Helper::Model::Cache - Helper to generate CACHE controller.
60              
61             =head1 SYNOPSIS
62              
63             % cd /path/to/MyApp/bin
64             % ./myapp_helper.pl M::Cache
65             ..........
66             ......
67              
68             =head1 DESCRIPTION
69              
70             It is a helper who generates the controller to use it with L<Egg::Model::Cache>
71             under the control of the project.
72              
73             It starts specifying the Model::Cache mode for the helper script of the project
74             to use it.
75              
76             % ./myapp_helper.pl Model::Cache
77              
78             Especially, there is no option needing.
79              
80             =head1 SEE ALSO
81              
82             L<Egg::Release>,
83             L<Egg::Model::Cache>,
84             L<Egg::Model::Cache::Base>,
85              
86             =head1 AUTHOR
87              
88             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved.
93              
94             This library is free software; you can redistribute it and/or modify
95             it under the same terms as Perl itself, either Perl version 5.8.6 or,
96             at your option, any later version of Perl 5 you may have available.
97              
98             =cut
99              
100              
101             __DATA__
102             filename: <e.module_output_filepath>
103             value: |
104             package <e.module_distname>;
105             use strict;
106             use warnings;
107             use base qw/ Egg::Model::Cache::Base /;
108            
109             our $VERSION= '<e.module_version>';
110            
111             __PACKAGE__->config(
112             # label_name => 'cache_name',
113             cache_root => <e.project_name>->path_to('cache'),
114             namespace => 'ModelCache',
115             );
116            
117             __PACKAGE__->setup_cache('Cache::FileCache');
118            
119             1;
120            
121             __END__
122             <e.document>