blib/lib/Clustericious/Command/generate/client.pm

filter: Statementstmt 47.5% 19 / 40 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 62.5% 5 / 8 Podpod 100% 1 / 1 totaltotal 39.0% 25 / 64 CC 8 SCAR 26.1
CC
8
Cov
35%
run
30.0
_installfile
12.0
__ANON__
6.0
CRAP 13.5
« blib/lib/Clustericious/Command/configdebug.pm ↑ Summary blib/lib/Clustericious/Command/lighttpd.pm »
1 package Clustericious::Command::generate::client;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mojo::Base 'Clustericious::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Basename qw( basename );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Clustericious command to generate a new Clustericious client
10 1 our $VERSION = '1.29'; # VERSION
11  
12  
13 1 has description => <<'EOF';
14 Generate Clustericious::Client-derived client.
15 EOF
16  
17 1 has usage => <<"EOF";
18 usage: $0 generate client [SERVER APP NAME]
19 EOF
20  
21 sub _installfile
22 0 ▶{
Subroutine _installfile: not called CC=3 SCAR=24.8
23 0 my $self = shift;
24 0 my ($templatedir, $file, $serverclass, $moduledir) = @_;
25  
26 0 my $name = lc $serverclass;
27  
28 0 (my $relpath = $file) =~ s/^$templatedir/$moduledir/;
29 0 $relpath =~ s/APPCLASS/$serverclass/g;
30 0 $relpath =~ s/APPNAME/$name/g;
31  
32 0 ▶ return if -e $relpath;
Branch: 1 branch
BranchTrueFalseTotal
if -e $relpath 0 0 0
33  
34 0 my $content = Mojo::Template->new->render_file( $file, $serverclass );
35 0 $self->write_file($relpath, $content );
36 0 ▶ -x $file && $self->chmod_file($relpath, 0755);
Branch: 1 branch
BranchTrueFalseTotal
-x $file and $self->chmod_file($relpath, 493) 0 0 0
37 }
38  
39 sub run
40 0 ▶{
Subroutine run: not called CC=5 SCAR=34.0
Pod documented
41 0 my ($self, $serverclass, @args ) = @_;
42 0 ▶ $serverclass ||= 'MyClustericiousApp';
Condition0%0/2
$serverclass ||= "MyClustericiousApp"
l!l
00
MC/DC0%0/1
$serverclass ||= "MyClustericiousApp"
$serverclass
Truth table0%0/2
A
A= $serverclass
Aresult
11
00
43 0 ▶ if (@args % 2)
Branch: 1 branch
BranchTrueFalseTotal
if (@args % 2) 0 0 0
44 {
45 0 die "usage : $0 generate client <app_name>\n";
46 }
47 0 my %args = @args;
48  
49 0 ▶ die "app_name should be the server name" if $serverclass =~ /\-/;
Branch: 1 branch
BranchTrueFalseTotal
if $serverclass =~ /\-/u 0 0 0
50  
51 0 my $moduledir = $serverclass.'-Client';
52  
53 0 my $templatedir = Clustericious->_dist_dir->subdir('tmpl', '1.08', 'client');
54  
55 0 ▶ die "Can't find template in $templatedir.\n" unless -d $templatedir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $templatedir 0 0 0
56  
57 0 ▶ find({wanted => sub { $self->_installfile($templatedir, $_, $serverclass, $moduledir) if -f },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if -f $_ 0 0 0
58 0 no_chdir => 1}, $templatedir);
59 }
60  
61 1 1;
62  
63 __END__
« blib/lib/Clustericious/Command/configdebug.pm ↑ Summary blib/lib/Clustericious/Command/lighttpd.pm »