Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Andrewpk/assetic
...
head fork: Andrewpk/assetic
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
1  phpunit.xml.dist
@@ -26,6 +26,7 @@
<!-- <server name="CSSMIN" value="/path/to/cssmin/source/CssMin.php" /> -->
<!-- <server name="CSSEMBED_JAR" value="/path/to/cssembed.jar" /> -->
<!-- <server name="PACKAGER" value="/path/to/packager.php" /> -->
+ <!-- <server name="CSSCRUSH" value="/path/to/CssCrush.php" /> -->
</php>
<filter>
View
83 src/Assetic/Filter/CssCrushFilter.php
@@ -0,0 +1,83 @@
+<?php
+
+/*
+ * This file is part of the Assetic package, an OpenSky project.
+ *
+ * (c) 2010-2011 OpenSky Project Inc
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Assetic\Filter;
+
+use Assetic\Asset\AssetInterface;
+use Assetic\Filter\FilterInterface;
+
+/**
+ * Loads CssCrush files.
+ *
+ * @link http://the-echoplex.net/csscrush/
+ * @author Kris Wallsmith <kris.wallsmith@gmail.com>
+ *
+ * @todo import directives do not work
+ */
+class CssCrushFilter implements FilterInterface
+{
+ private $debug = false;
+ private $boilerplate;
+ private $versioning = false;
+
+ public function setDebug($debug)
+ {
+ $this->debug = $debug;
+ }
+
+ public function setBoilerplate($boilerplate)
+ {
+ $this->boilerplate = $boilerplate;
+ }
+
+ public function setVersioning($versioning)
+ {
+ $this->versioning = $versioning;
+ }
+
+ public function filterLoad(AssetInterface $asset)
+ {
+ $options = array();
+
+ if (null !== $this->debug) {
+ $options['debug'] = (Boolean) $this->debug;
+ }
+
+ if (null !== $this->boilerplate) {
+ $options['boilerplate'] = (Boolean) $this->boilerplate;
+ }
+
+ if (null !== $this->versioning) {
+ $options['versioning'] = (Boolean) $this->versioning;
+ }
+
+ // remember the previous document root
+ $snapshot = \CssCrush::$config->docRoot;
+
+ // setup the input
+ $input = tempnam(sys_get_temp_dir(), 'assetic_csscrush');
+ file_put_contents($input, $asset->getContent());
+
+ // process the asset
+ \CssCrush::$config->docRoot = dirname($input);
+ $output = \CssCrush::file('/'.basename($input), $options);
+ $asset->setContent(file_get_contents(\CssCrush::$config->docRoot.$output));
+
+ // cleanup
+ unlink($input);
+ unlink(\CssCrush::$config->docRoot.$output);
+ \CssCrush::$config->docRoot = $snapshot;
+ }
+
+ public function filterDump(AssetInterface $asset)
+ {
+ }
+}
View
39 tests/Assetic/Test/Filter/CssCrushFilterTest.php
@@ -0,0 +1,39 @@
+<?php
+
+/*
+ * This file is part of the Assetic package, an OpenSky project.
+ *
+ * (c) 2010-2011 OpenSky Project Inc
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Assetic\Test\Filter;
+
+use Assetic\Asset\FileAsset;
+use Assetic\Filter\CssCrushFilter;
+
+/**
+ * @group integration
+ */
+class CssCrushFilterTest extends \PHPUnit_Framework_TestCase
+{
+ protected function setUp()
+ {
+ if (!class_exists('CssCrush', false)) {
+ $this->markTestSkipped('CssCrush is not available.');
+ }
+ }
+
+ public function testLoad()
+ {
+ $asset = new FileAsset(__DIR__.'/fixtures/csscrush/main.css', array(), __DIR__.'/fixtures/csscrush', 'main.css');
+ $asset->load();
+
+ $filter = new CssCrushFilter();
+ $filter->filterLoad($asset);
+
+ $this->assertContains('strong { font-weight: bold; }', $asset->getContent(), '->filterLoad() calls CssCrush');
+ }
+}
View
2  tests/Assetic/Test/Filter/fixtures/csscrush/main.css
@@ -0,0 +1,2 @@
+@import url("more.css");
+body { color: red; }
View
1  tests/Assetic/Test/Filter/fixtures/csscrush/more.css
@@ -0,0 +1 @@
+strong { font-weight: bold; }
View
4 tests/bootstrap.php
@@ -43,3 +43,7 @@
if (isset($_SERVER['PACKAGER'])) {
require_once $_SERVER['PACKAGER'];
}
+
+if (isset($_SERVER['CSSCRUSH'])) {
+ require_once $_SERVER['CSSCRUSH'];
+}

No commit comments for this range

Something went wrong with that request. Please try again.