[Rt-commit] r5344 - in CSS-Squish: lib/CSS t t/css t/css/foo
trs at bestpractical.com
trs at bestpractical.com
Wed Jun 7 15:43:00 EDT 2006
Author: trs
Date: Wed Jun 7 15:42:59 2006
New Revision: 5344
Added:
CSS-Squish/t/03-skip-http.t
CSS-Squish/t/04-recursion.t
CSS-Squish/t/99-pod-coverage.t
CSS-Squish/t/99-pod.t
CSS-Squish/t/css/03-skip-http.css
CSS-Squish/t/css/04-recursion.css
CSS-Squish/t/css/foo/
CSS-Squish/t/css/foo/04-recursion-2.css
CSS-Squish/t/css/foo/04-recursion-3.css
Modified:
CSS-Squish/ (props changed)
CSS-Squish/CHANGES
CSS-Squish/MANIFEST
CSS-Squish/Makefile.PL
CSS-Squish/README
CSS-Squish/lib/CSS/Squish.pm
CSS-Squish/t/01-basic.t
CSS-Squish/t/02-edge-cases.t
CSS-Squish/t/css/01-basic.css
CSS-Squish/t/css/02-edge-cases.css
Log:
r12745 at zot: tom | 2006-06-07 15:42:51 -0400
* Skip remote URLs
* Handle relative paths correctly
* More tests
* Update README
Modified: CSS-Squish/CHANGES
==============================================================================
--- CSS-Squish/CHANGES (original)
+++ CSS-Squish/CHANGES Wed Jun 7 15:42:59 2006
@@ -1,3 +1,3 @@
Revision history for Perl extension CSS::Squish.
-0.01 Wed Mar 31 2006
+0.01 Wed Jun 7 2006
Modified: CSS-Squish/MANIFEST
==============================================================================
--- CSS-Squish/MANIFEST (original)
+++ CSS-Squish/MANIFEST Wed Jun 7 15:42:59 2006
@@ -2,14 +2,21 @@
lib/CSS/Squish.pm
Makefile.PL
MANIFEST This list of files
-META.yml
README
t/00-use.t
t/01-basic.t
t/02-edge-cases.t
+t/03-skip-http.t
+t/04-recursion.t
+t/99-pod-coverage.t
+t/99-pod.t
t/css/01-basic-import.css
t/css/01-basic.css
t/css/02-edge-cases.css
+t/css/03-skip-http.css
+t/css/04-recursion.css
t/css/blam.css
t/css/foo.css
+t/css/foo/04-recursion-2.css
+t/css/foo/04-recursion-3.css
t/css/foo2.css
Modified: CSS-Squish/Makefile.PL
==============================================================================
--- CSS-Squish/Makefile.PL (original)
+++ CSS-Squish/Makefile.PL Wed Jun 7 15:42:59 2006
@@ -1,16 +1,14 @@
use strict;
use ExtUtils::MakeMaker;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
+
WriteMakefile(
NAME => 'CSS::Squish',
- VERSION_FROM => 'lib/CSS/Squish.pm', # finds $VERSION
- PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ VERSION_FROM => 'lib/CSS/Squish.pm',
+ PREREQ_PM => {
+ 'File::Spec' => 0
+ },
($] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT_FROM => 'lib/CSS/Squish.pm', # retrieve abstract from module
+ (ABSTRACT_FROM => 'lib/CSS/Squish.pm',
AUTHOR => 'Thomas Sibley <trs at bestpractical.com>') : ()),
- LIBS => [''], # e.g., '-lm'
- DEFINE => '', # e.g., '-DHAVE_SOMETHING'
- INC => '-I.', # e.g., '-I. -I/usr/include/other'
);
Modified: CSS-Squish/README
==============================================================================
--- CSS-Squish/README (original)
+++ CSS-Squish/README Wed Jun 7 15:42:59 2006
@@ -0,0 +1,50 @@
+NAME
+ CSS::Squish - Compact many CSS files into one big file
+
+SYNOPSIS
+ use CSS::Squish;
+ my $concatenated = CSS::Squish->concatenate(@files);
+
+DESCRIPTION
+ This module takes a list of CSS files and concatenates them, making sure
+ to honor any valid @import statements included in the files.
+
+ Following the CSS 2.1 spec, @import statements must be the first rules
+ in a CSS file. Media-specific @import statements will be honored by
+ enclosing the included file in an @media rule. This has the side effect
+ of actually *improving* compatibility in Internet Explorer, which
+ ignores media-specific @import rules but understands @media rules.
+
+ It is possible that feature versions will include methods to compact
+ whitespace and other parts of the CSS itself, but this functionality is
+ not supported at the current time.
+
+METHODS
+ CSS::Squish->concatenate(@files)
+ Takes a list of files to concatenate and returns the results as one big
+ scalar.
+
+ CSS::Squish->concatenate_to($dest, @files)
+ Takes a filehandle to print to and a list of files to concatenate.
+ "concatenate" uses this method with an "open"ed scalar.
+
+BUGS
+ At the current time, comments are not skipped. This means comments
+ happening before @import statements at the top of a file will cause the
+ @import rules to not be parsed. Make sure the @import rules are the very
+ first thing in the file (and only one per line).
+
+ All other bugs should be reported via
+ <http://rt.cpan.org/Public/Dist/Display.html?Name=CSS-Squish> or
+ bugs-CSS-Squish at rt.cpan.org.
+
+AUTHOR
+ Thomas Sibley <trs at bestpractical.com>
+
+COPYRIGHT AND LICENSE
+ Copyright (c) 2006.
+
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself, either Perl version 5.8.3 or, at
+ your option, any later version of Perl 5 you may have available.
+
Modified: CSS-Squish/lib/CSS/Squish.pm
==============================================================================
--- CSS-Squish/lib/CSS/Squish.pm (original)
+++ CSS-Squish/lib/CSS/Squish.pm Wed Jun 7 15:42:59 2006
@@ -5,6 +5,8 @@
$CSS::Squish::VERSION = '0.01';
+use File::Spec;
+
=head1 NAME
CSS::Squish - Compact many CSS files into one big file
@@ -98,26 +100,38 @@
next FILE;
}
- PROCESS_IMPORTS:
+ IMPORT:
while (my $line = <$fh>) {
if ($line =~ /$AT_IMPORT/) {
my $import = $1;
my $media = $2;
- print $dest "\n/**\n * Original CSS: $line */\n\n";
+ if ( $import =~ m{^https?://} ) {
+ # Skip remote URLs
+ print $dest $line;
+ next IMPORT;
+ }
+
+ # We need the path relative to where we're importing it from
+ my @spec = File::Spec->splitpath( $file );
+ my $import_path = File::Spec->catpath( @spec[0,1], $import );
+
+ print $dest "\n/**\n * From $file: $line */\n\n";
if (defined $media) {
print $dest "\@media $media {\n";
- $self->concatenate_to($dest, $import);
+ $self->concatenate_to($dest, $import_path);
print $dest "}\n";
}
else {
- $self->concatenate_to($dest, $import);
+ $self->concatenate_to($dest, $import_path);
}
+
+ print $dest "\n/** End of $import */\n\n";
}
else {
print $dest $line;
- last PROCESS_IMPORTS if not $line =~ /^\s*$/;
+ last IMPORT if not $line =~ /^\s*$/;
}
}
print $dest $_ while <$fh>;
Modified: CSS-Squish/t/01-basic.t
==============================================================================
--- CSS-Squish/t/01-basic.t (original)
+++ CSS-Squish/t/01-basic.t Wed Jun 7 15:42:59 2006
@@ -10,10 +10,13 @@
/**
- * Original CSS: @import "t/css/01-basic-import.css";
+ * From t/css/01-basic.css: @import "01-basic-import.css";
*/
inside 01-basic-import.css
+
+/** End of 01-basic-import.css */
+
body { color: blue; }
EOT
Modified: CSS-Squish/t/02-edge-cases.t
==============================================================================
--- CSS-Squish/t/02-edge-cases.t (original)
+++ CSS-Squish/t/02-edge-cases.t Wed Jun 7 15:42:59 2006
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More skip_all => "diff says the output is the same. Test::More doesn't. Argh.";
+use Test::More skip_all => "Not complete.";
use_ok("CSS::Squish");
Added: CSS-Squish/t/03-skip-http.t
==============================================================================
--- (empty file)
+++ CSS-Squish/t/03-skip-http.t Wed Jun 7 15:42:59 2006
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use_ok("CSS::Squish");
+
+my $expected = <<'EOT';
+ at import url("http://example.com/foo.css");
+foobar
+EOT
+
+my $result = CSS::Squish->concatenate('t/css/03-skip-http.css');
+
+is($result, $expected, "Skip remote URLs");
+
Added: CSS-Squish/t/04-recursion.t
==============================================================================
--- (empty file)
+++ CSS-Squish/t/04-recursion.t Wed Jun 7 15:42:59 2006
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use_ok("CSS::Squish");
+
+my $expected = <<'EOT';
+
+/**
+ * From t/css/04-recursion.css: @import "foo/04-recursion-2.css";
+ */
+
+
+/**
+ * From t/css/foo/04-recursion-2.css: @import "04-recursion-3.css";
+ */
+
+level 3
+
+/** End of 04-recursion-3.css */
+
+level 2
+
+/** End of foo/04-recursion-2.css */
+
+foobar
+EOT
+
+my $result = CSS::Squish->concatenate('t/css/04-recursion.css');
+
+is($result, $expected, "Recursive import");
+
Added: CSS-Squish/t/99-pod-coverage.t
==============================================================================
--- (empty file)
+++ CSS-Squish/t/99-pod-coverage.t Wed Jun 7 15:42:59 2006
@@ -0,0 +1,12 @@
+use Test::More;
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
+all_pod_coverage_ok( );
+
+# Workaround for dumb bug (fixed in 5.8.7) where Test::Builder thinks that
+# certain "die"s that happen inside evals are not actually inside evals,
+# because caller() is broken if you turn on $^P like Module::Refresh does
+#
+# (I mean, if we've gotten to this line, then clearly the test didn't die, no?)
+Test::Builder->new->{Test_Died} = 0;
+
Added: CSS-Squish/t/99-pod.t
==============================================================================
--- (empty file)
+++ CSS-Squish/t/99-pod.t Wed Jun 7 15:42:59 2006
@@ -0,0 +1,5 @@
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
+
Modified: CSS-Squish/t/css/01-basic.css
==============================================================================
--- CSS-Squish/t/css/01-basic.css (original)
+++ CSS-Squish/t/css/01-basic.css Wed Jun 7 15:42:59 2006
@@ -1,4 +1,4 @@
- at import "t/css/01-basic-import.css";
+ at import "01-basic-import.css";
body { color: blue; }
Modified: CSS-Squish/t/css/02-edge-cases.css
==============================================================================
--- CSS-Squish/t/css/02-edge-cases.css (original)
+++ CSS-Squish/t/css/02-edge-cases.css Wed Jun 7 15:42:59 2006
@@ -1,13 +1,13 @@
- at import "t/css/blam.css" print;
- at import "t/css/blam.css";
- at import url( "t/css/foo.css") print,aural;
- at import url(t/css/foo2.css ) print, aural, tty;
+ at import "blam.css" print;
+ at import "blam.css";
+ at import url( "foo.css") print,aural;
+ at import url(foo2.css ) print, aural, tty;
@import 'failure.css' print;
fjkls
jk
- at import url("t/css/foo.css");
+ at import url("foo.css");
last
Added: CSS-Squish/t/css/03-skip-http.css
==============================================================================
--- (empty file)
+++ CSS-Squish/t/css/03-skip-http.css Wed Jun 7 15:42:59 2006
@@ -0,0 +1,2 @@
+ at import url("http://example.com/foo.css");
+foobar
Added: CSS-Squish/t/css/04-recursion.css
==============================================================================
--- (empty file)
+++ CSS-Squish/t/css/04-recursion.css Wed Jun 7 15:42:59 2006
@@ -0,0 +1,2 @@
+ at import "foo/04-recursion-2.css";
+foobar
Added: CSS-Squish/t/css/foo/04-recursion-2.css
==============================================================================
--- (empty file)
+++ CSS-Squish/t/css/foo/04-recursion-2.css Wed Jun 7 15:42:59 2006
@@ -0,0 +1,2 @@
+ at import "04-recursion-3.css";
+level 2
Added: CSS-Squish/t/css/foo/04-recursion-3.css
==============================================================================
--- (empty file)
+++ CSS-Squish/t/css/foo/04-recursion-3.css Wed Jun 7 15:42:59 2006
@@ -0,0 +1 @@
+level 3
More information about the Rt-commit
mailing list