All work and no play makes Jack a dull boy
Robots can now take a break and have #play functions instead of #work. Internally they're treated the same, but it's a fun easter egg! Example: Cylon.robot({ name: 'Jack', connections: [], devices: [], play: function play(my) { every((5).seconds(), function() { console.log("All work and no play makes %s a dull boy.", my.name); }); } }); I sincerely apologize for the repeated reference to The Shining, blame @deadprogram. Closes #189.
This commit is contained in:
parent
bc4a1f5cea
commit
a5241e57b5
|
@ -89,7 +89,9 @@ module.exports = Robot = function Robot(opts) {
|
|||
this.initConnections(opts.connection || opts.connections);
|
||||
this.initDevices(opts.device || opts.devices);
|
||||
|
||||
this.work = opts.work || function() { Logger.info("No work yet"); };
|
||||
this.work = opts.work || opts.play;
|
||||
|
||||
this.work || (this.work = function() { Logger.info("No work yet"); });
|
||||
|
||||
for (var n in opts) {
|
||||
var func = opts[n],
|
||||
|
|
|
@ -76,6 +76,18 @@ describe("Robot", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("all work and no play", function() {
|
||||
var play = spy();
|
||||
|
||||
var playBot = new Robot({
|
||||
play: play
|
||||
});
|
||||
|
||||
it('makes Jack a dull boy', function() {
|
||||
expect(playBot.work).to.be.eql(play);
|
||||
})
|
||||
})
|
||||
|
||||
describe("#data", function() {
|
||||
var bot = new Robot({
|
||||
connection: { name: 'loopback', adaptor: 'loopback' },
|
||||
|
|
Loading…
Reference in New Issue