| 1 | package Clustericious::Command::generate::app; | ||||||||||||
| 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 Clustericious; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Mojo::Base 'Clustericious::Command'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use File::Find; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | # ABSTRACT: Clustericious command to generate a new Clustericious application | ||||||||||||
| 10 | 1 | our $VERSION = '1.29'; # VERSION | |||||||||||
| 11 | |||||||||||||
| 12 | |||||||||||||
| 13 | 1 | has description => <<'EOF'; | |||||||||||
| 14 | Generate Clustericious app. | ||||||||||||
| 15 | EOF | ||||||||||||
| 16 | |||||||||||||
| 17 | 1 | has usage => <<"EOF"; | |||||||||||
| 18 | usage: $0 generate 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, $class) = @_; | |||||||||||
| 25 | |||||||||||||
| 26 | 0 | my $name = lc $class; | |||||||||||
| 27 | |||||||||||||
| 28 | 0 | (my $relpath = $file) =~ s/^$templatedir/$class/; | |||||||||||
| 29 | 0 | $relpath =~ s/APPCLASS/$class/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, $class ); | |||||||||||
| 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=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 41 | 0 | my ($self, $class, @args ) = @_; | |||||||||||
| 42 | 0 | ▶ | $class ||= 'MyClustericiousApp'; | ||||||||||
|
Condition0%0/2
$class ||= "MyClustericiousApp"
MC/DC0%0/1
$class ||= "MyClustericiousApp"
$class
Truth table0%0/2
A
A= $class
| |||||||||||||
| 43 | 0 | ▶ | if (@args % 2) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | 0 | die "usage : $0 generate app <name>\n"; | |||||||||||
| 45 | } | ||||||||||||
| 46 | 0 | my %args = @args; | |||||||||||
| 47 | |||||||||||||
| 48 | 0 | my $templatedir = Clustericious->_dist_dir->subdir('tmpl', '1.08', 'app'); | |||||||||||
| 49 | |||||||||||||
| 50 | 0 | ▶ | die "Can't find template.\n" unless -d $templatedir; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | |||||||||||||
| 52 | 0 | ▶ | find({wanted => sub { $self->_installfile($templatedir, $_, $class) if -f }, | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||
| 53 | 0 | no_chdir => 1}, $templatedir); | |||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | 1 | 1; | |||||||||||
| 57 | |||||||||||||
| 58 | __END__ | ||||||||||||