line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::HelloMojo; |
2
|
1
|
|
|
1
|
|
1039
|
use Mojolicious::Lite; |
|
1
|
|
|
|
|
87140
|
|
|
1
|
|
|
|
|
8
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
14323
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
648
|
|
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
|
|
|
|
|
|
|
my $home = $mount->pattern->defaults->{app}->home; |
22
|
|
|
|
|
|
|
my ($rel_app) = ($app =~ /^$home\W(.*)$/); |
23
|
|
|
|
|
|
|
app->log->info("Mounted /$_ => $home / $rel_app"); |
24
|
|
|
|
|
|
|
if ( my $domain = $mount->pattern->defaults->{app}->config('domain') ) { |
25
|
|
|
|
|
|
|
foreach my $d ( ref $domain eq 'ARRAY' ? @$domain : $domain ) { |
26
|
|
|
|
|
|
|
my $mount = plugin Mount => {$d => $app}; |
27
|
|
|
|
|
|
|
my $home = $mount->pattern->defaults->{app}->home; |
28
|
|
|
|
|
|
|
my ($rel_app) = ($app =~ /^$home\W(.*)$/); |
29
|
|
|
|
|
|
|
app->log->info("Mounted $d => $home / $rel_app"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
app->log->info("No start script found for $app, skipping"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
closedir $dh; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub find_script { |
40
|
2
|
|
|
2
|
0
|
4
|
my ($app_dir, $app_name) = @_; |
41
|
2
|
|
|
|
|
3
|
my $dashes = my $us = $app_name; |
42
|
2
|
|
|
|
|
5
|
$dashes =~ s/_/-/g; |
43
|
2
|
|
|
|
|
4
|
$us =~ s/-/_/g; |
44
|
2
|
|
|
|
|
2
|
my $app; |
45
|
2
|
|
|
|
|
4
|
foreach ( $app_name, $dashes, $us ) { |
46
|
2
|
100
|
66
|
|
|
66
|
$app = $app_dir->rel_file("$app_name/$_.pl") and -f $app and return $app; |
47
|
1
|
50
|
33
|
|
|
48
|
$app = $app_dir->rel_file("$app_name/$_") and -f $app and return $app; |
48
|
1
|
50
|
33
|
|
|
38
|
$app = $app_dir->rel_file("$app_name/script/$_") and -f $app and return $app; |
49
|
0
|
0
|
0
|
|
|
|
$app = $app_dir->rel_file("$app_name/script/$_.pl") and -f $app and return $app; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding utf8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Mojo::HelloMojo - Mount All full and lite apps! |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use Mojo::HelloMojo; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $hello = Mojo::HelloMojo->new; |
66
|
|
|
|
|
|
|
$hello->start; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L is a L application. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SEE ALSO |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L, L, L. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |