Also removes the find{Robot,RobotConnection,RobotDevice} methods. Additionally,
stops passing the Master through to the Robot constructor, we can just
require('./cylon') if we need to access anything in there.
This commit reframes the Utils module to be more self-contained, and now only
the Number prototype methods and the every/after/constantly methods are exposed
globally.
I'm unsure about whether these methods can be more scoped such that people can
turn them off if they want, but that's potentially something to look into in the
future.
This commit also updates most of the other source files in Cylon, requiring the
Utils module rather than assuming the methods are in the global namespace.
A similar batch of commits will need to be made for all other Cylon modules to
make sure they don't explode when they can't find #subclass or something like
that.
To make the previously-global methods available, both in submodules and for
people looking for them, all the utility functions are exported in Cylon.Utils.
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.
Acts exactly the same with much, much less code complexity.
This also introduces a pattern for providing core modules to external libraries.
Whereas previously Cylon modules were able to rely on Cylon.Adaptor or
Cylon.Driver being present in the namespace (due to being required in
./lib/cylon), they will now need to require Cylon first, like this:
var Cylon = require('cylon');
var Driver = Cylon.Driver,
Adaptor = Cylon.Adaptor,
DigitalPin = Cylon.IO.DigitalPin;
Expected configuration:
{
ssl: {
key: "/path/to/key",
cert: "/path/to/cert"
}
}
If ssl is false, use plain HTTP. If it's an empty object (the default)
use our self-signed certs. If it's set up like above, use the provided
certs.