line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use Moose; |
2
|
3
|
|
|
12
|
|
4455
|
use FindBin; |
|
3
|
|
|
|
|
925080
|
|
|
3
|
|
|
|
|
25
|
|
3
|
3
|
|
|
12
|
|
22778
|
use lib; |
|
3
|
|
|
|
|
1149
|
|
|
3
|
|
|
|
|
184
|
|
4
|
3
|
|
|
3
|
|
508
|
use File::Spec; |
|
3
|
|
|
|
|
721
|
|
|
3
|
|
|
|
|
26
|
|
5
|
3
|
|
|
3
|
|
248
|
use Class::Load qw/ load_first_existing_class load_optional_class /; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
116
|
|
6
|
3
|
|
|
3
|
|
19
|
use Catalyst::Utils; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
162
|
|
7
|
3
|
|
|
3
|
|
1421
|
use Try::Tiny; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
89
|
|
8
|
3
|
|
|
3
|
|
19
|
use namespace::clean -except => [ 'meta' ]; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
181
|
|
9
|
3
|
|
|
3
|
|
19
|
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
39
|
|
10
|
|
|
|
|
|
|
my ($self, $app, $script) = @_; |
11
|
|
|
|
|
|
|
return load_first_existing_class("${app}::Script::${script}", "Catalyst::Script::$script"); |
12
|
5
|
|
|
5
|
1
|
18
|
} |
13
|
5
|
|
|
|
|
44
|
|
14
|
|
|
|
|
|
|
my ($self, @try) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
return grep { load_optional_class($_) } @try; |
17
|
4
|
|
|
4
|
1
|
20
|
} |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
14
|
no namespace::clean; |
|
8
|
|
|
|
|
16287
|
|
20
|
|
|
|
|
|
|
my ($base, @traits) = @_; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
1552
|
my $meta = Class::MOP::class_of($base)->create_anon_class( |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
15
|
|
23
|
|
|
|
|
|
|
superclasses => [ $base ], |
24
|
|
|
|
|
|
|
roles => [ @traits ], |
25
|
|
|
|
|
|
|
cache => 1, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
$meta->add_method(meta => sub { $meta }); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $meta->name; |
30
|
|
|
|
|
|
|
} |
31
|
12
|
|
|
12
|
|
21609
|
use namespace::clean; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my ($self, $appclass, $scriptclass) = @_; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
3
|
|
1073
|
if (grep { -f File::Spec->catfile($FindBin::Bin, '..', $_) } Catalyst::Utils::dist_indicator_file_list()) { |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
15
|
|
36
|
|
|
|
|
|
|
lib->import(File::Spec->catdir($FindBin::Bin, '..', 'lib')); |
37
|
|
|
|
|
|
|
} |
38
|
5
|
|
|
5
|
1
|
15145
|
|
39
|
|
|
|
|
|
|
my $class = $self->find_script_class($appclass, $scriptclass); |
40
|
5
|
50
|
|
|
|
31
|
|
|
20
|
|
|
|
|
493
|
|
41
|
0
|
|
|
|
|
0
|
my @possible_traits = ("${appclass}::TraitFor::Script::${scriptclass}", "${appclass}::TraitFor::Script"); |
42
|
|
|
|
|
|
|
my @traits = $self->find_script_traits(@possible_traits); |
43
|
|
|
|
|
|
|
|
44
|
5
|
|
|
|
|
39
|
$class = subclass_with_traits($class, @traits) |
45
|
|
|
|
|
|
|
if @traits; |
46
|
4
|
|
|
|
|
17974
|
|
47
|
4
|
|
|
|
|
36
|
$class->new_with_options( application_name => $appclass )->run; |
48
|
|
|
|
|
|
|
} |
49
|
4
|
50
|
|
|
|
14451
|
|
50
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
51
|
|
|
|
|
|
|
1; |
52
|
4
|
|
|
|
|
37
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Catalyst::ScriptRunner - The Catalyst Framework script runner |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Will run MyApp::Script::Server if it exists, otherwise |
60
|
|
|
|
|
|
|
# will run Catalyst::Script::Server. |
61
|
|
|
|
|
|
|
Catalyst::ScriptRunner->run('MyApp', 'Server'); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This class is responsible for loading and running scripts, either in the |
66
|
|
|
|
|
|
|
application specific namespace |
67
|
|
|
|
|
|
|
(e.g. C<MyApp::Script::Server>), or the Catalyst namespace (e.g. C<Catalyst::Script::Server>). |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
If your application contains a custom script, then it will be used in preference to the generic |
70
|
|
|
|
|
|
|
script, and is expected to sub-class the standard script. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 TRAIT LOADING |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Catalyst will automatically load and apply roles to the scripts in your |
75
|
|
|
|
|
|
|
application. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
C<MyApp::TraitFor::Script> will be loaded if present, and will be applied to B<ALL> |
78
|
|
|
|
|
|
|
scripts. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
C<MyApp::TraitFor::Script::XXXX> will be loaded (if present) and for script |
81
|
|
|
|
|
|
|
individually. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 run ($application_class, $scriptclass) |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Called with two parameters, the application class (e.g. MyApp) |
88
|
|
|
|
|
|
|
and the script class, (i.e. one of Server/FastCGI/CGI/Create/Test) |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 find_script_class ($appname, $script_name) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Finds and loads the class for the script, trying the application specific |
93
|
|
|
|
|
|
|
script first, and falling back to the generic script. Returns the script |
94
|
|
|
|
|
|
|
which was loaded. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 find_script_traits ($appname, @try) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Finds and loads a set of traits. Returns the list of traits which were loaded. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHORS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Catalyst Contributors, see Catalyst.pm |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify it under |
107
|
|
|
|
|
|
|
the same terms as Perl itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |