| 1 | package Catalyst::Helper::Model::EmailStore; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use File::Spec; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | =head1 NAME | ||||||||||||
| 8 | |||||||||||||
| 9 | Catalyst::Helper::Model::EmailStore - Helper for EmailStore Models | ||||||||||||
| 10 | |||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||
| 12 | |||||||||||||
| 13 | script/create.pl model EmailStore EmailStore dsn user password | ||||||||||||
| 14 | |||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||
| 16 | |||||||||||||
| 17 | Helper for EmailStore Model. | ||||||||||||
| 18 | |||||||||||||
| 19 | =head2 METHODS | ||||||||||||
| 20 | |||||||||||||
| 21 | =over 4 | ||||||||||||
| 22 | |||||||||||||
| 23 | =item mk_compclass | ||||||||||||
| 24 | |||||||||||||
| 25 | Reads the Email::Store plugin setup and makes a main model class as well as | ||||||||||||
| 26 | placeholders for each plugin that was found. | ||||||||||||
| 27 | |||||||||||||
| 28 | =item mk_comptest | ||||||||||||
| 29 | |||||||||||||
| 30 | Makes tests for the EmailStore Model. | ||||||||||||
| 31 | |||||||||||||
| 32 | =back | ||||||||||||
| 33 | |||||||||||||
| 34 | =cut | ||||||||||||
| 35 | |||||||||||||
| 36 | 0 | ▶ | sub mk_compclass { | ||||||||||
|
Subroutine
mk_compclass: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||
| 37 | 0 | my ( $self, $helper, $dsn, $user, $pass ) = @_; | |||||||||||
| 38 | 0 | ▶ | $helper->{dsn} = $dsn || ''; | ||||||||||
|
Condition0%0/2
$dsn || ''
MC/DC0%0/1
$dsn || ''
$dsn
Truth table0%0/2
A
A= $dsn
| |||||||||||||
| 39 | 0 | ▶ | $helper->{user} = $user || ''; | ||||||||||
|
Condition0%0/2
$user || ''
MC/DC0%0/1
$user || ''
$user
Truth table0%0/2
A
A= $user
| |||||||||||||
| 40 | 0 | ▶ | $helper->{pass} = $pass || ''; | ||||||||||
|
Condition0%0/2
$pass || ''
MC/DC0%0/1
$pass || ''
$pass
Truth table0%0/2
A
A= $pass
| |||||||||||||
| 41 | 0 | my $file = $helper->{file}; | |||||||||||
| 42 | 0 | $helper->{classes} = []; | |||||||||||
| 43 | 0 | $helper->render_file( 'cdbiclass', $file ); | |||||||||||
| 44 | # push( @{ $helper->{classes} }, $helper->{class} ); | ||||||||||||
| 45 | 0 | ▶ | return 1 unless $dsn; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | |||||||||||||
| 47 | 0 | require Module::Pluggable::Ordered; | |||||||||||
| 48 | 0 | Module::Pluggable::Ordered->import | |||||||||||
| 49 | ( inner => 1, search_path => [ "Email::Store" ] ); | ||||||||||||
| 50 | |||||||||||||
| 51 | 0 | require Email::Store; | |||||||||||
| 52 | |||||||||||||
| 53 | 0 | my $path = $file; | |||||||||||
| 54 | 0 | $path =~ s/\.pm$//; | |||||||||||
| 55 | 0 | $helper->mk_dir($path); | |||||||||||
| 56 | |||||||||||||
| 57 | |||||||||||||
| 58 | 0 | my $prefix = $helper->{app} . '::Model::EmailStore'; | |||||||||||
| 59 | 0 | for my $c ( $self->plugins ) { | |||||||||||
| 60 | |||||||||||||
| 61 | 0 | ▶ | next if $c eq 'Email::Store::DBI'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | 0 | ▶ | next unless UNIVERSAL::isa( $c, qw/Class::DBI/ ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | |||||||||||||
| 64 | 0 | my $model = $c; | |||||||||||
| 65 | 0 | $model =~ s/^Email::Store/$prefix/; | |||||||||||
| 66 | 0 | $helper->{tableclass} = $model; | |||||||||||
| 67 | |||||||||||||
| 68 | 0 | ▶ | if ( $model =~ /${prefix}::(.*)$/ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 69 | 0 | my @subpath = split( '::', $1 ); | |||||||||||
| 70 | 0 | my $f = pop @subpath; | |||||||||||
| 71 | 0 | ▶ | $helper->mk_dir( File::Spec->catdir( $path, @subpath ) ) if @subpath; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 72 | 0 | my $p = File::Spec->catfile( $path, @subpath, "$f.pm" ); | |||||||||||
| 73 | 0 | $helper->render_file( 'tableclass', $p ); | |||||||||||
| 74 | 0 | push( @{ $helper->{classes} }, $model ); | |||||||||||
| 75 | } | ||||||||||||
| 76 | } | ||||||||||||
| 77 | 0 | return 1; | |||||||||||
| 78 | } | ||||||||||||
| 79 | |||||||||||||
| 80 | 0 | ▶ | sub mk_comptest { | ||||||||||
|
Subroutine
mk_comptest: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 81 | 0 | my ( $self, $helper ) = @_; | |||||||||||
| 82 | 0 | my $test = $helper->{test}; | |||||||||||
| 83 | 0 | my $name = $helper->{name}; | |||||||||||
| 84 | 0 | for my $c ( @{ $helper->{classes} } ) { | |||||||||||
| 85 | 0 | $helper->{tableclass} = $c; | |||||||||||
| 86 | 0 | my @comps = ( $helper->{tableclass} =~ /\:\:(\w+)\:\:(\w+)$/ ); | |||||||||||
| 87 | 0 | ▶ | shift @comps if $comps[0] =~ /^M(?:odel)?$/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 88 | 0 | ▶ | shift @comps if $comps[0] eq $name; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 89 | 0 | my $prefix = join( '::', $name, @comps ); | |||||||||||
| 90 | 0 | $prefix =~ s/::/-/g; | |||||||||||
| 91 | 0 | $helper->render_file( 'test', $helper->next_test($prefix) ); | |||||||||||
| 92 | } | ||||||||||||
| 93 | } | ||||||||||||
| 94 | |||||||||||||
| 95 | =head1 SEE ALSO | ||||||||||||
| 96 | |||||||||||||
| 97 | L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>, | ||||||||||||
| 98 | L<Catalyst::Response>, L<Catalyst::Helper> | ||||||||||||
| 99 | |||||||||||||
| 100 | =head1 AUTHOR | ||||||||||||
| 101 | |||||||||||||
| 102 | Sebastian Riedel, C<sri@oook.de> | ||||||||||||
| 103 | |||||||||||||
| 104 | =head1 LICENSE | ||||||||||||
| 105 | |||||||||||||
| 106 | This library is free software . You can redistribute it and/or modify | ||||||||||||
| 107 | it under the same terms as perl itself. | ||||||||||||
| 108 | |||||||||||||
| 109 | =cut | ||||||||||||
| 110 | |||||||||||||
| 111 | 2 | 1; | |||||||||||
| 112 | __DATA__ | ||||||||||||