Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Commit

Permalink
Merge commit '0cc06c8a0b0c1de827af7a84d6109f6c94b7324a' as 'archived_…
Browse files Browse the repository at this point in the history
…PhantRepos/phant-reaper'
  • Loading branch information
bboyho committed Nov 15, 2017
2 parents 5cab7fa + 0cc06c8 commit bf91979
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 0 deletions.
4 changes: 4 additions & 0 deletions archived_PhantRepos/phant-reaper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tmp
/node_modules/
*.swp
npm-debug.log
14 changes: 14 additions & 0 deletions archived_PhantRepos/phant-reaper/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": "func",
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"node": true
}
11 changes: 11 additions & 0 deletions archived_PhantRepos/phant-reaper/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- '0.10'
before_script:
- npm install -g grunt-cli
notifications:
email:
recipients:
- [email protected]
on_success: change
on_failure: change
48 changes: 48 additions & 0 deletions archived_PhantRepos/phant-reaper/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

module.exports = function (grunt) {
// Show elapsed time at the end
require('time-grunt')(grunt);
// Load all grunt tasks
require('load-grunt-tasks')(grunt);

// Project configuration.
grunt.initConfig({
nodeunit: {
files: ['test/**/*_test.js']
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['lib/**/*.js']
},
test: {
src: ['test/**/*.js']
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib: {
files: '<%= jshint.lib.src %>',
tasks: ['jshint:lib', 'nodeunit']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'nodeunit']
}
}
});

// Default task.
grunt.registerTask('default', ['jshint', 'nodeunit']);

};
12 changes: 12 additions & 0 deletions archived_PhantRepos/phant-reaper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# phant-reaper [![Build Status](https://secure.travis-ci.org/sparkfun/phant-reaper.png?branch=master)](http://travis-ci.org/sparkfun/phant-reaper)

kills old phant stream metadata and data if the stream hasn't been pushed to in a while

## Getting Started
Install the module with: `npm install phant-reaper`

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## License
Copyright (c) 2014 SparkFun Electronics. Licensed under the GPL v3 license.
80 changes: 80 additions & 0 deletions archived_PhantRepos/phant-reaper/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* phant-reaper
* https://github.com/sparkfun/phant-reaper
*
* Copyright (c) 2014 SparkFun Electronics
* Licensed under the GPL v3 license.
*/

'use strict';

/**** Module dependencies ****/
var util = require('util'),
events = require('events');

/**** Make Reaper an event emitter ****/
util.inherits(Reaper, events.EventEmitter);

/**** app prototype ****/
var app = Reaper.prototype;

/**** Expose Reaper ****/
exports = module.exports = Reaper;

function Reaper(options) {

if (! (this instanceof Reaper)) {
return new Reaper(options);
}

events.EventEmitter.call(this);

util._extend(this, options || {});

}

app.created = 7 * 24 * 60 * 60 * 1000; // 7 days
app.pushed = 31540000000; // 1 year
app.metadata = false;
app.storage = false;

app.reap = function() {

var self = this,
now = new Date();

this.metadata.each(function(err, stream) {

var last = new Date(stream.last_push),
created = new Date(stream.date);

if(err) {
return self.emit('error', err);
}

// leave it alone if it was created recently
if ((now.getTime() - created.getTime()) < self.created) {
return;
}

// leave it alone if it has pushed recently
if ((now.getTime() - last.getTime()) < self.pushed) {
return;
}

self.metadata.delete(stream.id, function(err) {

if(err) {
return self.emit('error', err);
}

self.storage.clear(stream.id);

self.emit('delete', stream.id);

});

});

};

33 changes: 33 additions & 0 deletions archived_PhantRepos/phant-reaper/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "phant-reaper",
"version": "1.0.0",
"main": "index.js",
"description": "clears unused phant streams",
"homepage": "https://github.com/sparkfun/phant-reaper",
"bugs": "https://github.com/sparkfun/phant-reaper/issues",
"author": {
"name": "Todd Treece",
"email": "[email protected]",
"url": "http://uniontownlabs.org"
},
"repository": {
"type": "git",
"url": "git://github.com/sparkfun/phant-reaper"
},
"license": "GPL-3.0",
"devDependencies": {
"grunt": "^0.4.4",
"grunt-contrib-jshint": "~0.7.0",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-watch": "~0.5.0",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.0",
"jshint-stylish": "~0.1.3"
},
"engines": {
"node": "^0.10.29"
},
"scripts": {
"test": "grunt"
}
}
14 changes: 14 additions & 0 deletions archived_PhantRepos/phant-reaper/test/phant_reaper_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

var Reaper = require('../index.js');

exports.reaper = {
setUp: function(done) {
done();
},
'no args': function(test) {
test.expect(1);
test.ok(Reaper, 'should be ok');
test.done();
}
};

0 comments on commit bf91979

Please sign in to comment.