Nile/Plugin/Minify/Html.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 24 CC 1 SCAR 6.9
CC
1
Cov
0%
process
2.0
process_file
2.0
BEGIN
2.0
CRAP 2.0
1 # Copyright Infomation
2 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 # Author : Dr. Ahmed Amin Elsheshtawy, Ph.D.
4 # Website: https://github.com/mewsoft/Nile, http://www.mewsoft.com
5 # Email : mewsoft@cpan.org, support@mewsoft.com
6 # Copyrights (c) 2014-2015 Mewsoft Corp. All rights reserved.
7 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 package Nile::Plugin::Minify::Html;
9  
10 our $VERSION = '0.55';
11 our $AUTHORITY = 'cpan:MEWSOFT';
12  
13 =pod
14  
15 =encoding utf8
16  
17 =head1 NAME
18  
19 Nile::Plugin::Minify::Html - Html minifier plugin for the Nile framework.
20  
21 =head1 SYNOPSIS
22
23 =head1 DESCRIPTION
24  
25 Nile::Plugin::Minify::Html - Html minifier plugin for the Nile framework.
26
27 $app->plugin->minify->html($output_file => $file1, $file2, $url1, $url2, ...);
28  
29 $app->plugin->minify->html('home.html' => '/menu.html', '/body.html');
30
31 my $path = $app->var->html("views_dir");
32  
33 $app->plugin->minify->html(
34 $app->file->catfile($path, "home.html") =>
35 $app->file->catfile($path, "header.html"),
36 $app->file->catfile($path, "body.html"),
37 $app->file->catfile($path, "footer.html"),
38 "http://domain.com/ads/ads.html",
39 );
40  
41 =cut
42  
43 use Nile::Base;
44 use HTML::Packer;
45 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46 sub process {
47  
48 my ($self, $out, @files) = @_;
49  
50 my $content = "";
51  
52 foreach my $file (@files) {
53 $content .= $self->process_file($file);
54 }
55  
56 $self->app->file->put($out, $content);
57 }
58 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59 sub process_file {
60
61 my ($self, $file) = @_;
62
63 my $content = $self->app->file->get($file);
64
65 my $packer = HTML::Packer->init();
66  
67 $packer->minify(\$content,
68 {
69 remove_newlines => 0,
70 remove_comments => 0,
71 do_javascript => 'best',
72 do_stylesheet => 'minify',
73 no_compress_comment => 1,
74 html5 => 0,
75 }
76 );
77
78 return $content;
79 }
80 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81  
82 =pod
83  
84 =head1 Bugs
85  
86 This project is available on github at L<https://github.com/mewsoft/Nile>.
87  
88 =head1 HOMEPAGE
89  
90 Please visit the project's homepage at L<https://metacpan.org/release/Nile>.
91  
92 =head1 SOURCE
93  
94 Source repository is at L<https://github.com/mewsoft/Nile>.
95  
96 =head1 SEE ALSO
97  
98 See L<Nile> for details about the complete framework.
99  
100 =head1 AUTHOR
101  
102 Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org>
103 Website: http://www.mewsoft.com
104  
105 =head1 COPYRIGHT AND LICENSE
106  
107 Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com,
108 L<https://github.com/mewsoft/Nile>, L<http://www.mewsoft.com>
109  
110 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
111  
112 =cut
113  
114 1;