From 599d05bc5f46203e557fba26312d166cef3fc12b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Fri, 2 May 2014 13:06:58 +0200
Subject: [PATCH 01/17] Update README.md
Fixed console statement.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 670da97..1c03623 100644
--- a/README.md
+++ b/README.md
@@ -96,7 +96,7 @@ var imacss = require('imacss');
imacss
.transform('/path/to/your/images/*.png')
.on('error', function (err) {
- error('Transforming images failed: ' + err);
+ console.error('Transforming images failed: ' + err);
})
.pipe(process.stdout);
```
From 69b226976641ba96976663ca06c94d84fcfb2bce Mon Sep 17 00:00:00 2001
From: Ash
Date: Wed, 14 May 2014 17:06:42 +0100
Subject: [PATCH 02/17] Support the passing of a function to generate the
entire CSS rule set
---
README.md | 19 +++++++++++++++++++
index.js | 8 ++++----
lib/cssify.js | 18 ++++++++++++------
specs/cssify.spec.js | 18 ++++++++++++++++++
4 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 1c03623..ca9d097 100644
--- a/README.md
+++ b/README.md
@@ -86,6 +86,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
@@ -101,6 +105,21 @@ imacss
.pipe(process.stdout);
```
+```javascript
+var imacss = require('imacss');
+
+function generateCss(image) {
+ return '.image-' + image.slug + ' { ' + 'background-image:' + 'url(\'' + image.datauri + '\');' }';
+}
+
+imacss
+ .transform('/path/to/your/images/*.png', generateCss)
+ .on('error', function (err) {
+ console.error('Transforming images failed: ' + err);
+ })
+ .pipe(process.stdout);
+```
+
## Changelog
diff --git a/index.js b/index.js
index 6632162..39736e4 100644
--- a/index.js
+++ b/index.js
@@ -21,15 +21,15 @@ var domain = require('domain'),
* 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;
- clazz = clazz || pkg.name;
+ css = css || pkg.name;
execution.on('error', function (err) {
transformation.emit('error', err);
@@ -42,7 +42,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..7977f94 100644
--- a/lib/cssify.js
+++ b/lib/cssify.js
@@ -21,13 +21,13 @@ var stream = require('stream'),
* 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 +48,17 @@ Cssify.prototype._transform = function _transform (image, enc, cb) {
'background-image': 'url(\'' + image.datauri + '\')'
};
- this.push(Utilities.getCSSSelector(this.$$class, image.slug, selector) + '\n');
+ if(typeof this.css === 'string') {
+ this.push(Utilities.getCSSSelector(this.css, image.slug, selector) + '\n');
+ }
+
+ if(this.css instanceof Function) {
+ this.push(this.css(image) + '\n');
+ }
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/specs/cssify.spec.js b/specs/cssify.spec.js
index 4fdaa5c..0b986a0 100644
--- a/specs/cssify.spec.js
+++ b/specs/cssify.spec.js
@@ -34,4 +34,22 @@ describe('The "cssification" stream', function () {
stream.write(image);
stream.end();
});
+
+ it('should generate a custom CSS rule set if a function is passed instead of a prefix string', function(done) {
+
+ var image = helper.createImage(),
+ generateCss = function generateCss(image) { return image.name; },
+ stream = cssify(generateCss);
+
+ stream.on('data', function(ruleset) {
+ expect(ruleset).toBeDefined();
+ expect(ruleset).toBe(image.name + '\n');
+ done();
+ });
+
+ stream.write(image);
+ stream.end();
+
+ });
+
});
\ No newline at end of file
From f6aa8623c54eea9bb65c856c46832eeffdff15d0 Mon Sep 17 00:00:00 2001
From: Ash
Date: Wed, 14 May 2014 17:10:08 +0100
Subject: [PATCH 03/17] Elaborate on readme example
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index ca9d097..493f7a4 100644
--- a/README.md
+++ b/README.md
@@ -105,6 +105,8 @@ imacss
.pipe(process.stdout);
```
+#### Passing a function to customise the resulting CSS rule set
+
```javascript
var imacss = require('imacss');
From d9b860b9c6da4b0df8d28e02d63a3565f4b8933d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Wed, 13 Aug 2014 22:51:44 +0200
Subject: [PATCH 04/17] Updated code style and dependencies.
---
.gitignore | 2 ++
HISTORY.md | 23 +++++++++++++++++++++++
README.md | 25 +------------------------
gulpfile.js | 8 ++++----
index.js | 11 ++++++-----
lib/cssify.js | 21 ++++++++++++---------
lib/index.js | 15 +++++++--------
lib/mimeify.js | 6 +++---
lib/purify.js | 7 +++----
lib/slugify.js | 8 ++++----
lib/urify.js | 7 ++++---
lib/utilities/css.js | 4 ++--
lib/utilities/index.js | 10 +++++-----
lib/utilities/mime.js | 26 +++++++++++++-------------
package.json | 14 +++++++-------
specs/cssify.spec.js | 32 +++++++++++++++-----------------
specs/helper.js | 10 +++++-----
specs/mimeify.spec.js | 8 ++++----
specs/plugin.spec.js | 6 +++---
specs/purify.spec.js | 8 ++++----
specs/slugify.spec.js | 8 ++++----
specs/urify.spec.js | 8 ++++----
22 files changed, 135 insertions(+), 132 deletions(-)
create mode 100644 HISTORY.md
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/HISTORY.md b/HISTORY.md
new file mode 100644
index 0000000..5e6e910
--- /dev/null
+++ b/HISTORY.md
@@ -0,0 +1,23 @@
+# UNRELEASED
+
+ * 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/README.md b/README.md
index 493f7a4..93dd439 100644
--- a/README.md
+++ b/README.md
@@ -105,7 +105,7 @@ imacss
.pipe(process.stdout);
```
-#### Passing a function to customise the resulting CSS rule set
+#### Passing a function to customize the resulting CSS rule set
```javascript
var imacss = require('imacss');
@@ -122,29 +122,6 @@ imacss
.pipe(process.stdout);
```
-
-## 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.
-
-### Version 0.1.0 (20140211)
-
-- Initial Release. Implemented the core functionality (CLI and API).
-
## Author
Copyright 2014, [André König](http://iam.andrekoenig.info) (andre.koenig@posteo.de)
diff --git a/gulpfile.js b/gulpfile.js
index 0a7ded6..3775dae 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -13,10 +13,10 @@
'use strict';
-var gulp = require('gulp'),
- jshint = require('gulp-jshint'),
- jasmine = require('gulp-jasmine'),
- paths = {};
+var gulp = require('gulp');
+var jshint = require('gulp-jshint');
+var jasmine = require('gulp-jasmine');
+var paths = {};
paths.sources = ['./lib/**/*.js', './specs/**/*.js', 'gulpfile.js', 'index.js'];
paths.specs = ['./specs/**/*.spec.js'];
diff --git a/index.js b/index.js
index 39736e4..e70a1ba 100644
--- a/index.js
+++ b/index.js
@@ -13,9 +13,10 @@
'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.
@@ -26,8 +27,8 @@ var domain = require('domain'),
*/
exports.transform = function transform (glob, css) {
- var execution = domain.create(),
- transformation;
+ var execution = domain.create();
+ var transformation;
css = css || pkg.name;
diff --git a/lib/cssify.js b/lib/cssify.js
index 7977f94..61e1c6c 100644
--- a/lib/cssify.js
+++ b/lib/cssify.js
@@ -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 will transform the internal image
@@ -48,12 +49,14 @@ Cssify.prototype._transform = function _transform (image, enc, cb) {
'background-image': 'url(\'' + image.datauri + '\')'
};
- if(typeof this.css === 'string') {
- this.push(Utilities.getCSSSelector(this.css, image.slug, selector) + '\n');
- }
-
- if(this.css instanceof Function) {
- this.push(this.css(image) + '\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();
diff --git a/lib/index.js b/lib/index.js
index 200d9d8..813ff15 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -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..c08ccbb 100644
--- a/lib/mimeify.js
+++ b/lib/mimeify.js
@@ -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..c699182 100644
--- a/lib/purify.js
+++ b/lib/purify.js
@@ -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..0be2a75 100644
--- a/lib/slugify.js
+++ b/lib/slugify.js
@@ -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..031f2a7 100644
--- a/lib/urify.js
+++ b/lib/urify.js
@@ -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.
diff --git a/lib/utilities/css.js b/lib/utilities/css.js
index 879e5a7..95fb97e 100644
--- a/lib/utilities/css.js
+++ b/lib/utilities/css.js
@@ -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..edaab0d 100644
--- a/lib/utilities/index.js
+++ b/lib/utilities/index.js
@@ -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..2d65601 100644
--- a/lib/utilities/mime.js
+++ b/lib/utilities/mime.js
@@ -13,11 +13,11 @@
'use strict';
-var fs = require('fs'),
- filetypes = [
- {mime: 'image/jpeg', magicnumber: 'FFD8', extensions: ['jpg', 'jpeg']},
- {mime: 'image/png', magicnumber: '89504E470D0A1A0A', extensions: ['png']}
- ];
+var fs = require('fs');
+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.
@@ -27,11 +27,11 @@ var fs = require('fs'),
*
*/
exports.detect = function detect (image, callback) {
- var buffer = image.toString('hex').toUpperCase(),
- i = filetypes.length - 1,
- filetype,
- magic,
- mime;
+ 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 +39,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');
diff --git a/package.json b/package.json
index c4d9202..287f954 100644
--- a/package.json
+++ b/package.json
@@ -33,14 +33,14 @@
},
"homepage": "https://github.com/akoenig/imacss",
"dependencies": {
- "vinyl-fs": "0.0.2",
- "slug": "~0.4.0",
- "through2": "~0.4.1"
+ "vinyl-fs": "0.3.6",
+ "slug": "~0.5.0",
+ "through2": "~1.1.1"
},
"devDependencies": {
- "gulp": "~3.5.2",
- "gulp-jshint": "~1.4.0",
- "gulp-jasmine": "~0.1.3",
- "gulp-util": "~2.2.14"
+ "gulp": "~3.8.7",
+ "gulp-jshint": "~1.8.4",
+ "gulp-jasmine": "~0.3.0",
+ "gulp-util": "~3.0.0"
}
}
diff --git a/specs/cssify.spec.js b/specs/cssify.spec.js
index 0b986a0..1814a71 100644
--- a/specs/cssify.spec.js
+++ b/specs/cssify.spec.js
@@ -13,15 +13,15 @@
'use strict';
-var helper = require('./helper'),
- cssify = require('../lib/cssify');
+var helper = require('./helper');
+var cssify = require('../lib/cssify');
describe('The "cssification" stream', function () {
it('should generate a CSS selector based on the image data', function (done) {
- var image = helper.createImage(),
- prefix = 'imacss',
- stream = cssify(prefix);
+ var image = helper.createImage();
+ var prefix = 'imacss';
+ var stream = cssify(prefix);
stream.on('data', function (selector) {
expect(selector).toBeDefined();
@@ -37,19 +37,17 @@ describe('The "cssification" stream', function () {
it('should generate a custom CSS rule set if a function is passed instead of a prefix string', function(done) {
- var image = helper.createImage(),
- generateCss = function generateCss(image) { return image.name; },
- stream = cssify(generateCss);
+ var image = helper.createImage();
+ var generateCss = function generateCss(image) { return image.name; };
+ var stream = cssify(generateCss);
- stream.on('data', function(ruleset) {
- expect(ruleset).toBeDefined();
- expect(ruleset).toBe(image.name + '\n');
- done();
- });
+ stream.on('data', function(ruleset) {
+ expect(ruleset).toBeDefined();
+ expect(ruleset).toBe(image.name + '\n');
+ done();
+ });
- stream.write(image);
- stream.end();
-
+ stream.write(image);
+ stream.end();
});
-
});
\ No newline at end of file
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..c920392 100644
--- a/specs/mimeify.spec.js
+++ b/specs/mimeify.spec.js
@@ -13,14 +13,14 @@
'use strict';
-var helper = require('./helper'),
- mimeify = require('../lib/mimeify');
+var helper = require('./helper');
+var mimeify = require('../lib/mimeify');
describe('The "mimeification" stream', function () {
it('should determine the MIME type of the image', function (done) {
- var image = helper.createImage(),
- stream = mimeify();
+ var image = helper.createImage();
+ var stream = mimeify();
stream.on('data', function (image) {
expect(image.mime).toBeDefined();
diff --git a/specs/plugin.spec.js b/specs/plugin.spec.js
index 7ddf65b..2e424e0 100644
--- a/specs/plugin.spec.js
+++ b/specs/plugin.spec.js
@@ -13,9 +13,9 @@
'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 selector = '.imacss';
diff --git a/specs/purify.spec.js b/specs/purify.spec.js
index 3ba7c88..37f07b6 100644
--- a/specs/purify.spec.js
+++ b/specs/purify.spec.js
@@ -13,14 +13,14 @@
'use strict';
-var helper = require('./helper'),
- purify = require('../lib/purify');
+var helper = require('./helper');
+var purify = require('../lib/purify');
describe('The "purification" stream', function () {
it('should transform a vinyl file to an internal data structure', function (done) {
- var imageFile = helper.createImageFile(),
- stream = purify();
+ var imageFile = helper.createImageFile();
+ var stream = purify();
stream.on('data', function (image) {
expect(image.name).toBeDefined();
diff --git a/specs/slugify.spec.js b/specs/slugify.spec.js
index 853a873..6e218d8 100644
--- a/specs/slugify.spec.js
+++ b/specs/slugify.spec.js
@@ -13,14 +13,14 @@
'use strict';
-var helper = require('./helper'),
- slugify = require('../lib/slugify');
+var helper = require('./helper');
+var slugify = require('../lib/slugify');
describe('The "slugification" stream', function () {
it('should create a slug', function (done) {
- var image = helper.createImage(),
- stream = slugify();
+ var image = helper.createImage();
+ var stream = slugify();
stream.on('data', function (image) {
expect(image.slug).toBeDefined();
diff --git a/specs/urify.spec.js b/specs/urify.spec.js
index 89ae571..6ba5470 100644
--- a/specs/urify.spec.js
+++ b/specs/urify.spec.js
@@ -13,14 +13,14 @@
'use strict';
-var helper = require('./helper'),
- urify = require('../lib/urify');
+var helper = require('./helper');
+var urify = require('../lib/urify');
describe('The "urification" stream', function () {
it('should create a data-uri', function (done) {
- var image = helper.createImage(),
- stream = urify();
+ var image = helper.createImage();
+ var stream = urify();
stream.on('data', function (image) {
expect(image.datauri).toBeDefined();
From 286077c2e7b20a853a8d11bc41608aaeea5ae363 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Wed, 13 Aug 2014 22:52:26 +0200
Subject: [PATCH 05/17] 0.3.0
---
HISTORY.md | 2 +-
package.json | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/HISTORY.md b/HISTORY.md
index 5e6e910..3eb3922 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,4 +1,4 @@
-# UNRELEASED
+# 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)).
diff --git a/package.json b/package.json
index 287f954..4b611e0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "imacss",
- "version": "0.2.2",
+ "version": "0.3.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",
@@ -43,4 +43,4 @@
"gulp-jasmine": "~0.3.0",
"gulp-util": "~3.0.0"
}
-}
+}
\ No newline at end of file
From 95855306e60a88717ce54786296ad172bfe4835d Mon Sep 17 00:00:00 2001
From: Iacami
Date: Mon, 18 Aug 2014 10:30:02 -0300
Subject: [PATCH 06/17] removed extra quote
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 93dd439..7b64802 100644
--- a/README.md
+++ b/README.md
@@ -111,7 +111,7 @@ imacss
var imacss = require('imacss');
function generateCss(image) {
- return '.image-' + image.slug + ' { ' + 'background-image:' + 'url(\'' + image.datauri + '\');' }';
+ return '.image-' + image.slug + ' { ' + 'background-image:' + 'url(\'' + image.datauri + '\'); }';
}
imacss
From fc8be96413edd52a6e6160fcc900696adfae6ca4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 12:15:23 +0200
Subject: [PATCH 07/17] doc: readme
---
README.md | 4 ++--
gulpfile.js | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 7b64802..8757e25 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ var imacss = require('imacss');
imacss
.transform('/path/to/your/images/*.png')
- .on('error', function (err) {
+ .on('error', function onError (err) {
console.error('Transforming images failed: ' + err);
})
.pipe(process.stdout);
@@ -124,4 +124,4 @@ imacss
## 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/gulpfile.js b/gulpfile.js
index 3775dae..590ee56 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014 André König
+ * Copyright(c) 2014-2015 André König
* MIT Licensed
*
*/
@@ -32,4 +32,4 @@ gulp.task('test', function () {
.pipe(jasmine());
});
-gulp.task('default', ['lint', 'test']);
\ No newline at end of file
+gulp.task('default', ['lint', 'test']);
From 34639f4f0ca9487e57114cd4b76316b8f3545fd7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 18:07:20 +0200
Subject: [PATCH 08/17] deps: upgrade
---
gulpfile.js | 2 +-
package.json | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/gulpfile.js b/gulpfile.js
index 590ee56..bacf925 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -23,7 +23,7 @@ paths.specs = ['./specs/**/*.spec.js'];
gulp.task('lint', function () {
gulp.src(paths.sources)
- .pipe(jshint('./.jshintrc'))
+ .pipe(jshint())
.pipe(jshint.reporter('default'));
});
diff --git a/package.json b/package.json
index 4b611e0..8f0872f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "imacss",
- "version": "0.3.0",
+ "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,7 +8,6 @@
},
"license": "MIT",
"main": "index.js",
- "preferGlobal": true,
"scripts": {
"test": "gulp"
},
@@ -33,14 +32,15 @@
},
"homepage": "https://github.com/akoenig/imacss",
"dependencies": {
- "vinyl-fs": "0.3.6",
- "slug": "~0.5.0",
- "through2": "~1.1.1"
+ "slug": "^0.9.1",
+ "through2": "^2.0.0",
+ "vinyl-fs": "^1.0.0"
},
"devDependencies": {
"gulp": "~3.8.7",
- "gulp-jshint": "~1.8.4",
"gulp-jasmine": "~0.3.0",
- "gulp-util": "~3.0.0"
+ "gulp-jshint": "~1.8.4",
+ "gulp-util": "~3.0.0",
+ "typescript": "^1.5.0-beta"
}
-}
\ No newline at end of file
+}
From c87cef426ea6238227d893667cf6f7d3b054e95d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 18:40:09 +0200
Subject: [PATCH 09/17] feature: embedding SVG images as raw text strings
instead of base64
---
gulpfile.js | 6 ++---
index.js | 2 +-
lib/cssify.js | 2 +-
lib/index.js | 2 +-
lib/mimeify.js | 2 +-
lib/purify.js | 2 +-
lib/slugify.js | 2 +-
lib/urify.js | 4 ++--
lib/utilities/css.js | 2 +-
lib/utilities/index.js | 2 +-
lib/utilities/mime.js | 6 ++---
lib/utilities/uri.js | 22 +++++++++++++-----
specs/assets/arrow-right.svg | 9 ++++++++
specs/assets/twitter.svg | 43 ------------------------------------
14 files changed, 41 insertions(+), 65 deletions(-)
create mode 100644 specs/assets/arrow-right.svg
diff --git a/gulpfile.js b/gulpfile.js
index bacf925..1cce966 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,7 +1,7 @@
/*
* imacss
*
- * Copyright(c) 2014-2015 André König
+ * Copyright(c) 2014 - 2015 André König
* MIT Licensed
*
*/
@@ -22,13 +22,13 @@ paths.sources = ['./lib/**/*.js', './specs/**/*.js', 'gulpfile.js', 'index.js'];
paths.specs = ['./specs/**/*.spec.js'];
gulp.task('lint', function () {
- gulp.src(paths.sources)
+ return gulp.src(paths.sources)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('test', function () {
- gulp.src(paths.specs)
+ return gulp.src(paths.specs)
.pipe(jasmine());
});
diff --git a/index.js b/index.js
index e70a1ba..d0367c1 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
*
*/
diff --git a/lib/cssify.js b/lib/cssify.js
index 61e1c6c..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
*
*/
diff --git a/lib/index.js b/lib/index.js
index 813ff15..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
*
*/
diff --git a/lib/mimeify.js b/lib/mimeify.js
index c08ccbb..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
*
*/
diff --git a/lib/purify.js b/lib/purify.js
index c699182..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
*
*/
diff --git a/lib/slugify.js b/lib/slugify.js
index 0be2a75..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
*
*/
diff --git a/lib/urify.js b/lib/urify.js
index 031f2a7..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
*
*/
@@ -41,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 95fb97e..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
*
*/
diff --git a/lib/utilities/index.js b/lib/utilities/index.js
index edaab0d..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
*
*/
diff --git a/lib/utilities/mime.js b/lib/utilities/mime.js
index 2d65601..b3571e6 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
*
*/
@@ -26,7 +26,7 @@ var filetypes = [
* @param {function} callback -> err, mime{string}
*
*/
-exports.detect = function detect (image, callback) {
+module.exports.detect = function detect (image, callback) {
var buffer = image.toString('hex').toUpperCase();
var i = filetypes.length - 1;
var filetype;
@@ -81,4 +81,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/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 @@
-
From d90808a17f9e2eb684bab448138d242b832abb80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 18:48:51 +0200
Subject: [PATCH 10/17] breaking change: the CLI does not provide the
possibility for piping into a file. Just use `imacss *.svg > images.css`
---
bin/imacss | 32 ++++++++++++--------------------
HISTORY.md => changelog.md | 0
README.md => readme.md | 10 ++++++----
3 files changed, 18 insertions(+), 24 deletions(-)
rename HISTORY.md => changelog.md (100%)
rename README.md => readme.md (88%)
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/HISTORY.md b/changelog.md
similarity index 100%
rename from HISTORY.md
rename to changelog.md
diff --git a/README.md b/readme.md
similarity index 88%
rename from README.md
rename to readme.md
index 8757e25..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.
@@ -124,4 +126,4 @@ imacss
## Author
-Copyright 2014-2015, [André König](http://andrekoenig.info) (andre.koenig@posteo.de)
+Copyright 2014 - 2015, [André König](http://andrekoenig.info) (andre.koenig@posteo.de)
From 214d47eb174aceb2cb4a0392e531d5d072869d6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 19:02:26 +0200
Subject: [PATCH 11/17] travis: Node.js version switch
---
.travis.yml | 2 +-
package.json | 3 +--
specs/cssify.spec.js | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
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/package.json b/package.json
index 8f0872f..bf7e7fd 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,6 @@
"gulp": "~3.8.7",
"gulp-jasmine": "~0.3.0",
"gulp-jshint": "~1.8.4",
- "gulp-util": "~3.0.0",
- "typescript": "^1.5.0-beta"
+ "gulp-util": "~3.0.0"
}
}
diff --git a/specs/cssify.spec.js b/specs/cssify.spec.js
index 1814a71..4bb86f8 100644
--- a/specs/cssify.spec.js
+++ b/specs/cssify.spec.js
@@ -50,4 +50,4 @@ describe('The "cssification" stream', function () {
stream.write(image);
stream.end();
});
-});
\ No newline at end of file
+});
From ea1d1ea02aaee816ffe17416df593fced9f79313 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 19:19:28 +0200
Subject: [PATCH 12/17] refactoring: `mocha` migration.
---
.jshintrc | 23 ++++++++++++++++++++---
gulpfile.js | 35 -----------------------------------
index.js | 2 +-
lib/utilities/mime.js | 1 -
package.json | 11 ++++++-----
specs/cssify.spec.js | 17 ++++++++++-------
specs/mimeify.spec.js | 12 +++++++-----
specs/plugin.spec.js | 22 +++++++++++-----------
specs/purify.spec.js | 14 ++++++++------
specs/slugify.spec.js | 10 ++++++----
specs/urify.spec.js | 10 ++++++----
11 files changed, 75 insertions(+), 82 deletions(-)
delete mode 100644 gulpfile.js
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/gulpfile.js b/gulpfile.js
deleted file mode 100644
index 1cce966..0000000
--- a/gulpfile.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * imacss
- *
- * Copyright(c) 2014 - 2015 André König
- * MIT Licensed
- *
- */
-
-/**
- * @author André König
- *
- */
-
-'use strict';
-
-var gulp = require('gulp');
-var jshint = require('gulp-jshint');
-var jasmine = require('gulp-jasmine');
-var paths = {};
-
-paths.sources = ['./lib/**/*.js', './specs/**/*.js', 'gulpfile.js', 'index.js'];
-paths.specs = ['./specs/**/*.spec.js'];
-
-gulp.task('lint', function () {
- return gulp.src(paths.sources)
- .pipe(jshint())
- .pipe(jshint.reporter('default'));
-});
-
-gulp.task('test', function () {
- return gulp.src(paths.specs)
- .pipe(jasmine());
-});
-
-gulp.task('default', ['lint', 'test']);
diff --git a/index.js b/index.js
index d0367c1..4447574 100644
--- a/index.js
+++ b/index.js
@@ -13,7 +13,7 @@
'use strict';
-var domain = require('domain');
+var domain = require('domain');
var pipeline = require('./lib');
var pkg = require('./package.json');
diff --git a/lib/utilities/mime.js b/lib/utilities/mime.js
index b3571e6..3991e4b 100644
--- a/lib/utilities/mime.js
+++ b/lib/utilities/mime.js
@@ -13,7 +13,6 @@
'use strict';
-var fs = require('fs');
var filetypes = [
{mime: 'image/jpeg', magicnumber: 'FFD8', extensions: ['jpg', 'jpeg']},
{mime: 'image/png', magicnumber: '89504E470D0A1A0A', extensions: ['png']}
diff --git a/package.json b/package.json
index bf7e7fd..0771ad8 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,9 @@
"license": "MIT",
"main": "index.js",
"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"
@@ -37,9 +39,8 @@
"vinyl-fs": "^1.0.0"
},
"devDependencies": {
- "gulp": "~3.8.7",
- "gulp-jasmine": "~0.3.0",
- "gulp-jshint": "~1.8.4",
- "gulp-util": "~3.0.0"
+ "expect.js": "^0.3.1",
+ "jshint": "^2.8.0",
+ "mocha": "^2.2.5"
}
}
diff --git a/specs/cssify.spec.js b/specs/cssify.spec.js
index 4bb86f8..f58c41b 100644
--- a/specs/cssify.spec.js
+++ b/specs/cssify.spec.js
@@ -16,17 +16,19 @@
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) {
+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();
});
@@ -35,15 +37,16 @@ describe('The "cssification" stream', function () {
stream.end();
});
- it('should generate a custom CSS rule set if a function is passed instead of a prefix string', function(done) {
+ 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).toBeDefined();
- expect(ruleset).toBe(image.name + '\n');
+ expect(ruleset).not.to.be(undefined);
+ expect(ruleset).to.be(image.name + '\n');
+
done();
});
diff --git a/specs/mimeify.spec.js b/specs/mimeify.spec.js
index c920392..8dd13ce 100644
--- a/specs/mimeify.spec.js
+++ b/specs/mimeify.spec.js
@@ -16,15 +16,17 @@
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) {
+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 2e424e0..885fc8c 100644
--- a/specs/plugin.spec.js
+++ b/specs/plugin.spec.js
@@ -17,19 +17,20 @@ 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 37f07b6..4042083 100644
--- a/specs/purify.spec.js
+++ b/specs/purify.spec.js
@@ -16,16 +16,18 @@
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) {
+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 6e218d8..b678bc0 100644
--- a/specs/slugify.spec.js
+++ b/specs/slugify.spec.js
@@ -16,14 +16,16 @@
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) {
+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 6ba5470..11a17fa 100644
--- a/specs/urify.spec.js
+++ b/specs/urify.spec.js
@@ -16,14 +16,16 @@
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) {
+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
+});
From 7281bb81c39b6f2d899e8faee5333802b94ccebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 19:33:12 +0200
Subject: [PATCH 13/17] missing dependency
---
package.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 0771ad8..82d45c6 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,7 @@
"devDependencies": {
"expect.js": "^0.3.1",
"jshint": "^2.8.0",
- "mocha": "^2.2.5"
+ "mocha": "^2.2.5",
+ "gulp-util": "^0.3.0"
}
}
From 47f9f3cd8ac65f13d4a8f809d109436079e6545d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Sun, 14 Jun 2015 19:35:17 +0200
Subject: [PATCH 14/17] gulp-util
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 82d45c6..8283779 100644
--- a/package.json
+++ b/package.json
@@ -42,6 +42,6 @@
"expect.js": "^0.3.1",
"jshint": "^2.8.0",
"mocha": "^2.2.5",
- "gulp-util": "^0.3.0"
+ "gulp-util": "^3.0.5"
}
}
From 760fc8df6b3a4f85184f2ab80f794dbd7cfbd79f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Mon, 15 Jun 2015 09:51:27 +0200
Subject: [PATCH 15/17] doc: changelog
---
changelog.md | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/changelog.md b/changelog.md
index 3eb3922..b6c7dfc 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,10 @@
+# UNRELEASED
+
+ * 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)).
From e7625de049386415e20a74b8bfcd55a4c55a878c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Mon, 15 Jun 2015 09:52:44 +0200
Subject: [PATCH 16/17] 1.0.0
---
changelog.md | 2 +-
package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/changelog.md b/changelog.md
index b6c7dfc..87d4ef5 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,4 @@
-# UNRELEASED
+# 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`
diff --git a/package.json b/package.json
index 8283779..01e5034 100644
--- a/package.json
+++ b/package.json
@@ -44,4 +44,4 @@
"mocha": "^2.2.5",
"gulp-util": "^3.0.5"
}
-}
+}
\ No newline at end of file
From 1c0cf44e04b676316ad316347f03c221d7b3a44e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?=
Date: Mon, 15 Jun 2015 10:06:44 +0200
Subject: [PATCH 17/17] doc: year update
---
LICENSE | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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.