Commits

Kenneth Jørgensen committed 74f37c4

Upgraded to grunt 0.4 and changed the jasmine runner to jessie.

Comments (0)

Files changed (10)

+var exec = require("child_process").exec;
+
+module.exports = function(grunt) {
+	// Project configuration.
+	grunt.initConfig({
+		pkg: grunt.file.readJSON("package.json"),
+
+		coffee: {
+			// Core compile
+			core: {
+				files: {
+					"build/calamity.js": ["src/core/*.coffee"]
+				},
+				options: {
+					bare: true
+				}
+			},
+			// Compile the test files.
+			test: {
+				expand: true,
+				cwd: "test",
+				src: ["**/*.coffee"],
+				dest: "build/test",
+				ext: ".js"
+			},
+			// Compile the Jasmine specs.
+			spec: {
+				expand: true,
+				cwd: "spec",
+				src: ["**/*.coffee"],
+				dest: "build/spec",
+				ext: ".js"
+			}
+		},
+
+		concat: {
+			// Assembles the core distribution files.
+			core: {
+				options: {
+					banner:
+						"/*! <%= pkg.fullname %> <%= pkg.version %> - MIT license */\n" +
+						"(function(){\n",
+					footer: "}).call(this);",
+					process: true
+				},
+				src: [
+					"src/init/init.js",
+					"<%= _.keys(coffee.core.files)[0] %>"
+				],
+				dest: "<%= pkg.name %>.js"
+			}
+		},
+
+		uglify: {
+			core: {
+				options: {
+					preserveComments: "some"
+				},
+				files: {
+					"calamity-min.js": "calamity.js"
+				}
+			}
+		},
+
+		nodeunit: {
+			all: ["build/test/**/*.js"]
+		},
+
+		watch: {
+			files: [
+				"src/**",
+				"test/**",
+				"spec/**"
+			],
+			tasks: "default"
+		}
+	});
+
+	grunt.registerTask("jessie", "Runs Jasmine with Jessie.", function() {
+		done = this.async();
+		command = "./node_modules/jessie/bin/jessie build/spec"
+		exec(command, function(err, stdout, stderr) {
+			console.log(stdout);
+			if (err) {
+				grunt.warn(err);
+				done(false);
+			}
+			else {
+				done(true);
+			}
+		});
+	});
+
+	// Load grunt plugins.
+	grunt.loadNpmTasks("grunt-contrib-coffee");
+	grunt.loadNpmTasks("grunt-contrib-concat");
+	grunt.loadNpmTasks("grunt-contrib-uglify");
+	grunt.loadNpmTasks("grunt-contrib-nodeunit");
+//	grunt.loadNpmTasks("grunt-jasmine-runner");
+//	grunt.loadNpmTasks("grunt-jasmine-node");
+//	grunt.loadNpmTasks("grunt-browserify");
+
+	grunt.registerTask("default", ["coffee", "concat", "uglify", "nodeunit", "jessie"]);
+
+	// Core compile.
+//	grunt.registerTask("compile-core", "coffee:core_first concat:core_coffee coffee:core_second");
+//	grunt.registerTask("dist-core", "concat:core_dist min:core");
+//	grunt.registerTask("test-core", "coffee:core_test test"); // will go away once ported to jasmine
+//	grunt.registerTask("spec-phantomjs", "browserify jasmine");
+//	grunt.registerTask("build-core", "compile-core dist-core test-core spec-phantomjs");
+	// Default task.
+//	grunt.registerTask("default", "build-core");
+
+};

grunt.js

