« 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
| |||||||||||||
| 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
| |||||||||||||
| 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"
MC/DC0%0/1
$serverclass ||= "MyClustericiousApp"
$serverclass
Truth table0%0/2
A
A= $serverclass
| |||||||||||||
| 43 | 0 | ▶ | if (@args % 2) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 58 | 0 | no_chdir => 1}, $templatedir); | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | 1 | 1; | |||||||||||
| 62 | |||||||||||||
| 63 | __END__ | ||||||||||||