Permalink
Browse files

start converting the bundled plugins, starting with the pivotal track…

…er one
  • Loading branch information...
1 parent 61dfbe7 commit 15e6d6aa6c47b8d00be8cde748093447ad21da2f @jamesbloomer committed Dec 15, 2012
Showing with 105 additions and 9 deletions.
  1. +5 −5 lib/pivotaltracker.js
  2. +8 −4 lib/tadaa.js
  3. +27 −0 lib/upordown.js
  4. +16 −0 plugins/pivotaltrackerbugs.js
  5. +16 −0 plugins/pivotaltrackerfeatures.js
  6. +4 −0 test/tadaa_test.js
  7. +29 −0 test/upordown_test.js
View
@@ -1,5 +1,7 @@
var pivotal = require("pivotal");
+var pivotalTracker = {};
+
var getStories = function(filter, options, callback) {
console.log('Calling Pivotal Tracker');
pivotal.useToken(options.token);
@@ -13,16 +15,14 @@ var getStories = function(filter, options, callback) {
});
};
-
-var getOpenBugs = function(options, callback) {
+pivotalTracker.getOpenBugs = function(options, callback) {
var openBugsFilter = "type:bug state:unscheduled,unstarted,started,finished,delivered,rejected";
return getStories(openBugsFilter, options, callback);
};
-var getOpenFeatures = function(options, callback) {
+pivotalTracker.getOpenFeatures = function(options, callback) {
var openFeaturesFilter = "type:feature state:unscheduled,unstarted,started,finished,delivered,rejected";
return getStories(openFeaturesFilter, options, callback);
};
-exports.getOpenBugs = getOpenBugs;
-exports.getOpenFeatures = getOpenFeatures;
+module.exports = pivotalTracker;
View
@@ -3,21 +3,25 @@ var child = require('child_process');
var tadaa = {};
tadaa.playCorrectSound = function(result, audioPlayer, callback) {
-
+ if(result === null) {
+ return callback();
+ }
+
if(!audioPlayer)
{
audioPlayer = 'aplay';
}
// TODO check for a file named result. If it doesn't exits drop back to default good and bad.
+ // TODO add an extension. What's the default?
return child.exec(audioPlayer + ' ' + result, callback);
};
-tadaa.getValueAndPlaySound = function(getValue, getValueOptions, audioPlayer) {
+tadaa.getValueAndPlaySound = function(execute, audioPlayer) {
var player = audioPlayer;
- getValue(getValueOptions, function(error, result) {
- tadaa.playCorrectSound(tadaa.current, result, player, function(error) {
+ execute(function(error, result) {
+ tadaa.playCorrectSound(result, player, function(error) {
return;
});
});
View
@@ -0,0 +1,27 @@
+var upordown = {};
+
+var count = 0;
+
+upordown.reset = function() {
+ count = 0;
+};
+
+upordown.getStatus = function(current) {
+ if(!current) {
+ return "nochange";
+ }
+
+ if(current === count) {
+ return "nochange";
+ }
+
+ var status = "down";
+ if(current > count) {
+ status = "up";
+ }
+
+ count = current;
+ return status;
+};
+
+module.exports = upordown;
@@ -0,0 +1,16 @@
+var pivotalTracker = require("../lib/pivotaltracker.js"),
+ upordown = require('../lib/upordown.js');
+// TODO allow plugins to include other modules somehow
+
+var pivotalTrackerBugs = {};
+
+pivotalTrackerBugs.interval = 300;
+
+pivotalTrackerBugs.execute = function(callback) {
+ var options = {}; // TODO
+ pivotalTracker.getOpenBugs(options, function(err, result) {
+ callback(null, upordown.getStatus(result));
+ });
+};
+
+module.exports = pivotalTrackerBugs;
@@ -0,0 +1,16 @@
+var pivotalTracker = require('../lib/pivotaltracker.js'),
+ upordown = require('../lib/upordown.js');
+// TODO allow plugins to include other modules somehow
+
+var pivotalTrackerFeatures = {};
+
+pivotalTrackerFeatures.interval = 300;
+
+pivotalTrackerFeatures.execute = function(callback) {
+ var options = {}; // TODO
+ pivotalTracker.getOpenFeatures(options, function(err, result) {
+ callback(null, upordown.getStatus(result));
+ });
+};
+
+module.exports = pivotalTrackerFeatures;
View
@@ -76,5 +76,9 @@ describe('Tadaa', function() {
// console.log('after assert');
// done();
// });
+
+ // Should call plugin.interval
+
+ // should pass plugin.execute
// });
});
View
@@ -0,0 +1,29 @@
+var mocha = require('mocha'),
+ assert = require('assert'),
+ upordown = require('../lib/upordown.js');
+
+describe('upordown', function() {
+ beforeEach(function() {
+ upordown.reset();
+ });
+
+ it('should return up when result is greater than current', function() {
+ assert.equal(upordown.getStatus(1), "up");
+ });
+
+ it('should return down when result is less than current', function() {
+ assert.equal(upordown.getStatus(-1), "down");
+ });
+
+ it('should return nochange when result is the same as current', function() {
+ assert.equal(upordown.getStatus(0), "nochange");
+ });
+
+ it('should return nochange when result is null', function() {
+ assert.equal(upordown.getStatus(null), "nochange");
+ });
+
+ it('should return nochange when result is undefined', function() {
+ assert.equal(upordown.getStatus(undefined), "nochange");
+ });
+});

0 comments on commit 15e6d6a

Please sign in to comment.