line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::HelloMojo; |
2
|
1
|
|
|
1
|
|
1786
|
use Mojolicious::Lite; |
|
1
|
|
|
|
|
147962
|
|
|
1
|
|
|
|
|
10
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
31873
|
use Cwd; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1335
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
app->moniker(Mojo::Util::decamelize(app->moniker)); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
plugin 'Config' => {default => {hello_mojo => ['.']}}; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
foreach my $app_dir ( $ENV{HELLO_MOJO} ? split /:/, $ENV{HELLO_MOJO} : @{app->config->{hello_mojo}} ) { |
13
|
|
|
|
|
|
|
$app_dir = Mojo::Path->new($app_dir)->leading_slash ? Mojo::Home->new($app_dir) : Mojo::Home->new(Mojo::Path->new(getcwd)->trailing_slash(1)->merge($app_dir)); |
14
|
|
|
|
|
|
|
opendir(my $dh, $app_dir) or next; |
15
|
|
|
|
|
|
|
foreach ( grep { !/^\./ } readdir($dh) ) { |
16
|
|
|
|
|
|
|
my $app = find_script($app_dir => $_); |
17
|
|
|
|
|
|
|
if ( -f $app_dir->rel_file("$_/.nomojo") ) { |
18
|
|
|
|
|
|
|
app->log->info("No Mojo for $app, skipping"); |
19
|
|
|
|
|
|
|
} elsif ( $app && -f $app ) { |
20
|
|
|
|
|
|
|
my $mount = plugin Mount => {"/$_" => $app}; |
21
|
|
|
|
|
|
|
app->log->info("Mounted /$_ => $app"); |
22
|
|
|
|
|
|
|
if ( my $domain = $mount->pattern->defaults->{app}->config('domain') ) { |
23
|
|
|
|
|
|
|
foreach my $d ( ref $domain eq 'ARRAY' ? @$domain : $domain ) { |
24
|
|
|
|
|
|
|
my $mount = plugin Mount => {$d => $app}; |
25
|
|
|
|
|
|
|
app->log->info("Mounted $d => $app"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} else { |
29
|
|
|
|
|
|
|
app->log->info("No start script found for $app, skipping"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
closedir $dh; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub find_script { |
36
|
2
|
|
|
2
|
0
|
6
|
my ($app_dir, $app_name) = @_; |
37
|
2
|
|
|
|
|
5
|
my $dashes = my $us = $app_name; |
38
|
2
|
|
|
|
|
8
|
$dashes =~ s/_/-/g; |
39
|
2
|
|
|
|
|
5
|
$us =~ s/-/_/g; |
40
|
2
|
|
|
|
|
3
|
my $app; |
41
|
2
|
|
|
|
|
7
|
foreach ( $app_name, $dashes, $us ) { |
42
|
2
|
100
|
66
|
|
|
15
|
$app = $app_dir->rel_file("$app_name/$_.pl") and -f $app and return $app; |
43
|
1
|
50
|
33
|
|
|
95
|
$app = $app_dir->rel_file("$app_name/$_") and -f $app and return $app; |
44
|
1
|
50
|
33
|
|
|
141
|
$app = $app_dir->rel_file("$app_name/script/$_") and -f $app and return $app; |
45
|
0
|
0
|
0
|
|
|
|
$app = $app_dir->rel_file("$app_name/script/$_.pl") and -f $app and return $app; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=encoding utf8 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Mojo::HelloMojo - Mount All full and lite apps! |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use Mojo::HelloMojo; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $hello = Mojo::HelloMojo->new; |
62
|
|
|
|
|
|
|
$hello->start; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L is a L application. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L, L, L. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |