Comparing version 1.3.0 to 1.4.0
20
index.js
@@ -18,2 +18,3 @@ var uuid = require('uuid') | ||
this.hook('handleGif', this.handleGif) | ||
this.hook('saveMetaData', this.saveMetaData) | ||
this.hook('emitGif', this.emitGif) | ||
@@ -75,9 +76,2 @@ | ||
var id = uuid.v1() | ||
this.urlDb.put(url, { | ||
filename: id + '.gif', | ||
dir: this.outDir, | ||
time: new Date().getTime() | ||
}, function(err) { | ||
if(err) throw err | ||
}) | ||
@@ -90,2 +84,14 @@ this.download(id, url) | ||
downloader.download(url, this.outDir + '/' + id + '.gif', function() { | ||
this.saveMetaData(url, id) | ||
}.bind(this)) | ||
} | ||
Giffer.prototype.saveMetaData = function(url, id) { | ||
this.urlDb.put(url, { | ||
filename: id + '.gif', | ||
dir: this.outDir, | ||
time: new Date().getTime() | ||
}, function(err) { | ||
if(err) throw err | ||
this.emitGif(id + '.gif') | ||
@@ -92,0 +98,0 @@ }.bind(this)) |
{ | ||
"name": "giffer", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "GIF download bot", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,3 +11,3 @@ var test = require('tap').test | ||
test('Test basic functionality of giffer', function(t) { | ||
t.plan(4) | ||
t.plan(5) | ||
var testAdapter = new TestAdapter() | ||
@@ -29,2 +29,6 @@ | ||
}) | ||
giffer.pre('saveMetaData', function(next) { | ||
t.ok(true) | ||
next() | ||
}) | ||
giffer.pre('emitGif', function(next) { | ||
@@ -31,0 +35,0 @@ t.ok(true) |
6762
159