CSS-Packer-2.07/000755 000765 000120 00000000000 13370240235 014565 5ustar00leejohnsonadmin000000 000000 CSS-Packer-2.07/Changes000644 000765 000120 00000004561 13370240211 016060 0ustar00leejohnsonadmin000000 000000 Revision history for CSS-Packer 2.06 2018-11-06 - Add missing files to MANIFEST 2.06 2018-11-05 - Added option to define indentation level (GH #9, thanks to zdm) - Fixed minification of data URLs due to spurious new lines (GH #7) 2.05 2018-02-02 - Add missing files to MANIFEST (GH #5, thanks to nfg) 2.04 2018-02-01 - Fix compression with @keyframes by being more generic with at-rules (GH #3, GH #4) 2.03 2017-04-18 - Makefile.PL moved to ExtUtils::MakeMaker to fix no . in @INC (perl 5.25.11+) 2.01 2016-06-22 - Fix refrence cycles in ->init method causing memory leaks (GH #1) 2.00 2015-06-04 - New maintainer: LEEJO - Add .travis.yml for CI goodness - Add Changes test - Add MYMETA.json to .gitignore 1.002001 2012-02-18 - Use gnutar to build distribution. 1.002 2011-06-07 - Raised version number. 1.001_002 2011-05-19 - Added "copyright" and "remove_copyright" options. Suggested by Marc S. Brooks. - Updated POD. - Added tests. - Fixed comment regexp. 1.001_001 2011-04-07 - Added accessors. - Added tests. - Minor Bugfixes. - Cleanup. 1.000001 2011-02-27 - Changed requirements to Regexp::RegGrp 1.000001 due to "undefined submatches bug" in Regexp::RegGrp. - Small change in declaration replacement sub. - Added test. 1.000 2011-01-17 - Changed versioning. - Raised major version due to changes in versioning. - Changed requirements to Regexp::RegGrp 1.000 due to changes in versioning. 0.0401 2011-01-05 - Changed requirements to Regexp::RegGrp 0.04 0.04 2010-12-03 - Raised version number. 0.03_05 2010-10-05 - Changed required perl version to 5.8.9. 0.03_04 2010-09-23 - Added option to define compression level via comment. - Added tests. 0.03_03 2010-09-13 - Changed requirements to Regexp::RegGrp 0.0201 0.03_02 2010-09-07 - Fixed typo in documentation. 0.03_01 2010-08-22 - IE5/Mac backslash hack is no longer supported. - Moved regexp grouping stuff to Regexp::RegGrp. - Switched to Module::Install. - Added testcases. - Added "_no_compress_" comment functionality. - Added object-oriented interface. 0.2 2008-12-22 - Added support for removing whitespaces before and after commas. 0.1 2008-11-18 First version, released on an unsuspecting world. CSS-Packer-2.07/MANIFEST000644 000765 000120 00000001536 13370240235 015723 0ustar00leejohnsonadmin000000 000000 Changes lib/CSS/Packer.pm Makefile.PL MANIFEST README.md t/00-load.t t/01-interface.t t/02-io.t t/03-leaks.t t/04-indent.t t/05-data-image.t t/changes.t t/pod.t t/stylesheets/s1-expected-indent.css t/stylesheets/s1-expected.css t/stylesheets/s1.css t/stylesheets/s2-expected.css t/stylesheets/s2-expected-indent.css t/stylesheets/s2.css t/stylesheets/s3-expected.css t/stylesheets/s3.css t/stylesheets/s4-expected.css t/stylesheets/s4.css t/stylesheets/s5-expected.css t/stylesheets/s5.css t/stylesheets/s6-expected.css t/stylesheets/s6.css t/stylesheets/s7-expected.css t/stylesheets/s7.css t/stylesheets/s8-expected.css t/stylesheets/s8.css t/stylesheets/s9-expected.css t/stylesheets/s9.css META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) CSS-Packer-2.07/t/000755 000765 000120 00000000000 13370240235 015030 5ustar00leejohnsonadmin000000 000000 CSS-Packer-2.07/META.yml000644 000765 000120 00000001433 13370240235 016037 0ustar00leejohnsonadmin000000 000000 --- abstract: 'Another CSS minifier' author: - 'Lee Johnson ' build_requires: Test::File::Contents: '0.21' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: CSS-Packer no_index: directory: - t - inc requires: Regexp::RegGrp: 1.001_001 resources: bugtracker: https://github.com/leejo/css-packer-perl/issues homepage: https://metacpan.org/module/CSS::Packer license: http://dev.perl.org/licenses/ repository: https://github.com/leejo/css-packer-perl version: '2.07' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' CSS-Packer-2.07/META.json000644 000765 000120 00000002442 13370240235 016210 0ustar00leejohnsonadmin000000 000000 { "abstract" : "Another CSS minifier", "author" : [ "Lee Johnson " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "CSS-Packer", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "Test::File::Contents" : "0.21", "Test::More" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Regexp::RegGrp" : "1.001_001" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/leejo/css-packer-perl/issues" }, "homepage" : "https://metacpan.org/module/CSS::Packer", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "https://github.com/leejo/css-packer-perl" } }, "version" : "2.07", "x_serialization_backend" : "JSON::PP version 2.97001" } CSS-Packer-2.07/README.md000644 000765 000120 00000005632 13370240220 016044 0ustar00leejohnsonadmin000000 000000 # NAME CSS::Packer - Another CSS minifier
Build Status Coverage Status
# VERSION Version 2.07 # DESCRIPTION A fast pure Perl CSS minifier. # SYNOPSIS use CSS::Packer; my $packer = CSS::Packer->init(); $packer->minify( $scalarref, $opts ); To return a scalar without changing the input simply use (e.g. example 2): my $ret = $packer->minify( $scalarref, $opts ); For backward compatibility it is still possible to call 'minify' as a function: CSS::Packer::minify( $scalarref, $opts ); First argument must be a scalarref of CSS-Code. Second argument must be a hashref of options. Possible options are: - compress Defines compression level. Possible values are 'minify' and 'pretty'. Default value is 'pretty'. 'pretty' converts a { color: black ;} div { width:100px; } to a{ color:black; } div{ width:100px; } 'minify' converts the same rules to a{color:black;}div{width:100px;} - indent Defines number of spaces, used for indentation. Used only when compress is 'pretty'. Default value is 0. - copyright You can add a copyright notice at the top of the script. - remove\_copyright If there is a copyright notice in a comment it will only be removed if this option is set to a true value. Otherwise the first comment that contains the word "copyright" will be added at the top of the packed script. A copyright comment will be overwritten by a copyright notice defined with the copyright option. - no\_compress\_comment If not set to a true value it is allowed to set a CSS comment that prevents the input being packed or defines a compression level. /* CSS::Packer _no_compress_ */ /* CSS::Packer pretty */ # AUTHOR Merten Falk, ``. Now maintained by Lee Johnson (LEEJO) # BUGS Please report any bugs or feature requests through the web interface at [http://github.com/leejo/css-packer-perl/issues](http://github.com/leejo/css-packer-perl/issues). I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. # SUPPORT You can find documentation for this module with the perldoc command. perldoc CSS::Packer # COPYRIGHT & LICENSE Copyright 2008 - 2011 Merten Falk, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. # SEE ALSO [CSS::Minifier](https://metacpan.org/pod/CSS::Minifier), [CSS::Minifier::XS](https://metacpan.org/pod/CSS::Minifier::XS) CSS-Packer-2.07/lib/000755 000765 000120 00000000000 13370240235 015333 5ustar00leejohnsonadmin000000 000000 CSS-Packer-2.07/Makefile.PL000644 000765 000120 00000001413 13370061705 016541 0ustar00leejohnsonadmin000000 000000 #!perl use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'CSS::Packer', ABSTRACT_FROM => 'lib/CSS/Packer.pm', VERSION_FROM => 'lib/CSS/Packer.pm', AUTHOR => 'Lee Johnson ', LICENSE => 'perl', PREREQ_PM => { 'Regexp::RegGrp' => '1.001_001', }, BUILD_REQUIRES => { 'Test::More' => 0, 'Test::File::Contents' => 0.21, }, META_MERGE => { resources => { license => 'http://dev.perl.org/licenses/', homepage => 'https://metacpan.org/module/CSS::Packer', bugtracker => 'https://github.com/leejo/css-packer-perl/issues', repository => 'https://github.com/leejo/css-packer-perl' }, }, test => { TESTS => 't/*.t', }, ); CSS-Packer-2.07/lib/CSS/000755 000765 000120 00000000000 13370240235 015763 5ustar00leejohnsonadmin000000 000000 CSS-Packer-2.07/lib/CSS/Packer.pm000644 000765 000120 00000032164 13370240174 017536 0ustar00leejohnsonadmin000000 000000 package CSS::Packer; use 5.008009; use warnings; use strict; use Carp; use Regexp::RegGrp; our $VERSION = '2.07'; our @COMPRESS = ( 'minify', 'pretty' ); our $DEFAULT_COMPRESS = 'pretty'; our @BOOLEAN_ACCESSORS = ( 'no_compress_comment', 'remove_copyright' ); our @COPYRIGHT_ACCESSORS = ( 'copyright', 'copyright_comment' ); our $COPYRIGHT_COMMENT = '\/\*((?>[^*]|\*[^/])*copyright(?>[^*]|\*[^/])*)\*\/'; our $DICTIONARY = { 'STRING1' => qr~"(?>(?:(?>[^"\\]+)|\\.|\\"|\\\s)*)"~, 'STRING2' => qr~'(?>(?:(?>[^'\\]+)|\\.|\\'|\\\s)*)'~ }; our $WHITESPACES = '\s+'; our $RULE = '([^{};]+)\{([^{}]*)\}'; our $URL = 'url\(\s*(' . $DICTIONARY->{STRING1} . '|' . $DICTIONARY->{STRING2} . '|[^\'"\s]+?)\s*\)'; our $IMPORT = '\@import\s+(' . $DICTIONARY->{STRING1} . '|' . $DICTIONARY->{STRING2} . '|' . $URL . ')([^;]*);'; our $AT_RULE = '\@\S+([^{}]+)\{((?:' . $IMPORT . '|' . $RULE . '|' . $WHITESPACES . ')+)\}'; our $DECLARATION = '((?>[^;:]+)):(?<=:)((?>[^;]*))(?:;(?!(charset|base64))|\s*$)'; our $COMMENT = '(\/\*[^*]*\*+([^/][^*]*\*+)*\/)'; our $PACKER_COMMENT = '\/\*\s*CSS::Packer\s*(\w+)\s*\*\/'; our $CHARSET = '^(\@charset)\s+(' . $DICTIONARY->{STRING1} . '|' . $DICTIONARY->{STRING2} . ');'; our @REGGRPS = ( 'whitespaces', 'url', 'import', 'declaration', 'rule', 'content_value', 'mediarules', 'global' ); # --------------------------------------------------------------------------- # { no strict 'refs'; foreach my $reggrp ( @REGGRPS ) { next if defined *{ __PACKAGE__ . '::reggrp_' . $reggrp }{CODE}; *{ __PACKAGE__ . '::reggrp_' . $reggrp } = sub { my ( $self ) = shift; return $self->{ '_reggrp_' . $reggrp }; }; } foreach my $field ( @BOOLEAN_ACCESSORS ) { next if defined *{ __PACKAGE__ . '::' . $field }{CODE}; *{ __PACKAGE__ . '::' . $field} = sub { my ( $self, $value ) = @_; $self->{'_' . $field} = $value ? 1 : undef if ( defined( $value ) ); return $self->{'_' . $field}; }; } foreach my $field ( @COPYRIGHT_ACCESSORS ) { $field = '_' . $field if ( $field eq 'copyright_comment' ); next if defined *{ __PACKAGE__ . '::' . $field }{CODE}; *{ __PACKAGE__ . '::' . $field} = sub { my ( $self, $value ) = @_; if ( defined( $value ) and not ref( $value ) ) { $value =~ s/^\s*|\s*$//gs; $self->{'_' . $field} = $value; } my $ret = ''; if ( $self->{'_' . $field} ) { $ret = '/* ' . $self->{'_' . $field} . ' */' . "\n"; } return $ret; }; } } sub compress { my ( $self, $value ) = @_; if ( defined( $value ) ) { if ( grep( $value eq $_, @COMPRESS ) ) { $self->{_compress} = $value; } elsif ( ! $value ) { $self->{_compress} = undef; } } $self->{_compress} ||= $DEFAULT_COMPRESS; return $self->{_compress}; } # these variables are used in the closures defined in the init function # below - we have to use globals as using $self within the closures leads # to a reference cycle and thus memory leak, and we can't scope them to # the init method as they may change. they are set by the minify sub our $reggrp_url; our $reggrp_declaration; our $reggrp_mediarules; our $reggrp_content_value; our $global_compress; our $indent = ''; sub init { my $class = shift; my $self = {}; bless( $self, $class ); $self->{content_value}->{reggrp_data} = [ { regexp => $DICTIONARY->{STRING1} }, { regexp => $DICTIONARY->{STRING2} }, { regexp => qr~([\w-]+)\(\s*([\w-]+)\s*\)~, replacement => sub { return $_[0]->{submatches}->[0] . '(' . $_[0]->{submatches}->[0] . ')'; } }, { regexp => $WHITESPACES, replacement => '' } ]; $self->{whitespaces}->{reggrp_data} = [ { regexp => $WHITESPACES, replacement => '' } ]; $self->{url}->{reggrp_data} = [ { regexp => $URL, replacement => sub { my $url = $_[0]->{submatches}->[0]; return 'url(' . $url . ')'; } } ]; $self->{import}->{reggrp_data} = [ { regexp => $IMPORT, replacement => sub { my $submatches = $_[0]->{submatches}; my $url = $submatches->[0]; my $mediatype = $submatches->[2]; my $compress = $global_compress; $reggrp_url->exec( \$url ); $mediatype =~ s/^\s*|\s*$//gs; $mediatype =~ s/\s*,\s*/,/gsm; return '@import ' . $url . ( $mediatype ? ( ' ' . $mediatype ) : '' ) . ';' . ( $compress eq 'pretty' ? "\n" : '' ); } } ]; $self->{declaration}->{reggrp_data} = [ { regexp => $DECLARATION, replacement => sub { my $submatches = $_[0]->{submatches}; my $key = $submatches->[0]; my $value = $submatches->[1]; my $compress = $global_compress; $key =~ s/^\s*|\s*$//gs; $value =~ s/^\s*|\s*$//gs; if ( $key eq 'content' ) { $reggrp_content_value->exec( \$value ); } else { $value =~ s/\s*,\s*/,/gsm; $value =~ s/\s+/ /gsm; } return '' if ( not $key or $value eq '' ); return $indent . $key . ':' . $value . ';' . ( $compress eq 'pretty' ? "\n" : '' ); } } ]; $self->{rule}->{reggrp_data} = [ { regexp => $RULE, replacement => sub { my $submatches = $_[0]->{submatches}; my $selector = $submatches->[0]; my $declaration = $submatches->[1]; my $compress = $global_compress; $selector =~ s/^\s*|\s*$//gs; $selector =~ s/\s*,\s*/,/gsm; $selector =~ s/\s+/ /gsm; $declaration =~ s/^\s*|\s*$//gs; $reggrp_declaration->exec( \$declaration ); my $store = $selector . '{' . ( $compress eq 'pretty' ? "\n" : '' ) . $declaration . '}' . ( $compress eq 'pretty' ? "\n" : '' ); $store = '' unless ( $selector or $declaration ); return $store; } } ]; $self->{mediarules}->{reggrp_data} = [ @{$self->{import}->{reggrp_data}}, @{$self->{rule}->{reggrp_data}}, @{$self->{whitespaces}->{reggrp_data}} ]; $self->{global}->{reggrp_data} = [ { regexp => $CHARSET, replacement => sub { my $submatches = $_[0]->{submatches}; my $compress = $global_compress; return $submatches->[0] . " " . $submatches->[1] . ( $compress eq 'pretty' ? "\n" : '' ); } }, { regexp => $AT_RULE, replacement => sub { my $original = $_[0]->{match}; my ($selector) = ( $original =~ /\@(\S+)/ ); my $submatches = $_[0]->{submatches}; my $mediatype = $submatches->[0]; my $mediarules = $submatches->[1]; my $compress = $global_compress; $mediatype =~ s/^\s*|\s*$//gs; $mediatype =~ s/\s*,\s*/,/gsm; $reggrp_mediarules->exec( \$mediarules ); return "\@$selector " . $mediatype . '{' . ( $compress eq 'pretty' ? "\n" : '' ) . $mediarules . '}' . ( $compress eq 'pretty' ? "\n" : '' ); } }, @{$self->{mediarules}->{reggrp_data}} ]; map { $self->{ '_reggrp_' . $_ } = Regexp::RegGrp->new( { reggrp => $self->{$_}->{reggrp_data} } ); } @REGGRPS; return $self; } sub minify { my ( $self, $input, $opts ); unless ( ref( $_[0] ) and ref( $_[0] ) eq __PACKAGE__ ) { $self = __PACKAGE__->init(); shift( @_ ) unless ( ref( $_[0] ) ); ( $input, $opts ) = @_; } else { ( $self, $input, $opts ) = @_; } if ( ref( $input ) ne 'SCALAR' ) { carp( 'First argument must be a scalarref!' ); return undef; } my $css = \''; my $cont = 'void'; if ( defined( wantarray ) ) { my $tmp_input = ref( $input ) ? ${$input} : $input; $css = \$tmp_input; $cont = 'scalar'; } else { $css = ref( $input ) ? $input : \$input; } if ( ref( $opts ) eq 'HASH' ) { foreach my $field ( @BOOLEAN_ACCESSORS ) { $self->$field( $opts->{$field} ) if ( defined( $opts->{$field} ) ); } foreach my $field ( 'compress', 'copyright' ) { $self->$field( $opts->{$field} ) if ( defined( $opts->{$field} ) ); } $indent = $opts->{indent} && ( !$opts->{compress} || $opts->{compress} eq 'pretty' ) ? ' ' x $opts->{indent} : ''; } # (re)initialize variables used in the closures $reggrp_url = $self->reggrp_url; $reggrp_declaration = $self->reggrp_declaration; $reggrp_mediarules = $self->reggrp_mediarules; $reggrp_content_value = $self->reggrp_content_value; $global_compress = $self->compress; my $copyright_comment = ''; if ( ${$css} =~ /$COPYRIGHT_COMMENT/ism ) { $copyright_comment = $1; } # Resets copyright_comment() if there is no copyright comment $self->_copyright_comment( $copyright_comment ); if ( not $self->no_compress_comment() and ${$css} =~ /$PACKER_COMMENT/ ) { my $compress = $1; if ( $compress eq '_no_compress_' ) { return ( $cont eq 'scalar' ) ? ${$css} : undef; } $self->compress( $compress ); } ${$css} =~ s/$COMMENT/ /gsm; $self->reggrp_global()->exec( $css ); if ( not $self->remove_copyright() ) { ${$css} = ( $self->copyright() || $self->_copyright_comment() ) . ${$css}; } return ${$css} if ( $cont eq 'scalar' ); } 1; __END__ =head1 NAME CSS::Packer - Another CSS minifier =for html Build Status Coverage Status =head1 VERSION Version 2.07 =head1 DESCRIPTION A fast pure Perl CSS minifier. =head1 SYNOPSIS use CSS::Packer; my $packer = CSS::Packer->init(); $packer->minify( $scalarref, $opts ); To return a scalar without changing the input simply use (e.g. example 2): my $ret = $packer->minify( $scalarref, $opts ); For backward compatibility it is still possible to call 'minify' as a function: CSS::Packer::minify( $scalarref, $opts ); First argument must be a scalarref of CSS-Code. Second argument must be a hashref of options. Possible options are: =over 4 =item compress Defines compression level. Possible values are 'minify' and 'pretty'. Default value is 'pretty'. 'pretty' converts a { color: black ;} div { width:100px; } to a{ color:black; } div{ width:100px; } 'minify' converts the same rules to a{color:black;}div{width:100px;} =item indent Defines number of spaces, used for indentation. Used only when compress is 'pretty'. Default value is 0. =item copyright You can add a copyright notice at the top of the script. =item remove_copyright If there is a copyright notice in a comment it will only be removed if this option is set to a true value. Otherwise the first comment that contains the word "copyright" will be added at the top of the packed script. A copyright comment will be overwritten by a copyright notice defined with the copyright option. =item no_compress_comment If not set to a true value it is allowed to set a CSS comment that prevents the input being packed or defines a compression level. /* CSS::Packer _no_compress_ */ /* CSS::Packer pretty */ =back =head1 AUTHOR Merten Falk, C<< >>. Now maintained by Lee Johnson (LEEJO) =head1 BUGS Please report any bugs or feature requests through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc CSS::Packer =head1 COPYRIGHT & LICENSE Copyright 2008 - 2011 Merten Falk, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L =cut CSS-Packer-2.07/t/pod.t000644 000765 000120 00000000350 13370061705 016000 0ustar00leejohnsonadmin000000 000000 #!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); CSS-Packer-2.07/t/01-interface.t000644 000765 000120 00000004134 13370061705 017400 0ustar00leejohnsonadmin000000 000000 #!perl -T use Test::More; my $not = 18; SKIP: { eval { use CSS::Packer; }; skip( 'CSS::Packer not installed!', $not ) if ( $@ ); plan tests => $not; my $packer = CSS::Packer->init(); ok( ! $packer->no_compress_comment(), 'Default value for no_compress_comment' ); ok( ! $packer->remove_copyright(), 'Default value for remove_copyright' ); is( $packer->compress(), 'pretty', 'Default value for compress' ); is( $packer->copyright(), '', 'Default value for copyright' ); $packer->no_compress_comment( 1 ); ok( $packer->no_compress_comment(), 'Set no_compress_comment.' ); $packer->no_compress_comment( 0 ); ok( ! $packer->no_compress_comment(), 'Unset no_compress_comment.' ); $packer->remove_copyright( 1 ); ok( $packer->remove_copyright(), 'Set remove_copyright.' ); $packer->remove_copyright( 0 ); ok( ! $packer->remove_copyright(), 'Unset remove_copyright.' ); $packer->compress( 'minify' ); is( $packer->compress(), 'minify', 'Set compress to "minify".' ); $packer->compress( 'foo' ); is( $packer->compress(), 'minify', 'Set compress to "foo" failed.' ); $packer->compress( 'pretty' ); is( $packer->compress(), 'pretty', 'Setting compress back to "pretty".' ); $packer->copyright( 'Ich war\'s!' ); is( $packer->copyright(), "/* Ich war's! */\n", 'Set copyright' ); $packer->copyright( 'Ich war\'s' . "\n" . 'nochmal!' ); is( $packer->copyright(), "/* Ich war's\nnochmal! */\n", 'Set copyright' ); $packer->copyright( '' ); is( $packer->copyright(), '', 'Reset copyright' ); my $str = ''; $packer->minify( \$str, {} ); ok( ! $packer->no_compress_comment(), 'Default value for no_compress_comment is still set.' ); is( $packer->compress(), 'pretty', 'Default value for compress is still set.' ); $packer->minify( \$str, { compress => 'minify', no_compress_comment => 1, } ); ok( $packer->no_compress_comment(), 'Set no_compress_comment again.' ); is( $packer->compress(), 'minify', 'Set compress to "minify" again.' ); }CSS-Packer-2.07/t/05-data-image.t000644 000765 000120 00000001763 13370063246 017444 0ustar00leejohnsonadmin000000 000000 #!perl # =========================================================================== # # # All these tests are stolen from CSS::Minifier # # =========================================================================== # use Test::More; use Test::File::Contents; my $not = 1; SKIP: { eval( 'use CSS::Packer' ); skip( 'CSS::Packer not installed!', $not ) if ( $@ ); plan tests => $not; minTest( 's9', { compress => 'pretty' } ); } sub minTest { my $filename = shift; my $opts = shift || {}; open(INFILE, "t/stylesheets/$filename.css") or die("couldn't open file"); open(GOTFILE, ">t/stylesheets/$filename-got.css") or die("couldn't open file"); my $css = join( '', ); my $packer = CSS::Packer->init(); $packer->minify( \$css, $opts ); print GOTFILE $css; close(INFILE); close(GOTFILE); files_eq_or_diff( "t/stylesheets/$filename-got.css", "t/stylesheets/$filename-expected.css", { style => 'Unified' } ); return; } CSS-Packer-2.07/t/00-load.t000644 000765 000120 00000000217 13370061705 016354 0ustar00leejohnsonadmin000000 000000 #!perl -T use Test::More tests => 1; BEGIN { use_ok( 'CSS::Packer' ); } diag( "Testing CSS::Packer $CSS::Packer::VERSION, Perl $], $^X" ); CSS-Packer-2.07/t/changes.t000644 000765 000120 00000000251 13370061705 016626 0ustar00leejohnsonadmin000000 000000 #!perl use strict; use warnings; use Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); CSS-Packer-2.07/t/04-indent.t000644 000765 000120 00000002103 13370061705 016716 0ustar00leejohnsonadmin000000 000000 #!perl # =========================================================================== # # # All these tests are stolen from CSS::Minifier # # =========================================================================== # use Test::More; use Test::File::Contents; my $not = 2; SKIP: { eval( 'use CSS::Packer' ); skip( 'CSS::Packer not installed!', $not ) if ( $@ ); plan tests => $not; minTest( 's1', { compress => 'pretty', indent => 4 } ); minTest( 's2', { compress => 'pretty', indent => 4 } ); } sub minTest { my $filename = shift; my $opts = shift || {}; open(INFILE, "t/stylesheets/$filename.css") or die("couldn't open file"); open(GOTFILE, ">t/stylesheets/$filename-got.css") or die("couldn't open file"); my $css = join( '', ); my $packer = CSS::Packer->init(); $packer->minify( \$css, $opts ); print GOTFILE $css; close(INFILE); close(GOTFILE); files_eq_or_diff( "t/stylesheets/$filename-got.css", "t/stylesheets/$filename-expected-indent.css", { style => 'Unified' } ); return; } CSS-Packer-2.07/t/03-leaks.t000644 000765 000120 00000001702 13370061705 016537 0ustar00leejohnsonadmin000000 000000 #!perl use strict; use warnings; use Test::More; use CSS::Packer; if (! eval "use Test::Memory::Cycle; 1;" ) { plan skip_all => 'Test::Memory::Cycle required for this test'; } my $packer = CSS::Packer->init; memory_cycle_ok( $packer ); my $css = ' html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin : 0; padding : 0; border : 0; font-size : 100%; font : inherit; vertical-align : baseline; } '; for ( 1 .. 5 ) { ok( $packer->minify( \$css,{} ),'minify' ); } memory_cycle_ok( $packer ); done_testing(); CSS-Packer-2.07/t/02-io.t000644 000765 000120 00000006736 13370061705 016062 0ustar00leejohnsonadmin000000 000000 #!perl # =========================================================================== # # # All these tests are stolen from CSS::Minifier # # =========================================================================== # use Test::More; use Test::File::Contents; my $not = 17; SKIP: { eval( 'use CSS::Packer' ); skip( 'CSS::Packer not installed!', $not ) if ( $@ ); plan tests => $not; minTest( 's1', { compress => 'pretty' } ); minTest( 's2', { compress => 'pretty' } ); minTest( 's3', { compress => 'minify' } ); minTest( 's4', { compress => 'minify' } ); minTest( 's5', { compress => 'minify' } ); minTest( 's6', { compress => 'minify' } ); minTest( 's7', { compress => 'minify', no_compress_comment => 1 } ); minTest( 's8', { compress => 'minify' } ); my $packer = CSS::Packer->init(); my $var = "foo {\na : b;\n}"; $packer->minify( \$var, { 'compress' => 'minify' } ); is( $var, 'foo{a:b;}', 'string literal input and ouput (minify)' ); $var = "foo {\na : b;\n}"; $packer->minify( \$var, { 'compress' => 'pretty' } ); is( $var, "foo{\na:b;\n}\n", 'string literal input and ouput (pretty)' ); $var = "foo {\nborder:0;\nmargin:1;\npadding:0\n}"; $packer->minify( \$var, { 'compress' => 'minify' } ); is( $var, "foo{border:0;margin:1;padding:0;}", 'string literal input and ouput (minify)' ); $var = "foo {\nborder:0;\nmargin:1;\npadding:0\n}"; $packer->compress( 'pretty' ); $packer->copyright( 'BSD' ); $packer->minify( \$var ); is( $var, '/* BSD */' . "\nfoo{\nborder:0;\nmargin:1;\npadding:0;\n}\n", 'copyright option compression level "pretty"' ); $packer->compress( 'minify' ); $packer->minify( \$var ); is( $var, '/* BSD */' . "\n" . 'foo{border:0;margin:1;padding:0;}', 'copyright option compression level "minify"' ); $packer = CSS::Packer->init(); $var = "/* Copyright BSD */foo {\nborder:0;\nmargin:1;\npadding:0\n}"; $packer->minify( \$var, { remove_copyright => 1 } ); is( $var, "foo{\nborder:0;\nmargin:1;\npadding:0;\n}\n", 'copyright comment with remove_copyright option'); $var = "/* Copyright BSD */foo {\nborder:0;\nmargin:1;\npadding:0\n}"; $packer->minify( \$var, { remove_copyright => 0 } ); is( $var, '/* Copyright BSD */' . "\n" . "foo{\nborder:0;\nmargin:1;\npadding:0;\n}\n", 'copyright comment without remove_copyright option'); $packer = CSS::Packer->init(); $var = "/* CSS::Packer _no_compress_ */\nfoo {\nborder:0;\nmargin:1;\npadding:0\n}"; $packer->minify( \$var ); is( $var, "/* CSS::Packer _no_compress_ */\nfoo {\nborder:0;\nmargin:1;\npadding:0\n}", '_no_compress_ comment'); $var = "/* CSS::Packer _no_compress_ */\nfoo {\nborder:0;\nmargin:1;\npadding:0\n}"; $packer->minify( \$var, { no_compress_comment => 1 } ); is( $var, "foo{\nborder:0;\nmargin:1;\npadding:0;\n}\n", '_no_compress_ comment with no_compress_comment option'); } sub minTest { my $filename = shift; my $opts = shift || {}; open(INFILE, 't/stylesheets/' . $filename . '.css') or die("couldn't open file"); open(GOTFILE, '>t/stylesheets/' . $filename . '-got.css') or die("couldn't open file"); my $css = join( '', ); my $packer = CSS::Packer->init(); $packer->minify( \$css, $opts ); print GOTFILE $css; close(INFILE); close(GOTFILE); files_eq_or_diff( 't/stylesheets/' . $filename . '-got.css', 't/stylesheets/' . $filename . '-expected.css', { style => 'Unified' } ); return; } CSS-Packer-2.07/t/stylesheets/000755 000765 000120 00000000000 13370240235 017404 5ustar00leejohnsonadmin000000 000000 CSS-Packer-2.07/t/stylesheets/s6.css000644 000765 000120 00000001101 13370061705 020442 0ustar00leejohnsonadmin000000 000000 /* CSS::Packer _no_compress_ */ @media screen { @import url(sheet2.html ); foo { asdf:asdf; ew:12; } bar { content: "a\n b\ asdf"; } } /* from http://www.positioniseverything.net/easyclearing.html */ /* from http://www.positioniseverything.net/easyclearing.html */ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;} /* Hides from IE-mac \*/ /* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */CSS-Packer-2.07/t/stylesheets/s7.css000644 000765 000120 00000001101 13370061705 020443 0ustar00leejohnsonadmin000000 000000 /* CSS::Packer _no_compress_ */ @media screen { @import url(sheet2.html ); foo { asdf:asdf; ew:12; } bar { content: "a\n b\ asdf"; } } /* from http://www.positioniseverything.net/easyclearing.html */ /* from http://www.positioniseverything.net/easyclearing.html */ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;} /* Hides from IE-mac \*/ /* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */CSS-Packer-2.07/t/stylesheets/s5.css000644 000765 000120 00000001036 13370061705 020450 0ustar00leejohnsonadmin000000 000000 @media screen { @import url(sheet2.html ); foo { asdf:asdf; ew:12; } bar { content: "a\n b\ asdf"; } } /* from http://www.positioniseverything.net/easyclearing.html */ /* from http://www.positioniseverything.net/easyclearing.html */ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;} /* Hides from IE-mac \*/ /* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */CSS-Packer-2.07/t/stylesheets/s4.css000644 000765 000120 00000000654 13370061705 020454 0ustar00leejohnsonadmin000000 000000 /* from http://www.positioniseverything.net/easyclearing.html */ /* from http://www.positioniseverything.net/easyclearing.html */ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;} /* Hides from IE-mac \*/ /* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */CSS-Packer-2.07/t/stylesheets/s7-expected.css000644 000765 000120 00000000403 13370061705 022246 0ustar00leejohnsonadmin000000 000000 @media screen{@import url(sheet2.html);foo{asdf:asdf;ew:12;}bar{content:"a\n b\ asdf";}}.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.clearfix{display:inline-block;}* html .clearfix{height:1%;}.clearfix{display:block;}CSS-Packer-2.07/t/stylesheets/s1.css000644 000765 000120 00000000146 13370061705 020445 0ustar00leejohnsonadmin000000 000000 @import url(sheet2.html ); foo { asdf:asdf; ew:12; } bar { content: "a\n b\ asdf"; } CSS-Packer-2.07/t/stylesheets/s6-expected.css000644 000765 000120 00000001101 13370061705 022241 0ustar00leejohnsonadmin000000 000000 /* CSS::Packer _no_compress_ */ @media screen { @import url(sheet2.html ); foo { asdf:asdf; ew:12; } bar { content: "a\n b\ asdf"; } } /* from http://www.positioniseverything.net/easyclearing.html */ /* from http://www.positioniseverything.net/easyclearing.html */ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;} /* Hides from IE-mac \*/ /* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */CSS-Packer-2.07/t/stylesheets/s1-expected.css000644 000765 000120 00000000126 13370061705 022242 0ustar00leejohnsonadmin000000 000000 @import url(sheet2.html); foo{ asdf:asdf; ew:12; } bar{ content:"a\n b\ asdf"; } CSS-Packer-2.07/t/stylesheets/s3.css000644 000765 000120 00000000146 13370061705 020447 0ustar00leejohnsonadmin000000 000000 @import url(sheet2.html ); foo { asdf:asdf; ew:12; } bar { content: "a\n b\ asdf"; } CSS-Packer-2.07/t/stylesheets/s2.css000644 000765 000120 00000000654 13370061705 020452 0ustar00leejohnsonadmin000000 000000 /* from http://www.positioniseverything.net/easyclearing.html */ /* from http://www.positioniseverything.net/easyclearing.html */ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {display: inline-block;} /* Hides from IE-mac \*/ /* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */CSS-Packer-2.07/t/stylesheets/s8-expected.css000644 000765 000120 00000000066 13370061705 022254 0ustar00leejohnsonadmin000000 000000 @keyframes hammerTime{from{top:0px;}to{top:100000px;}}CSS-Packer-2.07/t/stylesheets/s9-expected.css000644 000765 000120 00000000166 13370063235 022256 0ustar00leejohnsonadmin000000 000000 .x-ie8 .x-mask{ background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)} CSS-Packer-2.07/t/stylesheets/s1-expected-indent.css000644 000765 000120 00000000142 13370061705 023517 0ustar00leejohnsonadmin000000 000000 @import url(sheet2.html); foo{ asdf:asdf; ew:12; } bar{ content:"a\n b\ asdf"; } CSS-Packer-2.07/t/stylesheets/s3-expected.css000644 000765 000120 00000000116 13370061705 022243 0ustar00leejohnsonadmin000000 000000 @import url(sheet2.html);foo{asdf:asdf;ew:12;}bar{content:"a\n b\ asdf";}CSS-Packer-2.07/t/stylesheets/s2-expected-indent.css000644 000765 000120 00000000326 13370061705 023524 0ustar00leejohnsonadmin000000 000000 .clearfix:after{ content:"."; display:block; height:0; clear:both; visibility:hidden; } .clearfix{ display:inline-block; } * html .clearfix{ height:1%; } .clearfix{ display:block; } CSS-Packer-2.07/t/stylesheets/s4-expected.css000644 000765 000120 00000000246 13370061705 022250 0ustar00leejohnsonadmin000000 000000 .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.clearfix{display:inline-block;}* html .clearfix{height:1%;}.clearfix{display:block;}CSS-Packer-2.07/t/stylesheets/s9.css000644 000765 000120 00000000173 13370062215 020452 0ustar00leejohnsonadmin000000 000000 .x-ie8 .x-mask{ background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7) } CSS-Packer-2.07/t/stylesheets/s8.css000644 000765 000120 00000000107 13370061705 020451 0ustar00leejohnsonadmin000000 000000 @keyframes hammerTime { from {top: 0px;} to {top: 100000px;} } CSS-Packer-2.07/t/stylesheets/s5-expected.css000644 000765 000120 00000000403 13370061705 022244 0ustar00leejohnsonadmin000000 000000 @media screen{@import url(sheet2.html);foo{asdf:asdf;ew:12;}bar{content:"a\n b\ asdf";}}.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.clearfix{display:inline-block;}* html .clearfix{height:1%;}.clearfix{display:block;}CSS-Packer-2.07/t/stylesheets/s2-expected.css000644 000765 000120 00000000266 13370061705 022250 0ustar00leejohnsonadmin000000 000000 .clearfix:after{ content:"."; display:block; height:0; clear:both; visibility:hidden; } .clearfix{ display:inline-block; } * html .clearfix{ height:1%; } .clearfix{ display:block; }