line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
13295
|
use utf8; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
3
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package CatalystX::InjectModule; |
4
|
|
|
|
|
|
|
$CatalystX::InjectModule::VERSION = '0.12'; |
5
|
1
|
|
|
1
|
|
333
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use namespace::autoclean; |
7
|
|
|
|
|
|
|
use CatalystX::InjectModule::MI; |
8
|
|
|
|
|
|
|
use List::MoreUtils qw(uniq); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
after 'finalize_config' => sub { |
11
|
|
|
|
|
|
|
my $c = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $conf = $c->config->{'CatalystX::InjectModule'}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$c->mk_classdata('mi'); # we will use this name in Catalyst |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# module injector |
18
|
|
|
|
|
|
|
my $mi = $c->mi( CatalystX::InjectModule::MI->new(ctx => $c) ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$mi->load($conf); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
after 'setup_components' => sub { |
26
|
|
|
|
|
|
|
my $c = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $conf = $c->config->{'CatalystX::InjectModule'}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# inject configured modules |
31
|
|
|
|
|
|
|
$c->mi->inject($conf->{inject}); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# add all templates to all views |
34
|
|
|
|
|
|
|
# XXX : Change this |
35
|
|
|
|
|
|
|
if ( $c->view('TT') ) { |
36
|
|
|
|
|
|
|
my @tmpl_paths = @{ $c->view('TT')->config->{INCLUDE_PATH} }; |
37
|
|
|
|
|
|
|
foreach my $viewfile ( @{$c->mi->_view_files} ) { |
38
|
|
|
|
|
|
|
$viewfile =~ /\/View\/(\w*)\.pm/; |
39
|
|
|
|
|
|
|
my $view = $1; |
40
|
|
|
|
|
|
|
next if ( $view eq 'TT'); |
41
|
|
|
|
|
|
|
@{ $c->view($view)->config->{INCLUDE_PATH} } = uniq(@tmpl_paths); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# push templates path (.../root/static/) |
46
|
|
|
|
|
|
|
if ( $c->mi->_static_dirs ) { |
47
|
|
|
|
|
|
|
push( @{$c->mi->_static_dirs}, 'root/static' ) |
48
|
|
|
|
|
|
|
if -d 'root/static'; |
49
|
|
|
|
|
|
|
foreach my $static_dir ( reverse @{$c->mi->_static_dirs} ) { |
50
|
|
|
|
|
|
|
# XXX : And if Static::Simple is not used ? |
51
|
|
|
|
|
|
|
$static_dir =~ s|/static||; |
52
|
|
|
|
|
|
|
push( @{ $c->config->{'Plugin::Static::Simple'}->{include_path} }, $static_dir ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# installer |
57
|
|
|
|
|
|
|
if ( $c->mi->modules_loaded ) { |
58
|
|
|
|
|
|
|
foreach my $module ( @{$c->mi->modules_loaded} ) { |
59
|
|
|
|
|
|
|
$c->mi->install_module($module); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding utf8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
CatalystX::InjectModule - injects modules containing components, plugins, config, lib, templates ... |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
version 0.12 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This module is at EXPERIMENTAL stage, so use with caution. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use Catalyst qw/ |
80
|
|
|
|
|
|
|
ConfigLoader |
81
|
|
|
|
|
|
|
+CatalystX::InjectModule |
82
|
|
|
|
|
|
|
/; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# myapp.yml |
85
|
|
|
|
|
|
|
CatalystX::InjectModule: |
86
|
|
|
|
|
|
|
path: |
87
|
|
|
|
|
|
|
- t/share/modulesX |
88
|
|
|
|
|
|
|
- t/share/modules |
89
|
|
|
|
|
|
|
modules: |
90
|
|
|
|
|
|
|
- Ax |
91
|
|
|
|
|
|
|
- A |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Each module must have at least one file cxmi_config.yml |
94
|
|
|
|
|
|
|
name: Bx |
95
|
|
|
|
|
|
|
version: 2 |
96
|
|
|
|
|
|
|
deps: |
97
|
|
|
|
|
|
|
- Cx == 2 |
98
|
|
|
|
|
|
|
- Ex |
99
|
|
|
|
|
|
|
catalyst_plugins: |
100
|
|
|
|
|
|
|
- Static::Simple |
101
|
|
|
|
|
|
|
- +CatalystX::SimpleLogin |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Ce plugin permet d'injecter des 'modules CatalystX::InjectModule' (CI) dans une application Catalyst. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Qu'est ce qu'un module CI ? |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Un module CI est défini par son nom et sa version. Si d'autres informations sont enregistrées dans son fichier de configuration 'cxmi_config.yml' elles sont fusionnées avec la config de l'application Catalyst. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Un module CI peut être dépendant d'autres modules CI. Le mot-clé 'deps' est alors utilisé pour les définir : |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
deps: |
113
|
|
|
|
|
|
|
- OtherModule |
114
|
|
|
|
|
|
|
- Another |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Un module CI peut être constitué de : |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
- librairies Perl : Elles sont dans ce cas ajoutées aux chemins de recherche des librairies (@INC) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
- composants Catalyst ( Model, View, controller ) : Ils sont injectés dans l'application Catalyst |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
- plugins Catalyst ( via le mot clé catalyst_plugins du fichier de configuration du module) : Ils sont injectés dans l'application. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
- Fichiers tt dans root/src et root/lib ( Template Toolkit ) |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
- Un fichier a son nom comportant une fonction 'install' qui sera exécutée lors du chargement. L'installation ne peut se faire qu'une seule fois. Pour réinstaller un Module CI il faut au préalable déinstaller le module. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Daniel Brosseau, C<< >> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 BUGS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
135
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
136
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SUPPORT |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
perldoc CatalystX::InjectModule |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
You can also look for information at: |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=over 4 |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * CPAN Ratings |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * Search CPAN |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Copyright 2015 Daniel Brosseau. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
179
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
180
|
|
|
|
|
|
|
copy of the full license at: |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
185
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
186
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
187
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
190
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
191
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
194
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
197
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
198
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
199
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
200
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
201
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
202
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
203
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
206
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
207
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
208
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
209
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
210
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
211
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
212
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=cut |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; # End of CatalystX::InjectModule |