initial commit
authorBruno Trecenti <btrecent@thoughtworks.com>
Tue, 25 Feb 2014 12:06:32 +0000 (09:06 -0300)
committerBruno Trecenti <btrecent@thoughtworks.com>
Tue, 25 Feb 2014 12:48:46 +0000 (09:48 -0300)
12 files changed:
.gitignore [new file with mode: 0644]
bower.json [new file with mode: 0644]
gulpfile.js [new file with mode: 0644]
karma.conf.js [new file with mode: 0644]
package.json [new file with mode: 0644]
src/models/blip.js [new file with mode: 0644]
src/models/cycle.js [new file with mode: 0644]
src/models/quadrant.js [new file with mode: 0644]
src/namespaces.js [new file with mode: 0644]
test/models/blip-spec.js [new file with mode: 0644]
test/models/cycle-spec.js [new file with mode: 0644]
test/models/quadrant-spec.js [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..d425a4c
--- /dev/null
@@ -0,0 +1,5 @@
+node_modules
+bower_components
+*.swa
+*.swp
+*.swo
diff --git a/bower.json b/bower.json
new file mode 100644 (file)
index 0000000..9de5e2f
--- /dev/null
@@ -0,0 +1,13 @@
+{
+  "name": "tech-radar",
+  "version": "0.0.0",
+  "homepage": "https://github.com/Trecenti/tech-radar",
+  "authors": [
+    "Bruno Trecenti <btrecent@thoughtworks.com>"
+  ],
+  "license": "MIT",
+  "private": true,
+  "dependencies": {
+    "d3": "~3.4.2"
+  }
+}
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644 (file)
index 0000000..d5b7c25
--- /dev/null
@@ -0,0 +1,24 @@
+var gulp = require('gulp')
+  , gutil = require('gulp-util')
+  , gkarma = require('gulp-karma')
+  , files;
+
+files = {
+  LIB: 'bower_components/d3/*.min.js',
+  NS: 'src/namespaces.js',
+  SOURCE: 'src/**/*.js',
+  SPEC: 'test/**/*-spec.js'
+};
+
+gulp.task('test', function (){
+  var karma;
+
+  karma = gkarma({
+    configFile: 'karma.conf.js',
+    action: 'run'
+  });
+
+  return gulp.src(
+    [files.LIB, files.NS, files.SOURCE, files.SPEC]
+  ).pipe(karma);
+});
diff --git a/karma.conf.js b/karma.conf.js
new file mode 100644 (file)
index 0000000..1753663
--- /dev/null
@@ -0,0 +1,6 @@
+module.exports = function(config) {
+  config.set({
+    frameworks: ['jasmine'],
+    browsers: ['PhantomJS']
+  });
+};
diff --git a/package.json b/package.json
new file mode 100644 (file)
index 0000000..5678e6b
--- /dev/null
@@ -0,0 +1,31 @@
+{
+  "name": "tech-radar",
+  "version": "0.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "",
+  "license": "ISC",
+  "devDependencies": {
+    "gulp-util": "~2.2.14",
+    "gulp": "~3.5.2",
+    "karma-script-launcher": "~0.1.0",
+    "karma-chrome-launcher": "~0.1.2",
+    "karma-firefox-launcher": "~0.1.3",
+    "karma-html2js-preprocessor": "~0.1.0",
+    "karma-jasmine": "~0.1.5",
+    "karma-coffee-preprocessor": "~0.1.3",
+    "requirejs": "~2.1.11",
+    "karma-requirejs": "~0.2.1",
+    "karma-phantomjs-launcher": "~0.1.2",
+    "karma": "~0.10.9",
+    "gulp-karma": "0.0.2"
+  },
+  "dependencies": {
+    "gulp-util": "~2.2.14",
+    "gulp": "~3.5.2",
+    "express": "~3.4.8"
+  }
+}
diff --git a/src/models/blip.js b/src/models/blip.js
new file mode 100644 (file)
index 0000000..0495a09
--- /dev/null
@@ -0,0 +1,17 @@
+tr.models.Blip = function (name, cycle, isNew) {
+  var self = {};
+
+  self.name = function () {
+    return name;
+  };
+
+  self.isNew = function () {
+    return isNew;
+  };
+
+  self.cycle = function () {
+    return cycle;
+  };
+
+  return self;
+};
diff --git a/src/models/cycle.js b/src/models/cycle.js
new file mode 100644 (file)
index 0000000..5893aa2
--- /dev/null
@@ -0,0 +1,9 @@
+tr.models.Cycle = function (name) {
+  var self = {};
+
+  self.name = function () {
+    return name;
+  };
+
+  return self;
+};
diff --git a/src/models/quadrant.js b/src/models/quadrant.js
new file mode 100644 (file)
index 0000000..a25e2b0
--- /dev/null
@@ -0,0 +1,24 @@
+tr.models.Quadrant = function (name) {
+  var self, blips;
+
+  self = {};
+  blips = [];
+
+  self.name = function () {
+    return name;
+  };
+
+  self.add = function (newBlips) {
+    if (Array.isArray(newBlips)) {
+      blips = blips.concat(newBlips);
+    } else {
+      blips.push(newBlips);
+    }
+  };
+
+  self.blips = function () {
+    return blips.slice(0);
+  };
+
+  return self;
+};
diff --git a/src/namespaces.js b/src/namespaces.js
new file mode 100644 (file)
index 0000000..60fafca
--- /dev/null
@@ -0,0 +1,3 @@
+var tr = tr || {};
+tr.models = {};
+tr.graphing = {};
diff --git a/test/models/blip-spec.js b/test/models/blip-spec.js
new file mode 100644 (file)
index 0000000..005e508
--- /dev/null
@@ -0,0 +1,36 @@
+describe('tr.models.Blip', function () {
+  it('has a name', function () {
+    var blip = new tr.models.Blip('My Blip');
+
+    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('is new', function () {
+    var blip = new tr.models.Blip(
+      'My Blip',
+      new tr.models.Cycle('My Cycle'),
+      true
+    );
+
+    expect(blip.isNew()).toBe(true);
+  });
+
+  it('is not new', function () {
+    var blip = new tr.models.Blip(
+      'My Blip',
+      new tr.models.Cycle('My Cycle'),
+      false
+    );
+
+    expect(blip.isNew()).toBe(false);
+  });
+});
diff --git a/test/models/cycle-spec.js b/test/models/cycle-spec.js
new file mode 100644 (file)
index 0000000..ecba3d1
--- /dev/null
@@ -0,0 +1,7 @@
+describe('tr.models.Cycle', function () {
+  it('has a name', function () {
+    var cycle = new tr.models.Cycle('My Cycle');
+
+    expect(cycle.name()).toEqual('My Cycle');
+  });
+});
diff --git a/test/models/quadrant-spec.js b/test/models/quadrant-spec.js
new file mode 100644 (file)
index 0000000..0c3ce69
--- /dev/null
@@ -0,0 +1,29 @@
+describe('tr.models.Quadrant', function () {
+  it('has a name', function () {
+    var quadrant = new tr.models.Quadrant('My Quadrant');
+
+    expect(quadrant.name()).toEqual('My Quadrant');
+  });
+
+  it('has no blips by default', function () {
+    var quadrant = new tr.models.Quadrant('My Quadrant');
+
+    expect(quadrant.blips()).toEqual([]);
+  });
+
+  it('can add a single blip', function () {
+    var quadrant = new tr.models.Quadrant('My Quadrant');
+
+    quadrant.add(new tr.models.Blip());
+
+    expect(quadrant.blips().length).toEqual(1);
+  });
+
+  it('can add multiple blips', function () {
+    var quadrant = new tr.models.Quadrant('My Quadrant');
+
+    quadrant.add([new tr.models.Blip(), new tr.models.Blip()]);
+
+    expect(quadrant.blips().length).toEqual(2);
+  });
+});