Nile/Plugin/Minify/Css.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 39 CC 2 SCAR 13.9
CC
2
Cov
0%
process_file
6.0
process
2.0
BEGIN
2.0
CRAP 4.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::Css;
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::Css - css minifier plugin for the Nile framework.
20  
21 =head1 SYNOPSIS
22
23 =head1 DESCRIPTION
24  
25 Nile::Plugin::Minify::Css - css minifier plugin for the Nile framework.
26
27 $app->plugin->minify->css($output_file => $file1, $file2, $url1, $url2, ...);
28  
29 $app->plugin->minify->css('site.css' => '/css/menu.css', '/css/news.css');
30
31 my $path = $app->var->get("css_dir");
32  
33 $app->plugin->minify->css(
34 $app->file->catfile($path, "app.css") =>
35 $app->file->catfile($path, "jquery.tweet.css"),
36 $app->file->catfile($path, "jquery.loading.css"),
37 $app->file->catfile($path, "jquery.likes.css"),
38 "http://domain.com/js/menu/menu.css",
39 );
40  
41 =cut
42  
43 use Nile::Base;
44 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45 has 'xsmod' => (
46 is => 'rw',
47 default => sub {
48 if (!eval "use CSS::Minifier::XS;1;") {
49 eval "use CSS::Minifier;1;";
50 return 0;
51 }
52 return 1;
53 },
54 );
55 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56 sub process {
57  
58 my ($self, $out, @files) = @_;
59  
60 my $content = "";
61  
62 foreach my $file (@files) {
63 $content .= $self->process_file($file);
64 }
65  
66 $self->app->file->put($out, $content);
67 }
68 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 sub process_file {
70
71 my ($self, $file) = @_;
72
73 my $content = $self->app->file->get($file);
74  
75 if ($self->xsmod) {
76 return CSS::Minifier::XS::minify(input => $content) || $self->app->abort("CSS::Minifier::XS Error");
77 }
78 else {
79 return CSS::Minifier::minify(input => $content) || $self->app->abort("CSS::Minifier Error");
80 }
81 }
82 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83  
84 =pod
85  
86 =head1 Bugs
87  
88 This project is available on github at L<https://github.com/mewsoft/Nile>.
89  
90 =head1 HOMEPAGE
91  
92 Please visit the project's homepage at L<https://metacpan.org/release/Nile>.
93  
94 =head1 SOURCE
95  
96 Source repository is at L<https://github.com/mewsoft/Nile>.
97  
98 =head1 SEE ALSO
99  
100 See L<Nile> for details about the complete framework.
101  
102 =head1 AUTHOR
103  
104 Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org>
105 Website: http://www.mewsoft.com
106  
107 =head1 COPYRIGHT AND LICENSE
108  
109 Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com,
110 L<https://github.com/mewsoft/Nile>, L<http://www.mewsoft.com>
111  
112 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
113  
114 =cut
115  
116 1;