Skip to content

Commit 0b39dbc

Browse files
author
Jordi Aguilar
committed
analyze, copyfiles and constructor changed
1 parent 2445410 commit 0b39dbc

File tree

5 files changed

+88
-4
lines changed

5 files changed

+88
-4
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## [Unreleased]
2+
3+
## [1.1.0] - 2017-01-10
4+
### Changed
5+
- npawify() now supports multiple arguments, it will merge them using asssign.
6+
7+
### Added
8+
- npawify.copyfiles
9+
- npawify.analyze
10+
11+
## [1.0.5] - 2017-01-09
12+
### Fixed
13+
- Using gulp-sourcemas 1.9.3 as 1.9.1 was removed from npm (wtf).
14+
15+
## [1.0.4] - 2016-12-27
16+
### Added
17+
- Postpublish script
18+
19+
### Changed
20+
- Output colors
21+
22+
## [1.0.3] - 2016-12-27
23+
### Changed
24+
- Log messages
25+
26+
## [1.0.2] - 2016-12-27
27+
### Changed
28+
- Output colors
29+
30+
## [1.0.1] - 2016-12-27
31+
### Added
32+
- npawify.assign()
33+
34+
## [1.0.0] - 2016-12-27
35+
- First version

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ var options = {
1919
}
2020

2121
gulp.task('build', npawify(options))
22-
gulp.task('watch', npawify(npawify.assign({}, options, { watch: true }))
22+
gulp.task('watch', npawify(options, { watch: true })
2323
gulp.task('default', ['build'])
2424
```
2525
26+
Note: npawify supports multiple arguments, that will be merged using [assign](#npawifyassign). ie: `npawify(options, { watch: true })`.
27+
2628
## Options
2729
npawify receives an options object, that can receive:
2830
@@ -35,6 +37,12 @@ npawify receives an options object, that can receive:
3537
* `license`: String containing license text. **Default:** undefined.
3638
3739
## npawify.assign
38-
npawify comes with `npawify.assign()` which is a copy of
40+
npawify comes with `npawify.assign()` which is a replica of
3941
[`Object.assign`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
4042
for its use with older Node versions.
43+
44+
## npawify.analyze
45+
This npawify function analyzes an adapter and returns an object containing its findings.
46+
47+
## npawify.copyfiles
48+
Exposes [`copyfiles`](https://www.npmjs.com/package/copyfiles) package.

dist/analyze.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = function (p) {
2+
var file = fs.readFileSync(p)
3+
var allgetters = ['getPlayhead', 'getPlayrate', 'getFramesPerSecond', 'getDroppedFrames',
4+
'getDuration', 'getBitrate', 'getThroughput', 'getRendition', 'getTitle', 'getTitle2',
5+
'getIsLive', 'getResource', 'getPosition']
6+
7+
var getters = []
8+
for (var i = 0; i < allgetters.length; i++) {
9+
var element = allgetters[i]
10+
if (file.indexOf(element) !== -1) {
11+
getters.push(element)
12+
}
13+
}
14+
15+
var name = pkg.name
16+
if (name.indexOf('youbora-adapter-') === 0) name = name.slice(16)
17+
18+
return {
19+
name: name,
20+
type: 'adapter',
21+
tech: 'js',
22+
author: pkg.author,
23+
version: pkg.version,
24+
libVersion: lib.VERSION,
25+
built: new Date().toDateString(),
26+
features: {
27+
buffer: file.indexOf('fireBufferBegin') !== -1 ? 'native' : 'monitor',
28+
seek: file.indexOf('fireSeekBegin') !== -1 ? 'native' : 'monitor',
29+
getters: getters
30+
}
31+
}
32+
}

dist/npawify.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ var through = require('through2')
88
var rename = require('gulp-rename')
99
var sourcemaps = require('gulp-sourcemaps')
1010
var uglify = require('gulp-uglify')
11+
var copyfiles = require('copyfiles')
1112

1213
var license = require('./license')
1314
var Logger = require('./logger')
1415
var assign = require('./assign')
16+
var analyze = require('./analyze')
1517

1618
var defaults = {
1719
entry: 'src/index.js',
@@ -23,8 +25,12 @@ var defaults = {
2325
license: false
2426
}
2527

26-
var npawify = function (options) {
27-
options = assign({}, defaults, options)
28+
/** Accept multiple arguments, will join them using assign */
29+
var npawify = function () {
30+
var args = Array.prototype.slice.call(arguments)
31+
args.unshift({})
32+
33+
var options = assign.apply(this, args)
2834

2935
var bundler = browserify({
3036
entries: [options.entry],
@@ -63,5 +69,7 @@ var npawify = function (options) {
6369

6470
npawify.assign = assign
6571
npawify.Logger = Logger
72+
npawify.copyfiles = copyfiles
73+
npawify.analyze = analyze
6674

6775
module.exports = npawify

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"dependencies": {
3333
"browserify": "13.1.1",
3434
"convert-source-map": "1.3.0",
35+
"copyfiles": "1.0.0",
3536
"gulp": "3.9.1",
3637
"gulp-rename": "1.2.2",
3738
"gulp-sourcemaps": "^1.9.3",

0 commit comments

Comments
 (0)