blib/lib/Catalyst/Helper/Controller/Scaffold.pm

filter: Statementstmt 42.1% 8 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 44.0% 11 / 25 CC 2 SCAR 12.5
CC
2
Cov
38%
mk_compclass
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
↑ Summary
1 package Catalyst::Helper::Controller::Scaffold;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.04';
7  
8 =head1 NAME
9  
10 Catalyst::Helper::Controller::Scaffold - Helper for Scaffolding
11  
12 =head1 SYNOPSIS
13  
14 # Imagine you want to generate a scaffolding controller MyApp::C::SomeTable
15 # for a CDBI table class MyApp::M::CDBI::SomeTable
16 script/myapp_create.pl controller SomeTable Scaffold CDBI::SomeTable
17  
18 =head1 DESCRIPTION
19  
20 Helper for Scaffolding.
21  
22 Templates are TT so you'll need a TT View Component and a forward in
23 your end action too. This can be accomplished with
24 L<Catalyst::Plugin::DefaultEnd>.
25  
26 Note that you have to add these lines to your CDBI class...
27  
28 use Class::DBI::AsForm;
29 use Class::DBI::FromForm;
30  
31 for L<Catalyst::Model::CDBI> you can do that by adding this
32  
33 additional_base_classes => [qw/Class::DBI::AsForm Class::DBI::FromForm/],
34  
35 to the component config. Also, change your application class like this:
36  
37 use Catalyst qw/-Debug FormValidator/;
38  
39 Also, note that the scaffolding uses L<Template::Plugin::Class>, so it will
40 be a requirement for you application as well.
41  
42 =head1 METHODS
43  
44 =over 4
45  
46 =item mk_compclass
47  
48 =cut
49  
50 0 ▶sub mk_compclass {
Subroutine mk_compclass: not called CC=2 SCAR=17.9
Pod documented
51 0 my ( $self, $helper, $table_class ) = @_;
52 0 ▶ my $type = ($helper->{type} eq 'C' ? 'M' : 'Model');
Branch: 1 branch
BranchTrueFalseTotal
$helper->{'type'} eq 'C' ? : 0 0 0
53 0 $helper->{table_class} = "$helper->{app}::${type}::$table_class";
54 0 my $file = $helper->{file};
55 0 my $dir = dir( $helper->{base}, 'root', $helper->{prefix} );
56 0 $helper->mk_dir($dir);
57 0 $helper->render_file( 'compclass', $file );
58 0 $helper->render_file( 'add', file( $dir, 'add.tt' ) );
59 0 $helper->render_file( 'edit', file( $dir, 'edit.tt' ) );
60 0 $helper->render_file( 'list', file( $dir, 'list.tt' ) );
61 0 $helper->render_file( 'view', file( $dir, 'view.tt' ) );
62 }
63  
64 =back
65  
66 =head1 AUTHOR
67  
68 Sebastian Riedel
69  
70 =head1 LICENSE
71  
72 This library is free software . You can redistribute it and/or modify
73 it under the same terms as perl itself.
74  
75 =cut
76  
77 1 1;
78  
79 __DATA__
↑ Summary