Skip to content

Commit 5eed22f

Browse files
author
Tim De Pauw
committed
Initial commit
0 parents  commit 5eed22f

118 files changed

Lines changed: 6223 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = crlf
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Tt]humbs.db
2+
.DS_Store
3+
npm-debug.log
4+
5+
/node_modules/
6+
/lib/
7+
/coverage/

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
matrix:
3+
include:
4+
- node_js: '0.12'
5+
- node_js: iojs
6+
- node_js: 4
7+
- node_js: 5
8+
env: COVERALLS=1
9+
after_success:
10+
- '[[ "$COVERALLS" ]] && gulp coveralls'

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2016 Zentrick nv
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# iab-vast-parser
2+
3+
[![npm](https://img.shields.io/npm/v/iab-vast-parser.svg)](https://www.npmjs.com/package/iab-vast-parser) [![Dependencies](https://img.shields.io/david/zentrick/iab-vast-parser.svg)](https://david-dm.org/zentrick/iab-vast-parser) [![Build Status](https://img.shields.io/travis/zentrick/iab-vast-parser/master.svg)](https://travis-ci.org/zentrick/iab-vast-parser) [![Coverage Status](https://img.shields.io/coveralls/zentrick/iab-vast-parser/master.svg)](https://coveralls.io/r/zentrick/iab-vast-parser) [![JavaScript Standard Style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
4+
5+
Parses IAB VAST tags into
6+
[iab-vast-model](https://github.com/zentrick/iab-vast-model) objects.
7+
8+
## Usage
9+
10+
```js
11+
import parseVAST from 'iab-vast-parser'
12+
13+
const xmlStr = '<VAST version="3.0">...</VAST>'
14+
const vast = parseVAST(xmlStr)
15+
// ... Do your thing ...
16+
```
17+
18+
## API
19+
20+
```js
21+
parseVAST(xml[, options])
22+
```
23+
24+
The parameter `xml` can be either an XML string, or a parsed VAST DOM `Document`
25+
or `Element`.
26+
27+
Currently, one `option` is supported: you can pass in a `DOMParser` instance
28+
via the `domParser` key. If you don't do so, a new `DOMParser` will be created
29+
on the fly.
30+
31+
## Maintainer
32+
33+
[Tim De Pauw](https://github.com/timdp)
34+
35+
## License
36+
37+
MIT

browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib/parse').default

gulpfile.babel.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import gulp from 'gulp'
2+
import gutil from 'gulp-util'
3+
import loadPlugins from 'gulp-load-plugins'
4+
import {Instrumenter} from 'isparta'
5+
import del from 'del'
6+
import globule from 'globule'
7+
import seq from 'run-sequence'
8+
import fsp from 'fs-promise'
9+
import stableStringify from 'json-stable-stringify'
10+
import path from 'path'
11+
import marshal from './test/lib/marshal'
12+
13+
const $ = loadPlugins()
14+
15+
const plumb = () => $.plumber({
16+
errorHandler: $.notify.onError('<%= error.message %>')
17+
})
18+
19+
const test = (strict = false) => {
20+
return gulp.src(['test/lib/setup.js', 'test/integration/**/*.js'], {read: false})
21+
.pipe($.if(!strict, plumb()))
22+
.pipe($.mocha({reporter: 'spec'}))
23+
}
24+
25+
gulp.task('clean', () => del('lib'))
26+
27+
gulp.task('transpile', () => {
28+
return gulp.src('src/**/*.js')
29+
.pipe(plumb())
30+
.pipe($.sourcemaps.init())
31+
.pipe($.babel())
32+
.pipe($.sourcemaps.write())
33+
.pipe(gulp.dest('lib'))
34+
})
35+
36+
gulp.task('lint', () => {
37+
return gulp.src('src/**/*.js')
38+
.pipe(plumb())
39+
.pipe($.standard())
40+
.pipe($.standard.reporter('default', {
41+
breakOnError: false
42+
}))
43+
})
44+
45+
gulp.task('build', (cb) => seq('lint', 'test', 'transpile', cb))
46+
47+
gulp.task('cleanbuild', (cb) => seq('clean', 'build', cb))
48+
49+
gulp.task('pre-coverage', () => {
50+
return gulp.src('src/**/*.js')
51+
.pipe($.istanbul({instrumenter: Instrumenter}))
52+
.pipe($.istanbul.hookRequire())
53+
})
54+
55+
gulp.task('coverage', ['pre-coverage'], () => {
56+
return test(true)
57+
.pipe($.istanbul.writeReports())
58+
.pipe($.istanbul.enforceThresholds({thresholds: {global: 85}}))
59+
})
60+
61+
gulp.task('coveralls', ['coverage'], () => {
62+
return gulp.src('coverage/lcov.info')
63+
.pipe($.coveralls())
64+
})
65+
66+
gulp.task('test', test)
67+
68+
gulp.task('write-exp', () => {
69+
const parse = require('./src/').default
70+
71+
const fixturesRoot = path.resolve(__dirname, 'test/fixtures')
72+
const expectedRoot = path.resolve(__dirname, 'test/integration/expected')
73+
74+
const promises = []
75+
const errors = []
76+
for (const relPath of globule.find({cwd: fixturesRoot, src: '**/*.xml'})) {
77+
const filePath = path.join(fixturesRoot, relPath)
78+
const expPath = path.join(expectedRoot, gutil.replaceExtension(relPath, '.json'))
79+
const working = fsp.readFile(filePath, 'utf8')
80+
.then((data) => parse(data))
81+
.then((parsed) => marshal(parsed))
82+
.then((marshaled) => stableStringify(marshaled, {space: 2}))
83+
.then((data) => fsp.outputFile(expPath, data, 'utf8'))
84+
.then(() => gutil.log('Created', gutil.colors.magenta(expPath)))
85+
.catch((err) => {
86+
gutil.log('Error creating', gutil.colors.magenta(expPath) + ':', err.stack)
87+
errors.push({path: expPath, error: err})
88+
})
89+
promises.push(working)
90+
}
91+
92+
return Promise.all(promises)
93+
.then(() => {
94+
if (errors.length > 0) {
95+
throw new gutil.PluginError('write-exp', `Failed to create ${errors.length} file(s)`)
96+
}
97+
})
98+
})
99+
100+
gulp.task('watch', () => gulp.watch('{src,test}/**/*', ['cleanbuild']))
101+
102+
gulp.task('default', ['cleanbuild'], () => gulp.start('watch'))

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib/').default

0 commit comments

Comments
 (0)