line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Command::Author::inflate; |
2
|
1
|
|
|
1
|
|
8
|
use Mojo::Base 'Mojolicious::Command'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use Mojo::Loader qw(data_section file_is_binary); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
102
|
|
5
|
1
|
|
|
1
|
|
7
|
use Mojo::Util qw(encode); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
469
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has description => 'Inflate embedded files to real files'; |
8
|
|
|
|
|
|
|
has usage => sub { shift->extract_usage }; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub run { |
11
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Find all embedded files |
14
|
0
|
|
|
|
|
|
my %all; |
15
|
0
|
|
|
|
|
|
my $app = $self->app; |
16
|
0
|
|
|
|
|
|
for my $class (@{$app->renderer->classes}, @{$app->static->classes}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
for my $name (keys %{data_section $class}) { |
|
0
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $data = data_section $class, $name; |
19
|
0
|
0
|
|
|
|
|
$data = encode 'UTF-8', $data unless file_is_binary $class, $name; |
20
|
0
|
|
|
|
|
|
$all{$name} = $data; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Turn them into real files |
25
|
0
|
|
|
|
|
|
for my $name (grep {/\.\w+$/} keys %all) { |
|
0
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
my $prefix = $name =~ /\.\w+\.\w+$/ ? 'templates' : 'public'; |
27
|
0
|
|
|
|
|
|
$self->write_file($self->rel_file("$prefix/$name"), $all{$name}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=encoding utf8 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Mojolicious::Command::Author::inflate - Inflate command |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Usage: APPLICATION inflate [OPTIONS] |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
./myapp.pl inflate |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Options: |
46
|
|
|
|
|
|
|
-h, --help Show this summary of available options |
47
|
|
|
|
|
|
|
--home Path to home directory of your application, defaults to |
48
|
|
|
|
|
|
|
the value of MOJO_HOME or auto-detection |
49
|
|
|
|
|
|
|
-m, --mode Operating mode for your application, defaults to the |
50
|
|
|
|
|
|
|
value of MOJO_MODE/PLACK_ENV or "development" |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L turns templates and static files embedded in the C sections of your |
55
|
|
|
|
|
|
|
application into real files. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This is a core command, that means it is always enabled and its code a good example for learning to build new commands, |
58
|
|
|
|
|
|
|
you're welcome to fork it. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
See L for a list of commands that are available by default. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L inherits all attributes from L and implements the |
65
|
|
|
|
|
|
|
following new ones. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 description |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $description = $inflate->description; |
70
|
|
|
|
|
|
|
$inflate = $inflate->description('Foo'); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Short description of this command, used for the command list. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 usage |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $usage = $inflate->usage; |
77
|
|
|
|
|
|
|
$inflate = $inflate->usage('Foo'); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Usage information for this command, used for the help screen. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L inherits all methods from L and implements the following |
84
|
|
|
|
|
|
|
new ones. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 run |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$inflate->run(@ARGV); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Run this command. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L, L, L. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |