new tr.models.Blip('Enterprise Data Warehouse', hold, true)
]);
languageFramework.add([
- new tr.models.Blip('Clojure', adopt),
+ new tr.models.Blip('Clojure', adopt, true),
new tr.models.Blip('Dropwizard', adopt),
new tr.models.Blip('Scala, the good parts', adopt),
new tr.models.Blip('Sinatra', adopt),
}
function plotBlips(cycles, quadrant, adjustX, adjustY) {
- var blips, number;
+ var blips;
blips = quadrant.blips();
- number = 0;
cycles.forEach(function (cycle, i) {
var maxRadius, minRadius, cycleBlips;
var split = blip.name().split('');
var sum = split.reduce(function (p, c) { return p + c.charCodeAt(0); }, 0);
- chance = new Chance(sum * cycle.name().length * number);
+ chance = new Chance(sum * cycle.name().length * blip.number());
angleInRad = Math.PI * chance.integer({ min: 13, max: 85 }) / 180;
radius = chance.floating({ min: minRadius + 25, max: maxRadius - 10 });
.attr('y', y + 4)
.attr('class', 'blip-text')
.attr('text-anchor', 'middle')
- .text(++number)
+ .text(blip.number())
});
});
};
tr.models.Blip = function (name, cycle, isNew) {
- var self = {};
+ var self, number;
+
+ self = {};
+ number = -1;
self.name = function () {
return name;
return cycle;
};
+ self.number = function () {
+ return number;
+ };
+
+ self.setNumber = function (newNumber) {
+ number = newNumber;
+ };
+
return self;
};
tr.models.Radar = function() {
- var self, quadrants;
+ var self, quadrants, blipNumber;
+ blipNumber = 0;
quadrants = { I: null, II: null, III: null, IV: null };
self = {};
+ function setNumbers(blips) {
+ blips.forEach(function (blip) {
+ blip.setNumber(++blipNumber);
+ });
+ }
+
self.setFirstQuadrant = function (quadrant) {
quadrants.I = quadrant;
+ setNumbers(quadrants.I.blips());
};
self.setSecondQuadrant = function (quadrant) {
quadrants.II = quadrant;
+ setNumbers(quadrants.II.blips());
};
self.setThirdQuadrant = function (quadrant) {
quadrants.III = quadrant;
+ setNumbers(quadrants.III.blips());
};
self.setFourthQuadrant = function (quadrant) {
quadrants.IV = quadrant;
+ setNumbers(quadrants.IV.blips());
};
function allQuadrants() {
describe('tr.models.Blip', function () {
- it('has a name', function () {
- var blip = new tr.models.Blip('My Blip');
+ var blip;
+ beforeEach(function () {
+ blip = new tr.models.Blip(
+ 'My Blip',
+ new tr.models.Cycle('My Cycle')
+ );
+ });
+ it('has a name', function () {
expect(blip.name()).toEqual('My Blip');
});
it('has a cycle', function () {
- var blip = new tr.models.Blip(
- 'My Blip',
- new tr.models.Cycle('My Cycle')
- );
-
expect(blip.cycle().name()).toEqual('My Cycle');
});
+ it('has a default number', function () {
+ expect(blip.number()).toEqual(-1);
+ });
+
+ it('sets the number', function () {
+ blip.setNumber(1);
+ expect(blip.number()).toEqual(1);
+ });
+
it('is new', function () {
- var blip = new tr.models.Blip(
+ blip = new tr.models.Blip(
'My Blip',
new tr.models.Cycle('My Cycle'),
true
});
it('is not new', function () {
- var blip = new tr.models.Blip(
+ blip = new tr.models.Blip(
'My Blip',
new tr.models.Cycle('My Cycle'),
false
expect(radar.quadrants().IV).toEqual(quadrant);
});
+ describe('blip numbers', function () {
+ var firstQuadrant, secondQuadrant, radar, firstCycle;
+
+ beforeEach(function () {
+ firstCycle = new tr.models.Cycle('Adopt', 0);
+ firstQuadrant = new tr.models.Quadrant('First');
+ secondQuadrant = new tr.models.Quadrant('Second');
+ firstQuadrant.add([
+ new tr.models.Blip('A', firstCycle),
+ new tr.models.Blip('B', firstCycle)
+ ]);
+ secondQuadrant.add([
+ new tr.models.Blip('C', firstCycle),
+ new tr.models.Blip('D', firstCycle)
+ ]);
+ radar = new tr.models.Radar();
+ });
+
+ it('sets blip numbers starting on the first quadrant', function () {
+ radar.setFirstQuadrant(firstQuadrant);
+
+ expect(radar.quadrants().I.blips()[0].number()).toEqual(1);
+ expect(radar.quadrants().I.blips()[1].number()).toEqual(2);
+ });
+
+ it('continues the number from the previous quadrant set', function () {
+ radar.setFirstQuadrant(firstQuadrant);
+ radar.setSecondQuadrant(secondQuadrant);
+
+ expect(radar.quadrants().II.blips()[0].number()).toEqual(3);
+ expect(radar.quadrants().II.blips()[1].number()).toEqual(4);
+ });
+ });
+
describe('cycles', function () {
var quadrant, radar, firstCycle, secondCycle;