diff --git a/.gitignore b/.gitignore
index 3c3629e..889a7f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
node_modules
+
+.zedstate
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
index 03b2068..11bb6fa 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,8 +1,25 @@
{
+ "curly": true,
+ "eqeqeq": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": true,
+ "nonew": true,
+ "sub": true,
+ "undef": true,
+ "unused": true,
+ "trailing": true,
+ "boss": true,
+ "eqnull": true,
+ "strict": true,
+ "immed": true,
+ "expr": true,
+ "latedef": "true",
+ "quotmark": "single",
+ "indent": 4,
"node": true,
"globals": {
- "describe": false,
- "it": false,
- "expect": false
+ "describe": false,
+ "it": false
}
}
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index ff74a05..73d1c7d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,3 @@
language: node_js
node_js:
- - '0.10'
\ No newline at end of file
+ - '0.12'
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 22c13ef..66033ed 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2014 André König, Germany
+Copyright (c) 2014 - 2015 André König, Germany
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
+THE SOFTWARE.
diff --git a/bin/imacss b/bin/imacss
index c3ed4ed..7cd9c0d 100755
--- a/bin/imacss
+++ b/bin/imacss
@@ -3,7 +3,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,15 +13,16 @@
*
*/
-var fs = require('fs'),
- path = require('path'),
- imacss = require('../'),
- pkg = require('../package.json'),
- args = {
- glob: process.argv[2],
- cssfile: process.argv[3],
- cssclass: process.argv[4]
- };
+'use strict';
+
+var path = require('path');
+var imacss = require('../');
+
+var pkg = require('../package.json');
+var args = {
+ glob: process.argv[2],
+ cssclass: process.argv[4]
+};
/**
* Prints an error message to the console and exits
@@ -73,15 +74,6 @@ if ('version' === args.glob) {
return console.log(pkg.version);
}
-//
-// Check if a css file has been defined.
-//
-if (args.cssfile && !isPath(args.cssfile)) {
- args.cssclass = args.cssfile;
-
- delete args.cssfile;
-}
-
args.glob = normalizePath(args.glob);
imacss
@@ -89,4 +81,4 @@ imacss
.on('error', function (err) {
error('Converting images failed: ' + err);
})
- .pipe(args.cssfile ? fs.createWriteStream(args.cssfile) : process.stdout);
\ No newline at end of file
+ .pipe(process.stdout);
\ No newline at end of file
diff --git a/changelog.md b/changelog.md
new file mode 100644
index 0000000..87d4ef5
--- /dev/null
+++ b/changelog.md
@@ -0,0 +1,30 @@
+# 1.0.0 (2015-06-15)
+
+ * ea1d1ea refactoring: `mocha` migration.
+ * d90808a breaking change: the CLI does not provide the possibility for piping into a file. Just use `imacss *.svg > images.css`
+ * c87cef4 feature: embedding SVG images as raw text strings instead of base64
+ * 34639f4 deps: upgrade
+
+# 0.3.0 (2014-08-13)
+
+ * Possibility to define a function which will generate an own CSS class structure (by [@juice49](https://github.com/juice49)).
+
+# Version 0.2.2 (2014-02-21)
+
+ * Added more files to .npmignore.
+
+# Version 0.2.1 (2014-02-17)
+
+ * Added `preferGlobal` flag to the `package.json`.
+
+# Version 0.2.0 (2014-02-17)
+
+ * Implemented support for passing a vinyl file object to the transform method.
+
+# Version 0.1.1 (2014-02-11)
+
+ * Fixed typos in the README.
+
+# Version 0.1.0 (2014-02-11)
+
+ * Initial Release. Implemented the core functionality (CLI and API).
\ No newline at end of file
diff --git a/gulpfile.js b/gulpfile.js
deleted file mode 100644
index 0a7ded6..0000000
--- a/gulpfile.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * imacss
- *
- * Copyright(c) 2014 André König
- * MIT Licensed
- *
- */
-
-/**
- * @author André König
- *
- */
-
-'use strict';
-
-var gulp = require('gulp'),
- jshint = require('gulp-jshint'),
- jasmine = require('gulp-jasmine'),
- paths = {};
-
-paths.sources = ['./lib/**/*.js', './specs/**/*.js', 'gulpfile.js', 'index.js'];
-paths.specs = ['./specs/**/*.spec.js'];
-
-gulp.task('lint', function () {
- gulp.src(paths.sources)
- .pipe(jshint('./.jshintrc'))
- .pipe(jshint.reporter('default'));
-});
-
-gulp.task('test', function () {
- gulp.src(paths.specs)
- .pipe(jasmine());
-});
-
-gulp.task('default', ['lint', 'test']);
\ No newline at end of file
diff --git a/index.js b/index.js
index 6632162..4447574 100644
--- a/index.js
+++ b/index.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,23 +13,24 @@
'use strict';
-var domain = require('domain'),
- pipeline = require('./lib'),
- pkg = require('./package.json');
+var domain = require('domain');
+
+var pipeline = require('./lib');
+var pkg = require('./package.json');
/**
* Transforms image files to base64 encoded data URIs and embeds them into CSS files.
*
* @param {string} glob A globbing expression for matching particular image files.
- * @param {string} clazz The CSS class which will be used as a prefix.
+ * @param {string | function} css The CSS class which will be used as a prefix, or a function to generate the CSS rule set.
*
*/
-exports.transform = function transform (glob, clazz) {
+exports.transform = function transform (glob, css) {
- var execution = domain.create(),
- transformation;
+ var execution = domain.create();
+ var transformation;
- clazz = clazz || pkg.name;
+ css = css || pkg.name;
execution.on('error', function (err) {
transformation.emit('error', err);
@@ -42,7 +43,7 @@ exports.transform = function transform (glob, clazz) {
.pipe(pipeline.slugify())
.pipe(pipeline.mimeify())
.pipe(pipeline.urify())
- .pipe(pipeline.cssify(clazz));
+ .pipe(pipeline.cssify(css));
});
return transformation;
diff --git a/lib/cssify.js b/lib/cssify.js
index f8ea304..d192832 100644
--- a/lib/cssify.js
+++ b/lib/cssify.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,21 +13,22 @@
'use strict';
-var stream = require('stream'),
- util = require('util'),
- Utilities = require('./utilities');
+var stream = require('stream');
+var util = require('util');
+
+var Utilities = require('./utilities');
/**
* The stream which will transform the internal image
* data structure into a CSS selector with the embedded file.
*
- * @param {string} clazz The CSS class which will be used as a prefix.
+ * @param {string | function} css The CSS class which will be used as a prefix, or a function to generate the CSS rule set.
* @param {object} options Stream options.
*
*/
-function Cssify (clazz, options) {
+function Cssify (css, options) {
- this.$$class = clazz;
+ this.css = css;
options = options || {};
@@ -48,11 +49,19 @@ Cssify.prototype._transform = function _transform (image, enc, cb) {
'background-image': 'url(\'' + image.datauri + '\')'
};
- this.push(Utilities.getCSSSelector(this.$$class, image.slug, selector) + '\n');
+ switch (typeof this.css) {
+ case 'string':
+ this.push(Utilities.getCSSSelector(this.css, image.slug, selector) + '\n');
+ break;
+
+ case 'function':
+ this.push(this.css(image) + '\n');
+ break;
+ }
cb();
};
-module.exports = function (clazz) {
- return new Cssify(clazz);
+module.exports = function (css) {
+ return new Cssify(css);
};
\ No newline at end of file
diff --git a/lib/index.js b/lib/index.js
index 200d9d8..ad74781 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,14 +13,13 @@
'use strict';
-var stream = require('stream'),
- through = require('through2'),
- vfs = require('vinyl-fs'),
- purify = require('./purify'),
- slugify = require('./slugify'),
- mimeify = require('./mimeify'),
- urify = require('./urify'),
- cssify = require('./cssify');
+var through = require('through2');
+var vfs = require('vinyl-fs');
+var purify = require('./purify');
+var slugify = require('./slugify');
+var mimeify = require('./mimeify');
+var urify = require('./urify');
+var cssify = require('./cssify');
exports.purify = purify;
exports.slugify = slugify;
diff --git a/lib/mimeify.js b/lib/mimeify.js
index 1838470..90a7212 100644
--- a/lib/mimeify.js
+++ b/lib/mimeify.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,9 +13,9 @@
'use strict';
-var stream = require('stream'),
- util = require('util'),
- Utilities = require('./utilities');
+var stream = require('stream');
+var util = require('util');
+var Utilities = require('./utilities');
/**
* The stream which will determine the respective image MIME type
diff --git a/lib/purify.js b/lib/purify.js
index e09e017..4e6f1d4 100644
--- a/lib/purify.js
+++ b/lib/purify.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,10 +13,9 @@
'use strict';
-var stream = require('stream'),
- util = require('util'),
- path = require('path'),
- slug = require('slug');
+var stream = require('stream');
+var util = require('util');
+var path = require('path');
/**
* The stream which will convert the vinyl file to
diff --git a/lib/slugify.js b/lib/slugify.js
index 088f2b4..9bdb0fa 100644
--- a/lib/slugify.js
+++ b/lib/slugify.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,10 +13,10 @@
'use strict';
-var stream = require('stream'),
- path = require('path'),
- util = require('util'),
- slug = require('slug');
+var stream = require('stream');
+var path = require('path');
+var util = require('util');
+var slug = require('slug');
/**
* The stream which will create a slug based on the
diff --git a/lib/urify.js b/lib/urify.js
index ed7cf37..292bdfe 100644
--- a/lib/urify.js
+++ b/lib/urify.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,9 +13,10 @@
'use strict';
-var stream = require('stream'),
- util = require('util'),
- Utilities = require('./utilities');
+var stream = require('stream');
+var util = require('util');
+
+var Utilities = require('./utilities');
/**
* The stream which generate the data URI of the image.
@@ -40,7 +41,7 @@ util.inherits(Urify, stream.Transform);
*/
Urify.prototype._transform = function _transform (image, enc, cb) {
- image.datauri = Utilities.getDataURI(image.mime, image.base64);
+ image.datauri = Utilities.getDataURI(image);
this.push(image);
diff --git a/lib/utilities/css.js b/lib/utilities/css.js
index 879e5a7..0c574e9 100644
--- a/lib/utilities/css.js
+++ b/lib/utilities/css.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -24,8 +24,8 @@
*
*/
exports.constructSelector = function constructSelector (prefix, name, properties) {
- var selector = '',
- prop;
+ var selector = '';
+ var prop;
// Creating cascade: e.g. .imacss.imacss-foobar {...}
selector = '.' + prefix + '.' + prefix + '-' + name + '{';
diff --git a/lib/utilities/index.js b/lib/utilities/index.js
index d6eb8c1..722f02e 100644
--- a/lib/utilities/index.js
+++ b/lib/utilities/index.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,10 +13,10 @@
'use strict';
-var mime = require('./mime'),
- uri = require('./uri'),
- css = require('./css');
+var mime = require('./mime');
+var uri = require('./uri');
+var css = require('./css');
-exports.getMimeType = mime.detect;
-exports.getDataURI = uri.constructDataURI;
+exports.getMimeType = mime.detect;
+exports.getDataURI = uri.constructDataURI;
exports.getCSSSelector = css.constructSelector;
\ No newline at end of file
diff --git a/lib/utilities/mime.js b/lib/utilities/mime.js
index 600d881..3991e4b 100644
--- a/lib/utilities/mime.js
+++ b/lib/utilities/mime.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -13,11 +13,10 @@
'use strict';
-var fs = require('fs'),
- filetypes = [
- {mime: 'image/jpeg', magicnumber: 'FFD8', extensions: ['jpg', 'jpeg']},
- {mime: 'image/png', magicnumber: '89504E470D0A1A0A', extensions: ['png']}
- ];
+var filetypes = [
+ {mime: 'image/jpeg', magicnumber: 'FFD8', extensions: ['jpg', 'jpeg']},
+ {mime: 'image/png', magicnumber: '89504E470D0A1A0A', extensions: ['png']}
+];
/**
* Determines the MIME type of the given image.
@@ -26,12 +25,12 @@ var fs = require('fs'),
* @param {function} callback -> err, mime{string}
*
*/
-exports.detect = function detect (image, callback) {
- var buffer = image.toString('hex').toUpperCase(),
- i = filetypes.length - 1,
- filetype,
- magic,
- mime;
+module.exports.detect = function detect (image, callback) {
+ var buffer = image.toString('hex').toUpperCase();
+ var i = filetypes.length - 1;
+ var filetype;
+ var magic;
+ var mime;
//
// Helper function for checking if a file is a SVG.
@@ -39,9 +38,9 @@ exports.detect = function detect (image, callback) {
//
function isSVG (data) {
- var i = 0,
- len = data.length,
- snippet;
+ var i = 0;
+ var len = data.length;
+ var snippet;
for (i; i < len; i = i + 1) {
snippet = data.slice(i, i + 2).toString('hex');
@@ -81,4 +80,4 @@ exports.detect = function detect (image, callback) {
}
return callback(null, mime || 'Unknown');
-};
\ No newline at end of file
+};
diff --git a/lib/utilities/uri.js b/lib/utilities/uri.js
index aea0102..a96db5c 100644
--- a/lib/utilities/uri.js
+++ b/lib/utilities/uri.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -16,12 +16,22 @@
/**
* Constructs a RFC 2397 conform data URI.
*
- * @param {string} mime The MIME type
- * @param {string} base64 The base64 encoded file
+ * @param {object} image The vinyl file object
*
* @return {string} The created data URI
*
*/
-exports.constructDataURI = function constructDataURI (mime, base64) {
- return 'data:' + mime + ';base64,' + base64;
-};
\ No newline at end of file
+module.exports.constructDataURI = function constructDataURI (image) {
+ var data = image.base64;
+ var type = 'base64';
+
+ if ('image/svg+xml' === image.mime) {
+ type = 'utf-8';
+ data = image.contents
+ .toString(type)
+ .replace(/\r?\n|\r/g, '')
+ .replace('#', '%23');
+ }
+
+ return 'data:' + image.mime + ';' + type + ',' + data;
+};
diff --git a/package.json b/package.json
index c4d9202..01e5034 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "imacss",
- "version": "0.2.2",
+ "version": "1.0.0",
"description": "An application and library that transforms image files to data URIs and embeds these into a single CSS file.",
"author": {
"name": "André König",
@@ -8,9 +8,10 @@
},
"license": "MIT",
"main": "index.js",
- "preferGlobal": true,
"scripts": {
- "test": "gulp"
+ "lint": "jshint -c ./.jshintrc ./*.js ./lib/**/*.js ./specs/*.js",
+ "mocha": "mocha ./specs/*.spec.js",
+ "test": "npm run lint && npm run mocha"
},
"bin": {
"imacss": "./bin/imacss"
@@ -33,14 +34,14 @@
},
"homepage": "https://github.com/akoenig/imacss",
"dependencies": {
- "vinyl-fs": "0.0.2",
- "slug": "~0.4.0",
- "through2": "~0.4.1"
+ "slug": "^0.9.1",
+ "through2": "^2.0.0",
+ "vinyl-fs": "^1.0.0"
},
"devDependencies": {
- "gulp": "~3.5.2",
- "gulp-jshint": "~1.4.0",
- "gulp-jasmine": "~0.1.3",
- "gulp-util": "~2.2.14"
+ "expect.js": "^0.3.1",
+ "jshint": "^2.8.0",
+ "mocha": "^2.2.5",
+ "gulp-util": "^3.0.5"
}
-}
+}
\ No newline at end of file
diff --git a/README.md b/readme.md
similarity index 73%
rename from README.md
rename to readme.md
index 670da97..42e75b5 100644
--- a/README.md
+++ b/readme.md
@@ -44,15 +44,15 @@ Embed all SVGs in a particular directory and all its subdirectories (will pipe t
Embed all SVGs in a particular directory and transfer them to a CSS file which will be saved in the CWD.
- $ imacss "~/projects/webapp/images/*.svg" images.svg.css
+ $ imacss "~/projects/webapp/images/*.svg" > images.svg.css
Embed all SVGs _and_ PNGs in a particular directory and transfer them to a CSS file which will be saved in the CWD.
- $ imacss "~/projects/webapp/images/*.{svg,png}" images.css
+ $ imacss "~/projects/webapp/images/*.{svg,png}" > images.css
If you don't like the `imacss` selector namespace you are able to modify it as well.
- $ imacss "~/projects/webapp/images/*.{svg,png}" images.css foobar
+ $ imacss "~/projects/webapp/images/*.{svg,png}" foobar > images.css
will produce this selector structure in the CSS file:
@@ -60,6 +60,8 @@ will produce this selector structure in the CSS file:
.foobar.foobar-github {...}
```
+**Important:** Please note that `imacss` does not embed `image/svg+xml` as `base64` strings. Instead it will use the raw `utf-8` representation.
+
## API
If you would like to use the `imacss` functionality within your application, there is an API for that.
@@ -86,6 +88,10 @@ The path to the images which should be transformed. You can use any glob pattern
`namespace` (optional; default=imacss)
+String || Function
+
+A string containing the css class namespace prefix, or a function to generate the entire CSS ruleset.
+
The CSS selector namespace.
### Usage example
@@ -95,35 +101,29 @@ var imacss = require('imacss');
imacss
.transform('/path/to/your/images/*.png')
- .on('error', function (err) {
- error('Transforming images failed: ' + err);
+ .on('error', function onError (err) {
+ console.error('Transforming images failed: ' + err);
})
.pipe(process.stdout);
```
+#### Passing a function to customize the resulting CSS rule set
-## Changelog
-
-### Version 0.2.2 (20140221)
-
-- Added more files to .npmignore.
-
-### Version 0.2.1 (20140217)
-
-- Added `preferGlobal` flag to the `package.json`.
-
-### Version 0.2.0 (20140217)
-
-- Implemented support for passing a vinyl file object to the transform method.
-
-### Version 0.1.1 (20140211)
-
-- Fixed typos in the README.
+```javascript
+var imacss = require('imacss');
-### Version 0.1.0 (20140211)
+function generateCss(image) {
+ return '.image-' + image.slug + ' { ' + 'background-image:' + 'url(\'' + image.datauri + '\'); }';
+}
-- Initial Release. Implemented the core functionality (CLI and API).
+imacss
+ .transform('/path/to/your/images/*.png', generateCss)
+ .on('error', function (err) {
+ console.error('Transforming images failed: ' + err);
+ })
+ .pipe(process.stdout);
+```
## Author
-Copyright 2014, [André König](http://iam.andrekoenig.info) (andre.koenig@posteo.de)
+Copyright 2014 - 2015, [André König](http://andrekoenig.info) (andre.koenig@posteo.de)
diff --git a/specs/assets/arrow-right.svg b/specs/assets/arrow-right.svg
new file mode 100644
index 0000000..a363497
--- /dev/null
+++ b/specs/assets/arrow-right.svg
@@ -0,0 +1,9 @@
+
+
+
+
diff --git a/specs/assets/twitter.svg b/specs/assets/twitter.svg
index 949c6d8..0f14656 100644
--- a/specs/assets/twitter.svg
+++ b/specs/assets/twitter.svg
@@ -1,5 +1,4 @@
-
diff --git a/specs/cssify.spec.js b/specs/cssify.spec.js
index 4fdaa5c..f58c41b 100644
--- a/specs/cssify.spec.js
+++ b/specs/cssify.spec.js
@@ -13,20 +13,22 @@
'use strict';
-var helper = require('./helper'),
- cssify = require('../lib/cssify');
+var helper = require('./helper');
+var cssify = require('../lib/cssify');
-describe('The "cssification" stream', function () {
+var expect = require('expect.js');
- it('should generate a CSS selector based on the image data', function (done) {
- var image = helper.createImage(),
- prefix = 'imacss',
- stream = cssify(prefix);
+describe('The "cssification" stream', function suite () {
+
+ it('should generate a CSS selector based on the image data', function test (done) {
+ var image = helper.createImage();
+ var prefix = 'imacss';
+ var stream = cssify(prefix);
stream.on('data', function (selector) {
- expect(selector).toBeDefined();
+ expect(selector).not.to.be(undefined);
- expect(selector.substring(1, prefix.length + 1)).toBe(prefix);
+ expect(selector.substring(1, prefix.length + 1)).to.be(prefix);
done();
});
@@ -34,4 +36,21 @@ describe('The "cssification" stream', function () {
stream.write(image);
stream.end();
});
-});
\ No newline at end of file
+
+ it('should generate a custom CSS rule set if a function is passed instead of a prefix string', function test (done) {
+
+ var image = helper.createImage();
+ var generateCss = function generateCss(image) { return image.name; };
+ var stream = cssify(generateCss);
+
+ stream.on('data', function(ruleset) {
+ expect(ruleset).not.to.be(undefined);
+ expect(ruleset).to.be(image.name + '\n');
+
+ done();
+ });
+
+ stream.write(image);
+ stream.end();
+ });
+});
diff --git a/specs/helper.js b/specs/helper.js
index e7f0822..168661c 100644
--- a/specs/helper.js
+++ b/specs/helper.js
@@ -13,9 +13,9 @@
'use strict';
-var fs = require('fs'),
- path = require('path'),
- gutil = require('gulp-util');
+var fs = require('fs');
+var path = require('path');
+var gutil = require('gulp-util');
/**
* Creates a vinyl based file description.
@@ -41,8 +41,8 @@ exports.createImageFile = function createImageFile () {
*
*/
exports.createImage = function createImage () {
- var file = this.createImageFile(),
- image = {};
+ var file = this.createImageFile();
+ var image = {};
image.name = path.basename(file.path);
image.contents = file.contents;
diff --git a/specs/mimeify.spec.js b/specs/mimeify.spec.js
index b5a6dec..8dd13ce 100644
--- a/specs/mimeify.spec.js
+++ b/specs/mimeify.spec.js
@@ -13,18 +13,20 @@
'use strict';
-var helper = require('./helper'),
- mimeify = require('../lib/mimeify');
+var helper = require('./helper');
+var mimeify = require('../lib/mimeify');
-describe('The "mimeification" stream', function () {
+var expect = require('expect.js');
- it('should determine the MIME type of the image', function (done) {
- var image = helper.createImage(),
- stream = mimeify();
+describe('The "mimeification" stream', function suite () {
+
+ it('should determine the MIME type of the image', function test (done) {
+ var image = helper.createImage();
+ var stream = mimeify();
stream.on('data', function (image) {
- expect(image.mime).toBeDefined();
- expect(image.mime).toBe('image/svg+xml');
+ expect(image.mime).not.to.be(undefined);
+ expect(image.mime).to.be('image/svg+xml');
done();
});
@@ -32,4 +34,4 @@ describe('The "mimeification" stream', function () {
stream.write(image);
stream.end();
});
-});
\ No newline at end of file
+});
diff --git a/specs/plugin.spec.js b/specs/plugin.spec.js
index 7ddf65b..885fc8c 100644
--- a/specs/plugin.spec.js
+++ b/specs/plugin.spec.js
@@ -13,23 +13,24 @@
'use strict';
-var streams = require('stream'),
- helper = require('./helper'),
- imacss = require('../');
+var streams = require('stream');
+var helper = require('./helper');
+var imacss = require('../');
-describe('The imacss', function () {
+var expect = require('expect.js');
+
+describe('The imacss', function suite () {
var selector = '.imacss';
- it('"transform" method should be able to handle globs', function (done) {
+ it('"transform" method should be able to handle globs', function test (done) {
var stream = new streams.Writable();
- imacss.transform('./specs/**/*.svg')
- .pipe(stream);
+ imacss.transform('./specs/**/*.svg').pipe(stream);
- stream._write = function (css, enc, next) {
+ stream._write = function (css) {
css = css.toString('utf-8');
- expect(css.substring(0, selector.length)).toBe(selector);
+ expect(css.substring(0, selector.length)).to.be(selector);
done();
};
@@ -38,15 +39,14 @@ describe('The imacss', function () {
it('"transform" method should be able to handle a Vinyl file object', function (done) {
var stream = new streams.Writable();
- imacss.transform(helper.createImageFile())
- .pipe(stream);
+ imacss.transform(helper.createImageFile()).pipe(stream);
- stream._write = function (css, enc, next) {
+ stream._write = function (css) {
css = css.toString('utf-8');
- expect(css.substring(0, selector.length)).toBe(selector);
+ expect(css.substring(0, selector.length)).to.be(selector);
done();
};
});
-});
\ No newline at end of file
+});
diff --git a/specs/purify.spec.js b/specs/purify.spec.js
index 3ba7c88..4042083 100644
--- a/specs/purify.spec.js
+++ b/specs/purify.spec.js
@@ -13,19 +13,21 @@
'use strict';
-var helper = require('./helper'),
- purify = require('../lib/purify');
+var helper = require('./helper');
+var purify = require('../lib/purify');
-describe('The "purification" stream', function () {
+var expect = require('expect.js');
- it('should transform a vinyl file to an internal data structure', function (done) {
- var imageFile = helper.createImageFile(),
- stream = purify();
+describe('The "purification" stream', function suite () {
+
+ it('should transform a vinyl file to an internal data structure', function test (done) {
+ var imageFile = helper.createImageFile();
+ var stream = purify();
stream.on('data', function (image) {
- expect(image.name).toBeDefined();
- expect(image.contents).toBeDefined();
- expect(image.base64).toBeDefined();
+ expect(image.name).not.to.be(undefined);
+ expect(image.contents).not.to.be(undefined);
+ expect(image.base64).not.to.be(undefined);
done();
});
@@ -33,4 +35,4 @@ describe('The "purification" stream', function () {
stream.write(imageFile);
stream.end();
});
-});
\ No newline at end of file
+});
diff --git a/specs/slugify.spec.js b/specs/slugify.spec.js
index 853a873..b678bc0 100644
--- a/specs/slugify.spec.js
+++ b/specs/slugify.spec.js
@@ -13,17 +13,19 @@
'use strict';
-var helper = require('./helper'),
- slugify = require('../lib/slugify');
+var helper = require('./helper');
+var slugify = require('../lib/slugify');
-describe('The "slugification" stream', function () {
+var expect = require('expect.js');
- it('should create a slug', function (done) {
- var image = helper.createImage(),
- stream = slugify();
+describe('The "slugification" stream', function suite () {
+
+ it('should create a slug', function test (done) {
+ var image = helper.createImage();
+ var stream = slugify();
stream.on('data', function (image) {
- expect(image.slug).toBeDefined();
+ expect(image.slug).not.to.be(undefined);
done();
});
@@ -31,4 +33,4 @@ describe('The "slugification" stream', function () {
stream.write(image);
stream.end();
});
-});
\ No newline at end of file
+});
diff --git a/specs/urify.spec.js b/specs/urify.spec.js
index 89ae571..11a17fa 100644
--- a/specs/urify.spec.js
+++ b/specs/urify.spec.js
@@ -13,17 +13,19 @@
'use strict';
-var helper = require('./helper'),
- urify = require('../lib/urify');
+var helper = require('./helper');
+var urify = require('../lib/urify');
-describe('The "urification" stream', function () {
+var expect = require('expect.js');
- it('should create a data-uri', function (done) {
- var image = helper.createImage(),
- stream = urify();
+describe('The "urification" stream', function suite () {
+
+ it('should create a data-uri', function test (done) {
+ var image = helper.createImage();
+ var stream = urify();
stream.on('data', function (image) {
- expect(image.datauri).toBeDefined();
+ expect(image.datauri).not.to.be(undefined);
done();
});
@@ -31,4 +33,4 @@ describe('The "urification" stream', function () {
stream.write(image);
stream.end();
});
-});
\ No newline at end of file
+});