line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# devel::mojo Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Devel::Mojo; |
7
|
1
|
|
|
1
|
|
827
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::Shell::Command); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1065
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
datadir => [ qw(datadir) ], |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
attributes_default => { |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
commands => { |
24
|
|
|
|
|
|
|
generate_lite_app => [ qw(file_pl) ], |
25
|
|
|
|
|
|
|
generate_app => [ qw(MyApp) ], |
26
|
|
|
|
|
|
|
morbo => [ qw(file_pl) ], |
27
|
|
|
|
|
|
|
inflate => [ qw(file_pl) ], |
28
|
|
|
|
|
|
|
get => [ qw(url) ], |
29
|
|
|
|
|
|
|
test => [ qw(file_pl) ], |
30
|
|
|
|
|
|
|
routes => [ qw(file_pl) ], |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
require_modules => { |
33
|
|
|
|
|
|
|
Mojolicious => [ ], |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
require_binaries => { |
36
|
|
|
|
|
|
|
mojo => [ ], |
37
|
|
|
|
|
|
|
morbo => [ ], |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub generate_lite_app { |
43
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
my ($pl) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
47
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('generate_lite_app', $pl) or return; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
0
|
|
|
|
my $cwd = defined($self->shell) && $self->shell->pwd || '/tmp'; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if (defined($self->shell)) { |
52
|
0
|
0
|
|
|
|
|
$self->shell->run_cd($datadir) or return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
0
|
0
|
|
|
|
|
chdir($datadir) or return $self->log->error("generate_lite_app: chdir: $!"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $cmd = "mojo generate lite_app \"$pl\""; |
59
|
0
|
|
|
|
|
|
my $r = $self->execute($cmd); |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if (defined($self->shell)) { |
62
|
0
|
0
|
|
|
|
|
$self->shell->run_cd($cwd) or return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
0
|
0
|
|
|
|
|
chdir($cwd) or return $self->log->error("generate_lite_app: chdir: $!"); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $r; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub generate_app { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my ($module) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
76
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('generate_app', $module) or return; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
0
|
|
|
|
my $cwd = defined($self->shell) && $self->shell->pwd || '/tmp'; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if (defined($self->shell)) { |
81
|
0
|
0
|
|
|
|
|
$self->shell->run_cd($datadir) or return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
0
|
0
|
|
|
|
|
chdir($datadir) or return $self->log->error("generate_app: chdir: $!"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $cmd = "mojo generate app \"$module\""; |
88
|
0
|
|
|
|
|
|
my $r = $self->execute($cmd); |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
if (defined($self->shell)) { |
91
|
0
|
0
|
|
|
|
|
$self->shell->run_cd($cwd) or return; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { |
94
|
0
|
0
|
|
|
|
|
chdir($cwd) or return $self->log->error("generate_app: chdir: $!"); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $r; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub morbo { |
101
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
102
|
0
|
|
|
|
|
|
my ($pl) = @_; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
105
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('morbo', $pl) or return; |
106
|
0
|
0
|
|
|
|
|
$self->brik_help_run_file_not_found('morbo', $pl) or return; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $cmd = "morbo \"$pl\""; |
109
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub inflate { |
113
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
114
|
0
|
|
|
|
|
|
my ($pl) = @_; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
117
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('inflate', $pl) or return; |
118
|
0
|
0
|
|
|
|
|
$self->brik_help_run_file_not_found('inflate', $pl) or return; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
0
|
|
|
|
my $cwd = defined($self->shell) && $self->shell->pwd || '/tmp'; |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if (defined($self->shell)) { |
123
|
0
|
0
|
|
|
|
|
$self->shell->run_cd($datadir) or return; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
else { |
126
|
0
|
0
|
|
|
|
|
chdir($datadir) or return $self->log->error("inflate: chdir: $!"); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $cmd = "perl \"$pl\" inflate"; |
130
|
0
|
|
|
|
|
|
my $r = $self->execute($cmd); |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
if (defined($self->shell)) { |
133
|
0
|
0
|
|
|
|
|
$self->shell->run_cd($cwd) or return; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
else { |
136
|
0
|
0
|
|
|
|
|
chdir($cwd) or return $self->log->error("inflate: chdir: $!"); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return $r; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# |
143
|
|
|
|
|
|
|
# ./myapp.pl get -v '/?user=sebastian&pass=secr3t' |
144
|
|
|
|
|
|
|
# |
145
|
|
|
|
|
|
|
sub get { |
146
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
147
|
0
|
|
|
|
|
|
my ($pl, $url) = @_; |
148
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('get', $pl) or return; |
150
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('get', $url) or return; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
my $cmd = "perl \"$pl\" get -v '$url'"; |
153
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub test { |
157
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
158
|
0
|
|
|
|
|
|
my ($pl) = @_; |
159
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('test', $pl) or return; |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
my $cmd = "perl \"$pl\" test"; |
163
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
# ./myapp.pl routes -v |
168
|
|
|
|
|
|
|
# |
169
|
|
|
|
|
|
|
sub routes { |
170
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
171
|
0
|
|
|
|
|
|
my ($pl) = @_; |
172
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('routes', $pl) or return; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my $cmd = "perl \"$pl\" routes -v"; |
176
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
__END__ |