diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e717f5e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2125666 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto \ No newline at end of file diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index da23d0d..8ee443d --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,18 @@ -# Logs -logs -*.log +# package managers # +#################### +node_modules/ +npm-debug.log +bower_components/ -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -# Deployed apps should consider commenting this line out: -# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git -node_modules +# generated files # +###################### +coverage/ +.idea/ +.DS_Store +.DS_Store? +._* +.Trashes +Icon? +ehthumbs.db +Thumbs.db +.tmp \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..4991c63 --- /dev/null +++ b/.npmignore @@ -0,0 +1,13 @@ +node_modules/ +npm-debug.log +bower_components/ +coverage/ +.idea/ +.DS_Store +.DS_Store? +._* +.Trashes +Icon? +ehthumbs.db +Thumbs.db +.tmp \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..43dbe81 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,34 @@ +language: node_js + +node_js: + - '0.10' + +before_script: + #- npm install -g codeclimate-test-reporter + +after_script: + #TODO: enable publishing code coverage reports + #- codeclimate < test/coverage/**/lcov.info + +notifications: + # publish build status to IRC channel: #gradient-parser + irc: + channels: + - chat.freenode.net#gradient-parser + on_success: always + on_failure: always + template: + - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}' + - 'Change view : %{compare_url}' + - 'Build details : %{build_url}' + #TODO: enable publishing build status to gitter.im + # publish build status to gitter chat room: https://gitter.im/rafaelcaricio/gradient-parser + #webhooks: + # urls: + # - [REPLACE WITH YOUR WEBHOOK URL; https://webhooks.gitter.im/e/XXXXXXXXXXXXXXXX] + # on_success: always + # on_failure: always + # on_start: false + +env: + #- CODECLIMATE_REPO_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \ No newline at end of file diff --git a/.umd b/.umd new file mode 100644 index 0000000..f46642c --- /dev/null +++ b/.umd @@ -0,0 +1,16 @@ +(function (window, factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { + // AMD + define([], factory); + } else if (typeof exports === 'object') { + // Node.js + module.exports = factory(); + } else { + // Browser + window.gradientParser = factory(); + } +}(this, function factory() { + // public API + return $1; +})); \ No newline at end of file diff --git a/README.md b/README.md index e92d406..13dcbd1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,97 @@ -gradient-parser -=============== +# gradient-parser +[![Build Status][build-image]][build-url] +[![Code GPA][gpa-image]][gpa-url] +[![Test Coverage][coverage-image]][coverage-url] +[![Dependency Status][depstat-image]][depstat-url] +[![Bower Version][bower-image]][bower-url] +[![NPM version][npm-image]][npm-url] +[![IRC Channel][irc-image]][irc-url] +[![Gitter][gitter-image]][gitter-url] +[![GitTip][tip-image]][tip-url] -Parse CSS3 gradient definition and returns AST. +## About + +All about how amazing the gradient-parser micro-library is. + +This repository was scaffolded with [generator-microjs](https://github.com/daniellmb/generator-microjs). + +## Examples + +### JavaScript + +```JavaScript + // TODO +``` + +## Install Choices +- `bower install gradient-parser` +- [download the zip](https://github.com/rafaelcaricio/gradient-parser/archive/master.zip) + +## Tasks + +All tasks can be run by simply running `grunt` or with the `npm test` command, or individually: + + * `grunt lint` will lint source code for syntax errors and anti-patterns. + * `grunt gpa` will analyze source code against complexity thresholds. + * `grunt test` will run the mocha unit tests against the source code. + * `grunt test-min` will run the mocha unit tests against the minified code. + +## License + +(The MIT License) + +Copyright (c) 2014 Rafael CarĂ­cio rafael@caricio.com + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, 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. + + + +[build-url]: https://travis-ci.org/rafaelcaricio/gradient-parser +[build-image]: http://img.shields.io/travis/rafaelcaricio/gradient-parser.png + +[gpa-url]: https://codeclimate.com/github/rafaelcaricio/gradient-parser +[gpa-image]: https://codeclimate.com/github/rafaelcaricio/gradient-parser.png + +[coverage-url]: https://codeclimate.com/github/rafaelcaricio/gradient-parser/code?sort=covered_percent&sort_direction=desc +[coverage-image]: https://codeclimate.com/github/rafaelcaricio/gradient-parser/coverage.png + +[depstat-url]: https://david-dm.org/rafaelcaricio/gradient-parser +[depstat-image]: https://david-dm.org/rafaelcaricio/gradient-parser.png?theme=shields.io + +[issues-url]: https://github.com/rafaelcaricio/gradient-parser/issues +[issues-image]: http://img.shields.io/github/issues/rafaelcaricio/gradient-parser.png + +[bower-url]: http://bower.io/search/?q=gradient-parser +[bower-image]: https://badge.fury.io/bo/gradient-parser.png + +[downloads-url]: https://www.npmjs.org/package/gradient-parser +[downloads-image]: http://img.shields.io/npm/dm/gradient-parser.png + +[npm-url]: https://www.npmjs.org/package/gradient-parser +[npm-image]: https://badge.fury.io/js/gradient-parser.png + +[irc-url]: http://webchat.freenode.net/?channels=gradient-parser +[irc-image]: http://img.shields.io/badge/irc-%23gradient-parser-brightgreen.png + +[gitter-url]: https://gitter.im/rafaelcaricio/gradient-parser +[gitter-image]: http://img.shields.io/badge/gitter-rafaelcaricio/gradient-parser-brightgreen.png + +[tip-url]: https://www.gittip.com/rafaelcaricio +[tip-image]: http://img.shields.io/gittip/rafaelcaricio.png \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..b3b62c6 --- /dev/null +++ b/bower.json @@ -0,0 +1,23 @@ +{ + "name": "gradient-parser", + "version": "0.1.0", + "main": "gradient-parser.js", + "ignore": [ + ".editorconfig", + ".gitattributes", + ".gitignore", + ".jshintrc", + ".npmignore", + ".travis.yml", + ".umd", + "gulpfile.js", + "npm-shrinkwrap.json", + "package.json" + ], + "dependencies": { + + }, + "devDependencies": { + + } +} \ No newline at end of file diff --git a/parser.js b/gradient-parser.js similarity index 82% rename from parser.js rename to gradient-parser.js index bd6cb86..77e8410 100644 --- a/parser.js +++ b/gradient-parser.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -var Parser = (function() { +var GradientParser = module.exports = (function() { var types = { gradients: [ @@ -22,7 +22,9 @@ var Parser = (function() { function Constructor() { } - Constructor.prototype.parse = function(input) { + var def = Constructor.prototype; + + def.parse = function(input) { return null; } @@ -30,7 +32,7 @@ var Parser = (function() { })(); -var p = new Parser('linear-gradient(to right, transparent 10px, #c2c2c2 10px)'); +var p = new GradientParser('linear-gradient(to right, transparent 10px, #c2c2c2 10px)'); var ast = p.parse(); if (ast == [ diff --git a/gruntfile.js b/gruntfile.js new file mode 100644 index 0000000..b8eda72 --- /dev/null +++ b/gruntfile.js @@ -0,0 +1,26 @@ +'use strict'; + +module.exports = function (grunt) { + var config = { + app: '.', + dist: '.' + }; + + grunt.initConfig({ + config: config, + mochaTest: { + test: { + options: { + reporter: 'spec' + }, + src: ['spec/**/*.js'] + } + } + }); + + grunt.loadNpmTasks('grunt-mocha-test'); + + grunt.registerTask('default', [ + 'mochaTest' + ]); +}; diff --git a/package.json b/package.json index 96e0f8e..f006c89 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,46 @@ { "name": "gradient-parser", - "version": "0.0.0", - "description": "Parse gradient definitions and return AST.", - "main": "./parser.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "version": "0.1.0", + "description": "Parse CSS3 gradient definitions and return an AST.", + "author": { + "name": "Rafael Carcicio", + "email": "rafael@caricio.com", + "url": "https://github.com/rafaelcaricio" }, - "repository": { - "type": "git", - "url": "https://github.com/rafaelcaricio/gradient-parser.git" - }, - "keywords": [ - "parser", - "gradient", - "css", - "ast" - ], - "author": "Rafael Caricio ", - "license": "MIT", + "homepage": "https://github.com/rafaelcaricio/gradient-parser", "bugs": { "url": "https://github.com/rafaelcaricio/gradient-parser/issues" }, - "homepage": "https://github.com/rafaelcaricio/gradient-parser" + "licenses": [ + { + "type": "MIT", + "url": "http://rafaelcaricio.mit-license.org" + } + ], + "maintainers": [], + "contributors": [], + "repository": { + "type": "git", + "url": "git://github.com/rafaelcaricio/gradient-parser.git" + }, + "main": "gradient-parser.js", + "scripts": { + "test": "grunt" + }, + "keywords": [ + "library", + "css3", + "parser" + ], + "dependencies": {}, + "devDependencies": { + "grunt": "*", + "grunt-complexity": "*", + "grunt-contrib-uglify": "^0.5.1", + "grunt-mocha-test": "^0.11.0", + "mocha": "*" + }, + "engines": { + "node": ">=0.10.0" + } } diff --git a/spec/gradient-parser.spec.js b/spec/gradient-parser.spec.js new file mode 100644 index 0000000..303ab48 --- /dev/null +++ b/spec/gradient-parser.spec.js @@ -0,0 +1,24 @@ +'use strict'; + +var expect = require('expect.js'); +var GradientParser = require('gradient-parser'); + +describe('gradient-parser.js', function () { + it('should exist', function () { + expect(typeof GradientParser).to.equal('function'); + }); + + describe('when parsing a simple definition', function(){ + var ast; + + beforeEach(function() { + var parser = new GradientParser(); + ast = parser.parse('linar-gradient(to right, transparent 10px, blue)'); + }); + + it('should get the gradient type', function () { + expect(ast[0].type).to.equal('linear-gradient'); + }); + + }); +});