Add some configuration and organize project
This commit is contained in:
parent
810666de6a
commit
755322fe43
12 changed files with 307 additions and 48 deletions
13
.editorconfig
Normal file
13
.editorconfig
Normal file
|
@ -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
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
* text=auto
|
41
.gitignore
vendored
Normal file → Executable file
41
.gitignore
vendored
Normal file → Executable file
|
@ -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
|
13
.npmignore
Normal file
13
.npmignore
Normal file
|
@ -0,0 +1,13 @@
|
|||
node_modules/
|
||||
npm-debug.log
|
||||
bower_components/
|
||||
coverage/
|
||||
.idea/
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Trashes
|
||||
Icon?
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
.tmp
|
34
.travis.yml
Normal file
34
.travis.yml
Normal file
|
@ -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
|
16
.umd
Normal file
16
.umd
Normal file
|
@ -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;
|
||||
}));
|
99
README.md
99
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
|
23
bower.json
Normal file
23
bower.json
Normal file
|
@ -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": {
|
||||
|
||||
}
|
||||
}
|
|
@ -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 == [
|
26
gruntfile.js
Normal file
26
gruntfile.js
Normal file
|
@ -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'
|
||||
]);
|
||||
};
|
57
package.json
57
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 <rafael@caricio.com>",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
|
24
spec/gradient-parser.spec.js
Normal file
24
spec/gradient-parser.spec.js
Normal file
|
@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue