diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..319469b --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +BIN := ./node_modules/.bin +TEST_FILES := test/support/globals.js $(shell find test/specs -type f -name "*.js") + +# Our 'phony' make targets (don't involve any file changes) +.PHONY: test bdd lint + +# Run Mocha, with standard reporter. +test: + @$(BIN)/mocha -r cylon --colors $(TEST_FILES) + +# Run Mocha, with more verbose BDD reporter. +bdd: + @$(BIN)/mocha -r cylon --colors -R spec $(TEST_FILES) + +# Run JSHint +lint: + @$(BIN)/jshint ./lib diff --git a/dist/test/loopback.js b/dist/test/loopback.js deleted file mode 100644 index 492d3ea..0000000 --- a/dist/test/loopback.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Loopback adaptor - * cylonjs.com - * - * Copyright (c) 2013 The Hybrid Group - * Licensed under the Apache 2.0 license. -*/ - - -(function() { - 'use strict'; - var namespace, - __slice = [].slice, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - namespace = require('node-namespace'); - - module.exports = { - adaptor: function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - return (function(func, args, ctor) { - ctor.prototype = func.prototype; - var child = new ctor, result = func.apply(child, args); - return Object(result) === result ? result : child; - })(Cylon.Adaptors.Loopback, args, function(){}); - } - }; - - namespace('Cylon.Adaptors', function() { - var _ref; - return this.Loopback = (function(_super) { - __extends(Loopback, _super); - - function Loopback() { - _ref = Loopback.__super__.constructor.apply(this, arguments); - return _ref; - } - - Loopback.prototype.commands = function() { - return ['ping']; - }; - - return Loopback; - - })(Cylon.Adaptor); - }); - -}).call(this); diff --git a/dist/test/ping.js b/dist/test/ping.js deleted file mode 100644 index d9621d2..0000000 --- a/dist/test/ping.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Ping driver - * cylonjs.com - * - * Copyright (c) 2013 The Hybrid Group - * Licensed under the Apache 2.0 license. -*/ - - -(function() { - 'use strict'; - var namespace, - __slice = [].slice, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - namespace = require('node-namespace'); - - module.exports = { - driver: function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - return (function(func, args, ctor) { - ctor.prototype = func.prototype; - var child = new ctor, result = func.apply(child, args); - return Object(result) === result ? result : child; - })(Cylon.Drivers.Ping, args, function(){}); - } - }; - - namespace('Cylon.Drivers', function() { - var _ref; - return this.Ping = (function(_super) { - __extends(Ping, _super); - - function Ping() { - _ref = Ping.__super__.constructor.apply(this, arguments); - return _ref; - } - - Ping.prototype.commands = function() { - return ['ping']; - }; - - Ping.prototype.ping = function() { - return "pong"; - }; - - return Ping; - - })(Cylon.Driver); - }); - -}).call(this); diff --git a/dist/test/test-adaptor.js b/dist/test/test-adaptor.js deleted file mode 100644 index 44b0191..0000000 --- a/dist/test/test-adaptor.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Test adaptor - * cylonjs.com - * - * Copyright (c) 2013 The Hybrid Group - * Licensed under the Apache 2.0 license. -*/ - - -(function() { - 'use strict'; - var namespace, - __slice = [].slice, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - namespace = require('node-namespace'); - - module.exports = { - adaptor: function() { - var args; - args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - return (function(func, args, ctor) { - ctor.prototype = func.prototype; - var child = new ctor, result = func.apply(child, args); - return Object(result) === result ? result : child; - })(Cylon.Adaptors.TestAdaptor, args, function(){}); - } - }; - - namespace('Cylon.Adaptors', function() { - return this.TestAdaptor = (function(_super) { - __extends(TestAdaptor, _super); - - function TestAdaptor(opts) { - if (opts == null) { - opts = {}; - } - TestAdaptor.__super__.constructor.apply(this, arguments); - } - - return TestAdaptor; - - })(Cylon.Adaptor); - }); - -}).call(this); diff --git a/dist/adaptor.js b/lib/adaptor.js similarity index 100% rename from dist/adaptor.js rename to lib/adaptor.js diff --git a/dist/api.js b/lib/api.js similarity index 100% rename from dist/api.js rename to lib/api.js diff --git a/dist/basestar.js b/lib/basestar.js similarity index 100% rename from dist/basestar.js rename to lib/basestar.js diff --git a/dist/cli/bluetooth.js b/lib/cli/bluetooth.js similarity index 100% rename from dist/cli/bluetooth.js rename to lib/cli/bluetooth.js diff --git a/dist/cli/cli-commands.js b/lib/cli/cli-commands.js similarity index 100% rename from dist/cli/cli-commands.js rename to lib/cli/cli-commands.js diff --git a/dist/cli/connect-to-serial.js b/lib/cli/connect-to-serial.js similarity index 100% rename from dist/cli/connect-to-serial.js rename to lib/cli/connect-to-serial.js diff --git a/dist/cli/process.js b/lib/cli/process.js similarity index 100% rename from dist/cli/process.js rename to lib/cli/process.js diff --git a/dist/cli/scan.js b/lib/cli/scan.js similarity index 100% rename from dist/cli/scan.js rename to lib/cli/scan.js diff --git a/dist/config.js b/lib/config.js similarity index 100% rename from dist/config.js rename to lib/config.js diff --git a/dist/connection.js b/lib/connection.js similarity index 100% rename from dist/connection.js rename to lib/connection.js diff --git a/dist/cylon.js b/lib/cylon.js similarity index 100% rename from dist/cylon.js rename to lib/cylon.js diff --git a/dist/device.js b/lib/device.js similarity index 100% rename from dist/device.js rename to lib/device.js diff --git a/dist/digital-pin.js b/lib/digital-pin.js similarity index 100% rename from dist/digital-pin.js rename to lib/digital-pin.js diff --git a/dist/driver.js b/lib/driver.js similarity index 100% rename from dist/driver.js rename to lib/driver.js diff --git a/dist/logger.js b/lib/logger.js similarity index 100% rename from dist/logger.js rename to lib/logger.js diff --git a/dist/port.js b/lib/port.js similarity index 100% rename from dist/port.js rename to lib/port.js diff --git a/dist/robot.js b/lib/robot.js similarity index 100% rename from dist/robot.js rename to lib/robot.js diff --git a/lib/test/loopback.js b/lib/test/loopback.js new file mode 100644 index 0000000..a5aca14 --- /dev/null +++ b/lib/test/loopback.js @@ -0,0 +1,35 @@ +/* + * Loopback adaptor + * cylonjs.com + * + * Copyright (c) 2013-2014 The Hybrid Group + * Licensed under the Apache 2.0 license. +*/ + +"use strict"; + +var namespace = require('node-namespace'); + +module.exports = { + adaptor: function(opts) { + return new Cylon.Adaptors.Loopback(opts); + } +}; + +namespace("Cylon.Adaptors", function() { + this.Loopback = (function(klass) { + subclass(Loopback, klass); + + function Loopback() { + _ref = Loopback.__super__.constructor.apply(this, arguments); + return _ref; + } + + Loopback.prototype.commands = function() { + return ['ping']; + }; + + return Loopback; + + })(Cylon.Adaptor); +}); diff --git a/lib/test/ping.js b/lib/test/ping.js new file mode 100644 index 0000000..ba19894 --- /dev/null +++ b/lib/test/ping.js @@ -0,0 +1,39 @@ +/* + * Ping driver + * cylonjs.com + * + * Copyright (c) 2013-2014 The Hybrid Group + * Licensed under the Apache 2.0 license. +*/ + +'use strict'; + +var namespace = require('node-namespace'); + +module.exports = { + driver: function(opts) { + return new Cylon.Drivers.Ping(opts); + } +}; + +namespace("Cylon.Drivers", function() { + this.Ping = (function(klass) { + subclass(Ping, klass); + + function Ping() { + _ref = Ping.__super__.constructor.apply(this, arguments); + return _ref; + } + + Ping.prototype.commands = function() { + return ['ping']; + }; + + Ping.prototype.ping = function() { + return "pong"; + }; + + return Ping; + + })(Cylon.Driver); +}); diff --git a/lib/test/test-adaptor.js b/lib/test/test-adaptor.js new file mode 100644 index 0000000..9f88285 --- /dev/null +++ b/lib/test/test-adaptor.js @@ -0,0 +1,33 @@ +/* + * Test adaptor + * cylonjs.com + * + * Copyright (c) 2013-2014 The Hybrid Group + * Licensed under the Apache 2.0 license. +*/ + +"use strict"; + +var namespace = require('node-namespace'); + +module.exports = { + adaptor: function(opts) { + return new Cylon.Adaptors.TestAdaptor(opts); + } +}; + +namespace("Cylon.Adaptors", function() { + this.TestAdaptor = (function(klass) { + subclass(TestAdaptor, klass); + + function TestAdaptor(opts) { + if (opts == null) { + opts = {}; + } + TestAdaptor.__super__.constructor.apply(this, arguments); + } + + return TestAdaptor; + + })(Cylon.Adaptor); +}); diff --git a/dist/test/test-driver.js b/lib/test/test-driver.js similarity index 100% rename from dist/test/test-driver.js rename to lib/test/test-driver.js diff --git a/dist/utils.js b/lib/utils.js similarity index 100% rename from dist/utils.js rename to lib/utils.js diff --git a/test/dist/specs/adaptor.spec.js b/test/specs/adaptor.spec.js similarity index 100% rename from test/dist/specs/adaptor.spec.js rename to test/specs/adaptor.spec.js diff --git a/test/dist/specs/basestar.spec.js b/test/specs/basestar.spec.js similarity index 100% rename from test/dist/specs/basestar.spec.js rename to test/specs/basestar.spec.js diff --git a/test/dist/specs/connection.spec.js b/test/specs/connection.spec.js similarity index 100% rename from test/dist/specs/connection.spec.js rename to test/specs/connection.spec.js diff --git a/test/dist/specs/cylon.spec.js b/test/specs/cylon.spec.js similarity index 100% rename from test/dist/specs/cylon.spec.js rename to test/specs/cylon.spec.js diff --git a/test/dist/specs/device.spec.js b/test/specs/device.spec.js similarity index 100% rename from test/dist/specs/device.spec.js rename to test/specs/device.spec.js diff --git a/test/dist/specs/digital-pin.spec.js b/test/specs/digital-pin.spec.js similarity index 100% rename from test/dist/specs/digital-pin.spec.js rename to test/specs/digital-pin.spec.js diff --git a/test/dist/specs/driver.spec.js b/test/specs/driver.spec.js similarity index 100% rename from test/dist/specs/driver.spec.js rename to test/specs/driver.spec.js diff --git a/test/dist/specs/logger.spec.js b/test/specs/logger.spec.js similarity index 100% rename from test/dist/specs/logger.spec.js rename to test/specs/logger.spec.js diff --git a/test/dist/specs/port.spec.js b/test/specs/port.spec.js similarity index 100% rename from test/dist/specs/port.spec.js rename to test/specs/port.spec.js diff --git a/test/dist/specs/robot.spec.js b/test/specs/robot.spec.js similarity index 100% rename from test/dist/specs/robot.spec.js rename to test/specs/robot.spec.js diff --git a/test/dist/specs/utils.spec.js b/test/specs/utils.spec.js similarity index 100% rename from test/dist/specs/utils.spec.js rename to test/specs/utils.spec.js