line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Module::Abstract; |
2
|
2
|
|
|
2
|
|
2819
|
use Mojo::Base -base; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
15
|
|
3
|
2
|
|
|
2
|
|
484
|
use Mojo::Util 'decamelize'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
105
|
|
4
|
2
|
|
|
2
|
|
9
|
use YAML; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
114
|
|
5
|
2
|
|
|
2
|
|
1674
|
use Hash::Merge::Simple qw/merge/; |
|
2
|
|
|
|
|
931
|
|
|
2
|
|
|
|
|
1202
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'routes'; |
8
|
|
|
|
|
|
|
has 'config' => sub { {} }; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
2
|
|
|
2
|
1
|
22
|
my ($self, $app, $path) = @_; |
12
|
2
|
|
|
|
|
14
|
$self->init_config($app, $path); |
13
|
2
|
|
|
|
|
97
|
$self->init_routes($app); |
14
|
2
|
|
|
|
|
1377
|
$self->init_templates($app); |
15
|
2
|
|
|
|
|
82
|
$self->init_helpers($app); |
16
|
2
|
|
|
|
|
11
|
$self->startup($app); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
0
|
1
|
|
sub init_routes {} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
2
|
1
|
|
sub init_helpers {} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
2
|
1
|
|
sub startup {} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub init_templates { |
26
|
2
|
|
|
2
|
1
|
5
|
my ($self, $app) = @_; |
27
|
2
|
|
|
|
|
9
|
my $pkg = decamelize ref $self; |
28
|
2
|
|
|
|
|
46
|
$pkg =~ s/-/\//; |
29
|
|
|
|
|
|
|
|
30
|
2
|
50
|
|
|
|
10
|
return if !-d $self->config->{path}.'/templates/'.$pkg; |
31
|
0
|
|
|
|
|
0
|
my $paths = $app->renderer->paths; |
32
|
0
|
|
|
|
|
0
|
unshift @$paths, $self->config->{path}.'/templates/'.$pkg; |
33
|
0
|
|
|
|
|
0
|
$app->renderer->paths($paths); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init_config { |
37
|
2
|
|
|
2
|
1
|
6
|
my ($self, $app, $path) = @_; |
38
|
2
|
|
|
|
|
8
|
my $pkg = decamelize ref $self; |
39
|
2
|
|
|
|
|
64
|
$pkg =~ s/-/\//; |
40
|
2
|
|
|
|
|
5
|
my $fh; |
41
|
|
|
|
|
|
|
|
42
|
2
|
50
|
|
|
|
58
|
open($fh, "./config/$pkg.yaml") and do { |
43
|
0
|
|
|
|
|
0
|
local $/; |
44
|
0
|
|
|
|
|
0
|
my ($data) = Load(<$fh>); |
45
|
0
|
|
|
|
|
0
|
$self->config($data); |
46
|
0
|
|
|
|
|
0
|
close $fh; |
47
|
|
|
|
|
|
|
}; |
48
|
2
|
|
|
|
|
6
|
$self->config({ %{$self->config}, path => $path }); |
|
2
|
|
|
|
|
16
|
|
49
|
|
|
|
|
|
|
|
50
|
2
|
50
|
|
|
|
17
|
open($fh, $self->config->{path}.'/config/module.yaml') and do { |
51
|
0
|
|
|
|
|
|
local $/; |
52
|
0
|
|
|
|
|
|
my ($data) = Load(<$fh>); |
53
|
0
|
|
|
|
|
|
close $fh; |
54
|
0
|
|
|
|
|
|
$self->config(merge $data, $self->config); |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |