Skip to content

Commit

Permalink
add grunt, phantomjs, unify code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Hammerl committed Mar 20, 2014
1 parent 857f6b1 commit 2bc66e3
Show file tree
Hide file tree
Showing 17 changed files with 365 additions and 2,655 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
deps
node_modules/
npm-debug.log
.DS_Store
39 changes: 39 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"indent": 4,
"strict": true,
"globalstrict": true,
"node": true,
"browser": true,
"nonew": true,
"curly": true,
"eqeqeq": true,
"indent": false,
"immed": true,
"newcap": true,
"regexp": true,
"evil": true,
"eqnull": true,
"expr": true,
"trailing": true,
"undef": true,
"unused": true,

"globals": {
"TextEncoder": true,
"TextDecoder": true,
"mimefuncs": true,
"console": true,
"define": true,
"describe": true,
"it": true,
"beforeEach": true,
"afterEach": true,
"window": true,
"mocha": true,
"mochaPhantomJS": true,
"importScripts": true,
"postMessage": true,
"before": true,
"self": true
}
}
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- "0.11"
before_install:
- npm install -g grunt-cli
notifications:
email:
- [email protected]
42 changes: 42 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = function(grunt) {
'use strict';

// Project configuration.
grunt.initConfig({
jshint: {
all: ['*.js', 'src/*.js', 'test/*.js'],
options: {
jshintrc: '.jshintrc'
}
},

connect: {
dev: {
options: {
port: 12345,
base: '.',
keepalive: true
}
}
},

mocha_phantomjs: {
all: {
options: {
reporter: 'spec'
},
src: ['test/index.html']
}
}
});

// Load the plugin(s)
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-phantomjs');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-mocha-test');

// Tasks
grunt.registerTask('dev', ['connect:dev']);
grunt.registerTask('default', ['jshint', 'mocha_phantomjs']);
};
16 changes: 16 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Copyright (c) 2013 Andris Reinman

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 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.
64 changes: 42 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
# mimeparser

Another prototype for parsing mime streams, see [example application here](https://github.com/Kreata/mimeparser-example).
Lib for parsing mime streams.

## Scope

This is supposed to be a "low level" mime parsing module. No magic is performed on the data (eg. no joining HTML parts etc.). All body data is emitted out as ArrayBuffer values, so no need to perform any base64 or quoted printable decoding by yourself.

## Usage
[![Build Status](https://travis-ci.org/whiteout-io/mimeparser.png?branch=master)](https://travis-ci.org/whiteout-io/mimeparser)

### Volo
## Installation

Install with [volo](http://volojs.org/):
### [volo](http://volojs.org/):

volo add Kreata/mimeparser/master
volo add whiteout-io/mimeparser/0.1.0

### AMD
### [Bower](http://bower.io/):

Require [mimeparser.js](mimeparser.js) as `mimeparser`
bower install [email protected]:whiteout-io/mimeparser.git#0.1.0

### Create a parser
### [npm](https://www.npmjs.org/):

Create a parser by invoking `mimeparser()`
npm install https://github.com/whiteout-io/mimeparser/tarball/0.1.0

```javascript
var parser = mimeparser();
```
## Dependencies

## Methods
This module depends on [mimefuncs](https://github.com/whiteout-io/mimefuncs). The dependency will not be fetched automatically, so make sure it is there.

## Usage

### AMD

var MimeParser = require('mimeparser');

### non-AMD

<script src="mimeparser"></script>
// exposes MimeParser the constructor to the global object

### Feed data to the parser

Expand Down Expand Up @@ -83,18 +92,29 @@ This seems like asynchronous but actually it is not. So always define `onheader`

**message/rfc822** is automatically parsed if the mime part does not have a `Content-Disposition: attachment` header, otherwise it will be emitted as a regular attachment (as one long ArrayBuffer value).

## Tests

Download `mimeparser` source and install dependencies
## Hands on

```bash
git clone [email protected]:Kreata/mimeparser.git
cd mailcomposer
volo install
git clone [email protected]:whiteout-io/mimeparser.git
cd mimeparser
npm install && npm test
```

Tests are handled by QUnit. Open [testrunner.html](tests/testrunner.html) to run the tests. There's only a few test currently, just to check for syntax errors but not so much individual features.

## License

**MIT**
Copyright (c) 2013 Andris Reinman

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 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.
22 changes: 22 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "mimeparser",
"main": "src/mimeparser.js",
"version": "0.1.0",
"homepage": "https://github.com/whiteout-io/mimeparser",
"authors": ["Andris Reinman <[email protected]>"],
"description": "Parse a mime tree, no magic included.",
"keywords": ["mime"],
"license": "MIT",
"ignore": [
"node_modules",
"bower_components",
"test",
".gitignore",
".jshintrc",
".travis.yml",
"Gruntfile.js",
"LICENSE",
"package.json",
"README.md"
]
}
37 changes: 30 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
{
"main": "mimeparser",
"volo": {
"baseDir": "deps",
"dependencies": {
"mimefuncs": "github:Kreata/mimefuncs/v0.1.3"
}
}
"name": "mimeparser",
"version": "0.1.0",
"homepage": "https://github.com/whiteout-io/mimeparser",
"description": "Parse a mime tree, no magic included.",
"author": "Andris Reinman <[email protected]>",
"keywords": ["mime"],
"license": "MIT",
"scripts": {
"test": "grunt"
},
"repository": {
"type": "git",
"url": "git://github.com/whiteout-io/mimeparser.git"
},
"main": "src/mimeparser",
"dependencies": {},
"devDependencies": {
"chai": "~1.8.1",
"grunt": "~0.4.1",
"grunt-mocha-phantomjs": "~0.4.0",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-jshint": "~0.8.0",
"mocha": "~1.16.2",
"phantomjs": "~1.9.7-1",
"requirejs": "~2.1.10",
"stringencoding": "https://github.com/whiteout-io/stringencoding/tarball/0.1.0",
"arraybuffer-slice": "0.0.2",
"mimefuncs": "https://github.com/whiteout-io/mimefuncs/tarball/0.1.5"
},
"volo": {}
}
Loading

0 comments on commit 2bc66e3

Please sign in to comment.