Permalink
Browse files

Remove unnecessary files

  • Loading branch information...
1 parent 718c7e2 commit 21019379d2161a432dc609c63c43e85b52ed894d @jefflembeck jefflembeck committed Dec 12, 2013
View
@@ -1,96 +0,0 @@
-/*global require:true*/
-/*global module:true*/
-(function(){
- "use strict";
-
- var fs = require( 'fs-extra' );
- var path = require( 'path' );
-
- var _ = require( 'lodash' );
-
- var colorsRegx = /\.colors\-([^\.]+)/i;
-
- var isColorWord = function( val ){
- var acceptable = ["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];
- if( acceptable.indexOf( val ) > -1 ){
- return true;
- }
- return false;
- };
- // test if value is a valid hex
- var isHex = function( val ){
- return (/^[0-9a-f]{3}(?:[0-9a-f]{3})?$/i).test( val );
- };
-
- var getColorConfig = function( str ){
- var colors = str.match( colorsRegx ), colorObj = {};
- if( colors ){
- colors = colors[ 1 ].split( "-" );
- colors.forEach( function( color, i ){
- if( isHex( color ) ){
- colorObj[ i ] = "#" + color;
- } else if( isColorWord( color ) ){
- colorObj[ color ] = color;
- }
- });
- return colorObj;
- }
- else {
- return colorObj;
- }
- }; //getColorConfig
-
- var Colorfy = function( filepath, extraColors ){
-
- var colors = getColorConfig( filepath );
- _.extend( colors, extraColors );
-
- this.originalContents = fs.readFileSync( filepath ).toString( 'utf-8' );
- this.originalFilepath = filepath.replace( colorsRegx, "" );
- this.originalFilename = path.basename( this.originalFilepath );
- this.ofnNoExt = this.originalFilename.replace( path.extname( this.originalFilename ), "" );
- this.filepath = filepath;
- this.colors = colors;
- this.colornames = Object.keys(this.colors);
- this.colorFiles = {};
- };
-
- Colorfy.prototype.writeFiles = function( destFolder ){
- destFolder = destFolder || "";
- var filesWritten = [];
-
- if( !fs.existsSync( destFolder ) ){
- fs.mkdirpSync( destFolder );
- }
- fs.writeFileSync( path.join( destFolder, this.originalFilename ), this.originalContents );
-
- for (var filepath in this.colorFiles) {
- if (this.colorFiles.hasOwnProperty(filepath)) {
- fs.writeFileSync( path.join( destFolder, filepath ), this.colorFiles[ filepath ] );
- filesWritten.push( path.join( destFolder, filepath ) );
- }
- }
-
- return filesWritten;
- };
-
- Colorfy.prototype.convert = function(){
- var self = this;
-
- for( var name in self.colors ){
- if( self.colors.hasOwnProperty(name) ){
- var color = self.colors[name];
- var newFilePath = path.join( path.dirname( self.originalFilepath ), self.ofnNoExt + "-" + name + path.extname( self.originalFilepath ) ) ,
- newFilename = path.basename( newFilePath ),
- newFileContents = self.originalContents.replace( /(<svg[^>]+>)/im, '$1<style type="text/css">circle, ellipse, line, path, polygon, polyline, rect, text { fill: ' + color + ' !important; }</style>' );
-
- self.colorFiles[ newFilename ] = newFileContents;
- }
- }
- };
-
-
-
- module.exports = Colorfy;
-}());
-
@@ -1,47 +0,0 @@
-/*global module:true*/
-/*global __dirname:true*/
-/*global require:true*/
-(function( exports ){
- "use strict";
-
- var path = require( 'path' );
- var fs = require( 'fs' );
-
- var Colorfy = require( path.join( __dirname, 'colorfy' ) );
-
- var DirectoryColorfy = function( input, output, opts ){
- if( typeof input !== "string" ){
- throw new Error( "Input required, must be string" );
- }
- if( !fs.lstatSync( input ).isDirectory() ){
- throw new Error( "Input is not a directory" );
- }
- this.input = input;
- this.output = output;
- this.options = opts || {};
- this.colors = this.options.colors || {};
- };
-
- DirectoryColorfy.prototype.convert = function(){
- var self = this;
- var files = fs.readdirSync( self.input );
- var filesWritten = [];
- files = files.filter(function( file ){
- if( path.extname( file ) === ".svg" ){
- return file;
- }
- });
- files.forEach(function(file){
- var c = new Colorfy( path.join( self.input, file ), self.colors );
- c.convert();
- filesWritten.push.apply( filesWritten, c.writeFiles( self.output ) );
- });
-
- return filesWritten;
- };
-
-
- module.exports = DirectoryColorfy;
-
-}(typeof exports === 'object' && exports || this));
-
View
@@ -1,7 +1,7 @@
{
"name": "grunt-grunticon",
"description": "A mystical CSS icon solution",
- "version": "1.0.0-alpha.2",
+ "version": "1.0.0-alpha.3",
"homepage": "https://github.com/filamentgroup/grunticon",
"author": {
"name": "Scott Jehl",
@@ -30,7 +30,6 @@
},
"dependencies": {
"uglify-js": "~2.2.5",
- "fs-extra": "0.6.3",
"xmldom": "0.1.16",
"handlebars": "1.1.2",
"lodash":"2.4.0",
View
@@ -1,173 +0,0 @@
-/*global require:true*/
-(function( exports ){
-
- "use strict";
-
- var fs = require( 'fs' );
- var path = require( 'path' );
- var Colorfy = require( path.join('..', 'lib', 'colorfy'));
- var bearSVG = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="62.905px">\n<path d="M11.068,34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344,0.092-0.666,0.161-1.033,0.161\n\tc-2.342,0-4.248-1.906-4.248-4.248c0-1.47,0.758-2.756,1.883-3.514l12.147-8.45c2.549-1.562,5.534-2.526,8.749-2.641l30.149,0.092\n\tL77.819,4.34c0-0.115,0-0.229,0-0.345C77.819,1.791,79.586,0,81.791,0c2.205,0,3.996,1.791,3.996,3.995\n\tc0,0.345-0.046,0.712-0.138,1.034l2.043,0.275c2.365,0.459,4.156,2.549,4.156,5.052c0,0.161,0,0.298-0.022,0.436l6.544,3.536\n\tc0.941,0.368,1.63,1.309,1.63,2.388c0,0.367-0.068,0.689-0.206,1.01l-1.631,3.697c-0.804,1.309-2.181,2.228-3.788,2.411\n\tl-15.041,1.791L65.787,41.527l7.738,13.363l5.098,2.365c0.803,0.552,1.354,1.493,1.354,2.549c0,1.699-1.378,3.078-3.101,3.078\n\tl-9.805,0.022c-2.525,0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92,0.023l6.682,10.287l4.937,2.25\n\tc0.919,0.551,1.516,1.538,1.516,2.664c0,1.699-1.378,3.076-3.077,3.076l-9.828,0.023c-2.388,0-4.5-1.286-5.649-3.215l-9.208-14.627\n\tl-6.429,6.246l-0.528,4.087l2.158,1.423c0.368,0.184,0.689,0.438,0.965,0.758c1.056,1.332,0.872,3.284-0.459,4.34\n\tc-0.574,0.482-1.286,0.713-1.975,0.689l-4.317,0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275,51.033,0,50,0,48.898\n\tc0-1.676,0.62-3.215,1.676-4.387L11.068,34.558z"/>\n</svg>\n';
- var bearBlueSVG = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="62.905px"><style type="text/css">circle, ellipse, line, path, polygon, polyline, rect, text { fill: blue !important; }</style>\n<path d="M11.068,34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344,0.092-0.666,0.161-1.033,0.161\n\tc-2.342,0-4.248-1.906-4.248-4.248c0-1.47,0.758-2.756,1.883-3.514l12.147-8.45c2.549-1.562,5.534-2.526,8.749-2.641l30.149,0.092\n\tL77.819,4.34c0-0.115,0-0.229,0-0.345C77.819,1.791,79.586,0,81.791,0c2.205,0,3.996,1.791,3.996,3.995\n\tc0,0.345-0.046,0.712-0.138,1.034l2.043,0.275c2.365,0.459,4.156,2.549,4.156,5.052c0,0.161,0,0.298-0.022,0.436l6.544,3.536\n\tc0.941,0.368,1.63,1.309,1.63,2.388c0,0.367-0.068,0.689-0.206,1.01l-1.631,3.697c-0.804,1.309-2.181,2.228-3.788,2.411\n\tl-15.041,1.791L65.787,41.527l7.738,13.363l5.098,2.365c0.803,0.552,1.354,1.493,1.354,2.549c0,1.699-1.378,3.078-3.101,3.078\n\tl-9.805,0.022c-2.525,0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92,0.023l6.682,10.287l4.937,2.25\n\tc0.919,0.551,1.516,1.538,1.516,2.664c0,1.699-1.378,3.076-3.077,3.076l-9.828,0.023c-2.388,0-4.5-1.286-5.649-3.215l-9.208-14.627\n\tl-6.429,6.246l-0.528,4.087l2.158,1.423c0.368,0.184,0.689,0.438,0.965,0.758c1.056,1.332,0.872,3.284-0.459,4.34\n\tc-0.574,0.482-1.286,0.713-1.975,0.689l-4.317,0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275,51.033,0,50,0,48.898\n\tc0-1.676,0.62-3.215,1.676-4.387L11.068,34.558z"/>\n</svg>\n';
- var bearRedSVG = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="62.905px"><style type="text/css">circle, ellipse, line, path, polygon, polyline, rect, text { fill: red !important; }</style>\n<path d="M11.068,34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344,0.092-0.666,0.161-1.033,0.161\n\tc-2.342,0-4.248-1.906-4.248-4.248c0-1.47,0.758-2.756,1.883-3.514l12.147-8.45c2.549-1.562,5.534-2.526,8.749-2.641l30.149,0.092\n\tL77.819,4.34c0-0.115,0-0.229,0-0.345C77.819,1.791,79.586,0,81.791,0c2.205,0,3.996,1.791,3.996,3.995\n\tc0,0.345-0.046,0.712-0.138,1.034l2.043,0.275c2.365,0.459,4.156,2.549,4.156,5.052c0,0.161,0,0.298-0.022,0.436l6.544,3.536\n\tc0.941,0.368,1.63,1.309,1.63,2.388c0,0.367-0.068,0.689-0.206,1.01l-1.631,3.697c-0.804,1.309-2.181,2.228-3.788,2.411\n\tl-15.041,1.791L65.787,41.527l7.738,13.363l5.098,2.365c0.803,0.552,1.354,1.493,1.354,2.549c0,1.699-1.378,3.078-3.101,3.078\n\tl-9.805,0.022c-2.525,0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92,0.023l6.682,10.287l4.937,2.25\n\tc0.919,0.551,1.516,1.538,1.516,2.664c0,1.699-1.378,3.076-3.077,3.076l-9.828,0.023c-2.388,0-4.5-1.286-5.649-3.215l-9.208-14.627\n\tl-6.429,6.246l-0.528,4.087l2.158,1.423c0.368,0.184,0.689,0.438,0.965,0.758c1.056,1.332,0.872,3.284-0.459,4.34\n\tc-0.574,0.482-1.286,0.713-1.975,0.689l-4.317,0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275,51.033,0,50,0,48.898\n\tc0-1.676,0.62-3.215,1.676-4.387L11.068,34.558z"/>\n</svg>\n';
- var bearPrimaryFFA500 = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="62.905px"><style type="text/css">circle, ellipse, line, path, polygon, polyline, rect, text { fill: #ffa500 !important; }</style>\n<path d="M11.068,34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344,0.092-0.666,0.161-1.033,0.161\n\tc-2.342,0-4.248-1.906-4.248-4.248c0-1.47,0.758-2.756,1.883-3.514l12.147-8.45c2.549-1.562,5.534-2.526,8.749-2.641l30.149,0.092\n\tL77.819,4.34c0-0.115,0-0.229,0-0.345C77.819,1.791,79.586,0,81.791,0c2.205,0,3.996,1.791,3.996,3.995\n\tc0,0.345-0.046,0.712-0.138,1.034l2.043,0.275c2.365,0.459,4.156,2.549,4.156,5.052c0,0.161,0,0.298-0.022,0.436l6.544,3.536\n\tc0.941,0.368,1.63,1.309,1.63,2.388c0,0.367-0.068,0.689-0.206,1.01l-1.631,3.697c-0.804,1.309-2.181,2.228-3.788,2.411\n\tl-15.041,1.791L65.787,41.527l7.738,13.363l5.098,2.365c0.803,0.552,1.354,1.493,1.354,2.549c0,1.699-1.378,3.078-3.101,3.078\n\tl-9.805,0.022c-2.525,0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92,0.023l6.682,10.287l4.937,2.25\n\tc0.919,0.551,1.516,1.538,1.516,2.664c0,1.699-1.378,3.076-3.077,3.076l-9.828,0.023c-2.388,0-4.5-1.286-5.649-3.215l-9.208-14.627\n\tl-6.429,6.246l-0.528,4.087l2.158,1.423c0.368,0.184,0.689,0.438,0.965,0.758c1.056,1.332,0.872,3.284-0.459,4.34\n\tc-0.574,0.482-1.286,0.713-1.975,0.689l-4.317,0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275,51.033,0,50,0,48.898\n\tc0-1.676,0.62-3.215,1.676-4.387L11.068,34.558z"/>\n</svg>\n';
-
- var arrayEqual = function( arr1, arr2 ){
- if(!( Array.isArray( arr1 ) && Array.isArray( arr2 ) )){
- return false;
- }
-
- if( arr1.length !== arr2.length ){
- return false;
- }
-
- for( var i = 0, l = arr1.length; i < l; i++ ){
- if( arr1[i] instanceof Array && arr2[i] instanceof Array ){
- if( !arrayEqual( arr1[i], arr2[i] ) ){
- return false;
- }
- } else if( arr1[i] !== arr2[i] ){
- return false;
- }
- }
-
- return true;
- };
-
- exports.constructor = {
- setUp: function( done ) {
- this.c = new Colorfy( "test/files/bear.svg" );
- this.c2 = new Colorfy( "test/files/bear.colors-blue-red.svg" );
- this.c3 = new Colorfy( "test/files/bear.svg", {"orange": "orange", "green": "green" } );
- done();
- },
-
- file: function( test ) {
- test.equal( this.c.filepath, "test/files/bear.svg" );
- test.equal( this.c2.filepath, "test/files/bear.colors-blue-red.svg");
- test.done();
- },
-
- filename: function( test ) {
- test.equal( this.c.originalFilename, "bear.svg" );
- test.equal( this.c2.originalFilename, "bear.svg" );
- test.done();
- },
-
- originalContents: function( test ) {
- test.equal( this.c.originalContents, bearSVG );
- test.done();
- },
-
- originalFilepathNoColor: function( test ) {
- test.equal( this.c.originalFilepath, "test/files/bear.svg" );
- test.done();
- },
-
- originalFilepath: function( test ) {
- test.equal( this.c.originalFilepath, "test/files/bear.svg" );
- test.done();
- },
-
- originalFilename: function( test ) {
- test.equal( this.c.originalFilename, "bear.svg" );
- test.done();
- },
-
- originalFilenameNoExt: function( test ) {
- test.equal( this.c.ofnNoExt, "bear" );
- test.done();
- },
-
- colorsNone: function( test ) {
- test.ok( arrayEqual( this.c.colornames, [] ) );
- test.done();
- },
- colors: function( test ) {
- test.ok( arrayEqual( this.c2.colornames, ['blue', 'red'] ) );
- test.done();
- },
- colorsAsArg: function( test ){
- test.ok( arrayEqual( this.c3.colornames, ['orange', 'green'] ) );
- test.done();
- }
- };
-
- exports.convert = {
- setUp: function( done ) {
- this.c = new Colorfy( "test/files/bear.svg" );
- this.c2 = new Colorfy( "test/files/bear.colors-blue-red.svg" );
- this.c3 = new Colorfy( "test/files/bear.svg", { "orange": "#ffa500", "green": "#00ff00"} );
- this.c4 = new Colorfy( "test/files/bear.colors-primary-blue-red.svg", { "primary": "#ffa500" } );
- this.c5 = new Colorfy( "test/files/bear.colors-secondary.svg", { "primary": "#ffa500" } );
- done();
- },
- colorFilesNoColor: function( test ){
- this.c.convert();
- test.equals( Object.keys( this.c.colorFiles ).length, 0 );
- test.done();
- },
- colorFiles: function( test ){
- this.c2.convert();
- test.equals( Object.keys( this.c2.colorFiles ).length, 2 );
- test.ok( arrayEqual( Object.keys( this.c2.colorFiles ), ['bear-blue.svg', 'bear-red.svg'] ));
- test.done();
- },
- colorFilesContents: function( test ){
- this.c2.convert();
- test.equals( this.c2.colorFiles['bear-blue.svg'], bearBlueSVG );
- test.equals( this.c2.colorFiles['bear-red.svg'], bearRedSVG );
- test.done();
- },
- colorFilesOpts: function( test ){
- this.c3.convert();
- test.equals( Object.keys( this.c3.colorFiles ).length, 2 );
- test.ok( arrayEqual( Object.keys( this.c3.colorFiles ), ['bear-orange.svg', 'bear-green.svg'] ));
- test.done();
- },
- colorFilesOptsDefinition: function( test ){
- this.c4.convert();
- test.equals( Object.keys( this.c4.colorFiles ).length, 3 );
- test.ok( arrayEqual( Object.keys( this.c4.colorFiles ), ['bear-blue.svg', 'bear-red.svg', 'bear-primary.svg'] ));
- test.equals( this.c4.colorFiles['bear-primary.svg'], bearPrimaryFFA500 );
- test.done();
- },
- colorFilesOptsDefinitionNoMatch: function( test ){
- this.c5.convert();
- test.equals( this.c5.colorFiles['bear-secondary.svg'], undefined );
- test.done();
- }
- };
-
- exports.writeFile = {
- setUp: function( done ) {
- this.c = new Colorfy( "test/files/bear.svg" );
- this.c2 = new Colorfy( "test/files/bear.colors-blue-red.svg" );
- done();
- },
- tearDown: function( done ){
- ["bear", "bear-blue", "bear-red"].forEach( function( base ){
- if( fs.existsSync( "test/files/temp/" + base + ".svg" ) ){
- fs.unlinkSync( "test/files/temp/" + base + ".svg" );
- }
- });
- done();
- },
- writeFirstFile: function( test ) {
- this.c.convert();
- this.c.writeFiles( "test/files/temp" );
- test.ok( fs.existsSync( "test/files/temp/bear.svg" ) );
- test.done();
- },
- writeColorFiles: function( test ) {
- this.c2.convert();
- this.c2.writeFiles( "test/files/temp" );
- test.ok( fs.existsSync( "test/files/temp/bear.svg" ) );
- test.ok( fs.existsSync( "test/files/temp/bear-blue.svg" ) );
- test.ok( fs.existsSync( "test/files/temp/bear-red.svg" ) );
- test.done();
- }
- };
-
-
-}(typeof exports === 'object' && exports || this));
-
@@ -1,63 +0,0 @@
-
-/*global require:true*/
-(function( exports ){
- "use strict";
-
- var path = require( 'path' );
- var fs = require( 'fs' );
- var DirectoryColorfy = require( path.join( '..', 'lib', 'directory-colorfy' ) );
-
-
- exports.constructor = {
- setUp: function( done ) {
- this.dc = new DirectoryColorfy( "test/files" , "test/files" );
- this.dc2 = new DirectoryColorfy( "test/files", "test/files/temp",
- { colors: {
- "blue": "blue"
- }
- });
- done();
- },
- tearDown: function( done ){
- done();
- },
- emptyConstructor: function( test ){
- test.equal( Object.keys( this.dc.options ).length, 0 , "Empty options hash on constructor" );
- test.done();
- },
- constructor: function( test ){
- test.equal( this.dc2.input, "test/files", "Input filled in on constuctor" );
- test.equal( this.dc2.output, "test/files/temp", "Output filled in on constuctor" );
- test.equal( Object.keys( this.dc2.options.colors ).length, 1, "Colors filled" );
- test.equal( Object.keys(this.dc2.options.colors)[0], "blue", "Colors filled" );
- test.done();
- }
- };
- exports.convert = {
- setUp: function( done ) {
- this.dc = new DirectoryColorfy( path.resolve( path.join( "test", "files", "directory-colorfy" )), path.resolve( path.join( "test", "files", "temp" )),
- { colors: {
- "green": "green",
- "orange": "orange"
- }
- });
- done();
- },
- tearDown: function( done ){
- ["bear", "bear-green", "bear-orange"].forEach( function( base ){
- if( fs.existsSync( "test/files/temp/" + base + ".svg" ) ){
- fs.unlinkSync( "test/files/temp/" + base + ".svg" );
- }
- });
- done();
- },
- convert: function( test ){
- this.dc.convert();
- test.ok( fs.existsSync( "test/files/temp/bear-green.svg" ) , "Green bear is there" );
- test.ok( fs.existsSync( "test/files/temp/bear-orange.svg" ) , "Orange bear is there" );
- test.done();
- }
- };
-
-}(typeof exports === 'object' && exports || this));
-
Oops, something went wrong.

0 comments on commit 2101937

Please sign in to comment.