Newer Older
89 lines | 2.111kb
copy gitweblite soruce code
root authored on 2012-11-23
1
package Mojolicious::Command::inflate;
upgraded Mojolicious to v3.7...
Yuki Kimoto authored on 2013-01-28
2
use Mojo::Base 'Mojolicious::Command';
copy gitweblite soruce code
root authored on 2012-11-23
3

            
upgraded Mojolicious to v3.7...
Yuki Kimoto authored on 2013-01-28
4
use Mojo::Loader;
copy gitweblite soruce code
root authored on 2012-11-23
5
use Mojo::Util 'encode';
6

            
7
has description => "Inflate embedded files to real files.\n";
8
has usage       => "usage: $0 inflate\n";
9

            
10
sub run {
11
  my $self = shift;
12

            
13
  # Find all embedded files
14
  my %all;
upgraded Mojolicious to v3.7...
Yuki Kimoto authored on 2013-01-28
15
  my $app    = $self->app;
16
  my $loader = Mojo::Loader->new;
update Mojolicious to 4.57
Yuki Kimoto authored on 2013-12-02
17
  for my $class (@{$app->renderer->classes}, @{$app->static->classes}) {
18
    for my $name (keys %{$loader->data($class)}) {
19
      my $data = $loader->data($class, $name);
20
      $all{$name}
21
        = $loader->is_binary($class, $name) ? $data : encode('UTF-8', $data);
22
    }
23
  }
copy gitweblite soruce code
root authored on 2012-11-23
24

            
25
  # Turn them into real files
update Mojolicious to 4.57
Yuki Kimoto authored on 2013-12-02
26
  for my $name (keys %all) {
27
    my $prefix = $name =~ /\.\w+\.\w+$/ ? 'templates' : 'public';
28
    $self->write_file($self->rel_file("$prefix/$name"), $all{$name});
copy gitweblite soruce code
root authored on 2012-11-23
29
  }
30
}
31

            
32
1;
33

            
update Mojolicious to 4.57
Yuki Kimoto authored on 2013-12-02
34
=encoding utf8
35

            
copy gitweblite soruce code
root authored on 2012-11-23
36
=head1 NAME
37

            
38
Mojolicious::Command::inflate - Inflate command
39

            
40
=head1 SYNOPSIS
41

            
42
  use Mojolicious::Command::inflate;
43

            
44
  my $inflate = Mojolicious::Command::inflate->new;
45
  $inflate->run(@ARGV);
46

            
47
=head1 DESCRIPTION
48

            
49
L<Mojolicious::Command::inflate> turns templates and static files embedded in
50
the C<DATA> sections of your application into real files.
51

            
upgraded Mojolicious to v3.7...
Yuki Kimoto authored on 2013-01-28
52
This is a core command, that means it is always enabled and its code a good
53
example for learning to build new commands, you're welcome to fork it.
54

            
copy gitweblite soruce code
root authored on 2012-11-23
55
=head1 ATTRIBUTES
56

            
upgraded Mojolicious to v3.7...
Yuki Kimoto authored on 2013-01-28
57
L<Mojolicious::Command::inflate> inherits all attributes from
58
L<Mojolicious::Command> and implements the following new ones.
copy gitweblite soruce code
root authored on 2012-11-23
59

            
update Mojolicious and added...
Yuki Kimoto authored on 2013-03-20
60
=head2 description
copy gitweblite soruce code
root authored on 2012-11-23
61

            
62
  my $description = $inflate->description;
63
  $inflate        = $inflate->description('Foo!');
64

            
65
Short description of this command, used for the command list.
66

            
update Mojolicious and added...
Yuki Kimoto authored on 2013-03-20
67
=head2 usage
copy gitweblite soruce code
root authored on 2012-11-23
68

            
69
  my $usage = $inflate->usage;
70
  $inflate  = $inflate->usage('Foo!');
71

            
72
Usage information for this command, used for the help screen.
73

            
74
=head1 METHODS
75

            
upgraded Mojolicious to v3.7...
Yuki Kimoto authored on 2013-01-28
76
L<Mojolicious::Command::inflate> inherits all methods from
77
L<Mojolicious::Command> and implements the following new ones.
copy gitweblite soruce code
root authored on 2012-11-23
78

            
update Mojolicious and added...
Yuki Kimoto authored on 2013-03-20
79
=head2 run
copy gitweblite soruce code
root authored on 2012-11-23
80

            
81
  $inflate->run(@ARGV);
82

            
83
Run this command.
84

            
85
=head1 SEE ALSO
86

            
87
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
88

            
89
=cut