-module.exports = function(grunt) {
-
-	// Project configuration.
-	grunt.initConfig({
-		pkg: '<json:package.json>',
-		meta: {
-			banner: "/*! <%= pkg.fullname %> <%= pkg.version %> - MIT license */",
-			wrapperVersion: "C.VERSION = \"<%= pkg.version %>\";",
-			wrapperStart: "(function(){",
-			wrapperEnd: "}).call(this);"
-		},
-
-		coffee: {
-			// Initial precompile to catch compile errors properly.
-			core_first: {
-				files: {
-					"build/core/*.js": ["src/core/*.coffee"]
-				},
-				options: {
-					bare: true
-				}
-			},
-			// Second compile of concatenated coffee files for more minimizes output.
-			core_second: {
-				files: {
-					"build/core/calamity.js": ["build/core/<%= pkg.name %>.coffee"]
-				},
-				options: {
-					bare: true
-				}
-			},
-			// Compile the core test coffee files.
-			core_test: {
-				files: {
-					"build/test/core/*.js": ["test/core/*.coffee"]
-				}
-			}
-		},
-
-		// Build Jasmine core specs for the browser
-		browserify: {
-			"build/spec.js": {
-				entries: ["spec/core/*.coffee"]
-			}
-		},
-
-		// Execute Jasmine specs
-		jasmine : {
-			src: [
-				"node_modules/sinon/lib/sinon.js",
-				"node_modules/sinon/lib/sinon/spy.js",
-				"lib/jasmine-sinon.js"
-			],
-			specs : "build/spec.js",
-			timeout : 500,
-			verbose: true,
-			junit : {
-				output : "build/spec/"
-			},
-			phantomjs : {
-				"ignore-ssl-errors" : true
-			}
-		},
-
-		concat: {
-			// Assembles the core coffee files in prep for full compile.
-			core_coffee: {
-				src: "src/core/*.coffee",
-				dest: "build/core/<%= pkg.name %>.coffee"
-			},
-			// Assembles the core distribution files.
-			core_dist: {
-				src: [
-					"<banner>",
-					"<banner:meta.wrapperStart>",
-					"src/init/init.js",
-					"<banner:meta.wrapperVersion>",
-					"<%= _.keys(coffee.core_second.files)[0] %>",
-					"<banner:meta.wrapperEnd>"
-				],
-				dest: "<%= pkg.name %>.js"
-			}
-		},
-		min: {
-			// Minimizes the core distribution files.
-			core: {
-				src: [
-					"<banner>",
-					"<config:concat.core_dist.dest>"
-				],
-				dest: "<%= pkg.name %>-min.js"
-			}
-		},
-
-		test: {
-			files : [
-				// Core tests.
-				"<%= _.keys(coffee.core_test.files) %>"
-			]
-		},
-
-		watch: {
-			files: [
-				"src/**",
-				"test/**"
-			],
-			tasks: "default"
-		}
-	});
-
-	// Load grunt plugins.
-	grunt.loadNpmTasks("grunt-contrib-coffee");
-	grunt.loadNpmTasks("grunt-jasmine-runner");
-//	grunt.loadNpmTasks("grunt-jasmine-node");
-	grunt.loadNpmTasks("grunt-browserify");
-
-	// Core compile.
-	grunt.registerTask("compile-core", "coffee:core_first concat:core_coffee coffee:core_second");
-	grunt.registerTask("dist-core", "concat:core_dist min:core");
-	grunt.registerTask("test-core", "coffee:core_test test"); // will go away once ported to jasmine
-	grunt.registerTask("spec-phantomjs", "browserify jasmine");
-	grunt.registerTask("build-core", "compile-core dist-core test-core spec-phantomjs");
-	// Default task.
-	grunt.registerTask("default", "build-core");
-
-};
 {
 	"fullname": "Calamity",
 	"name": "calamity",
-	"version": "0.3.0",
+	"version": "0.3.1",
 	"description": "An event bus library for event-driven applications.",
 	"keywords": ["events", "pubsub"],
 	"homepage": "https://bitbucket.org/kennethjor/calamity",
 		}
 	],
 	"dependencies": {
-		"underscore": "~ 1.4.3"
+		"underscore": "~ 1.4.4"
 	},
 	"devDependencies": {
-		"grunt-contrib-coffee": "~ 0.3.2",
+		"grunt": "~ 0.4",
+		"grunt-contrib-concat": "~ 0.1.3",
+		"grunt-contrib-coffee": "~ 0.6.0",
+		"grunt-contrib-uglify": "~ 0.2.0",
+		"grunt-contrib-nodeunit": "~ 0.1.2",
+		"grunt-contrib-watch": "~ 0.3.1",
 		"async": "~ 0.1.22",
-		"grunt-browserify": "~ 0.1.2",
-		"grunt-jasmine-runner": "~ 0.6.0",
-		"sinon": "~ 1.5.2"
-	},
-	"scripts": {
-		"prepublish": "grunt && ./docs.sh"
+		"jessie": "~ 0.4.2",
+		"sinon": "~ 1.6.0"
 	},
 	"files": [
 		"calamity.js",

spec/core/EventBusSpec.coffee

-C = require "../../calamity.js"
+C = require "../../../calamity"
+sinon = require "sinon"
 
 describe "EventBus", ->
 	bus = null
 			bus.publish "address/1"
 		waits 10
 		runs ->
-			expect(handler11).toHaveBeenCalledOnce()
-			expect(handler12).toHaveBeenCalledOnce()
-			expect(handler2).not.toHaveBeenCalled()
+			expect(handler11.callCount).toBe 1
+			expect(handler12.callCount).toBe 1
+			expect(handler2.called).toBe false
 
 			bus.publish "address/2"
 		waits 10
 		runs ->
-			expect(handler11).toHaveBeenCalledOnce()
-			expect(handler12).toHaveBeenCalledOnce()
-			expect(handler2).toHaveBeenCalledOnce()
+			expect(handler11.callCount).toBe 1
+			expect(handler12.callCount).toBe 1
+			expect(handler2.called).toBe true
 
 	it "should send correct message to handlers", ->
 		msg = null
 }
 
 // Init Calamity object.
-var C = {};
+var C = {version: "<%= pkg.version %>"};
 
-// This wrapper is brutally stolen from Underscore 1.4.2.
-// https://raw.github.com/documentcloud/underscore/master/underscore.js
 var root = this
-if (typeof exports !== 'undefined') {
-	if (typeof module !== 'undefined' && module.exports) {
+// CommonJS
+if (typeof exports !== "undefined") {
+	if (typeof module !== "undefined" && module.exports) {
 		exports = module.exports = C;
 	}
 	exports.C = C;
 }
-else if (typeof define === 'function' && define.amd) {
-    // AMD. Register as an anonymous module.
+// AMD
+else if (typeof define === "function" && define.amd) {
     define(['calamity'], C);
 }
+// Browser
 else {
 	root['Calamity'] = C;
 }

test/core/EmitterMixinTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 # Test class with the emitter mixin applied.

test/core/EventBusTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 bus = null

test/core/EventMessageTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 msg = null

test/core/MemoryEventBridgeTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 bus = null

test/core/ProxyMixinTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 # Proxy using the default global bus.