line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Clustericious::Command::generate::client; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
598
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
4
|
use Mojo::Base 'Clustericious::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
113
|
use File::Find; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
7
|
1
|
|
|
1
|
|
6
|
use File::Basename qw( basename ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
390
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Clustericious command to generate a new Clustericious client |
10
|
|
|
|
|
|
|
our $VERSION = '1.27'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has description => <<'EOF'; |
14
|
|
|
|
|
|
|
Generate Clustericious::Client-derived client. |
15
|
|
|
|
|
|
|
EOF |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has usage => <<"EOF"; |
18
|
|
|
|
|
|
|
usage: $0 generate client [SERVER APP NAME] |
19
|
|
|
|
|
|
|
EOF |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _installfile |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
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
|
0
|
|
|
|
|
return if -e $relpath; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $content = Mojo::Template->new->render_file( $file, $serverclass ); |
35
|
0
|
|
|
|
|
|
$self->write_file($relpath, $content ); |
36
|
0
|
0
|
|
|
|
|
-x $file && $self->chmod_file($relpath, 0755); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub run |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
0
|
1
|
|
my ($self, $serverclass, @args ) = @_; |
42
|
0
|
|
0
|
|
|
|
$serverclass ||= 'MyClustericiousApp'; |
43
|
0
|
0
|
|
|
|
|
if (@args % 2) |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
|
|
|
die "usage : $0 generate client <app_name>\n"; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
my %args = @args; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
die "app_name should be the server name" if $serverclass =~ /\-/; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $moduledir = $serverclass.'-Client'; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $templatedir = Clustericious->_dist_dir->subdir('tmpl', '1.08', 'client'); |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
die "Can't find template in $templatedir.\n" unless -d $templatedir; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
0
|
|
|
find({wanted => sub { $self->_installfile($templatedir, $_, $serverclass, $moduledir) if -f }, |
58
|
0
|
|
|
|
|
|
no_chdir => 1}, $templatedir); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Clustericious::Command::generate::client - Clustericious command to generate a new Clustericious client |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 1.27 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
% clustericious generate client Myapp |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This command generates a new Clustericious client with the given name. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SEE ALSO |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L<Clustericious>, L<Clustericious::Client> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Original author: Brian Duggan |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Current maintainer: Graham Ollis E<lt>plicease@cpan.orgE<gt> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Contributors: |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Curt Tilmes |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Yanick Champoux |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This software is copyright (c) 2013 by NASA GSFC. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
106
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |