Merge pull request #69 from hybridgroup/generator-update
Generator updates
This commit is contained in:
commit
8956d2f55d
|
@ -50,6 +50,7 @@ var generateTemplateData = function() {
|
|||
return {
|
||||
adaptorName: cylonAdaptorName(),
|
||||
adaptorClassName: adaptorClassName(),
|
||||
basename: String(adaptorName).toLowerCase(),
|
||||
cylonVersion: pkg.version
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,18 +13,44 @@ sister project Gobot (http://gobot.io).
|
|||
For more information about Cylon, check out our repo at
|
||||
https://github.com/hybridgroup/cylon
|
||||
|
||||
## Installing
|
||||
## Getting Started
|
||||
|
||||
npm install <%= adaptorName %>
|
||||
Install the module with: `npm install <%= adaptorName %>`
|
||||
|
||||
## Using
|
||||
|
||||
```coffeescript
|
||||
# your example code here...
|
||||
```
|
||||
## Examples
|
||||
|
||||
## Connecting
|
||||
|
||||
### JavaScript
|
||||
|
||||
```javascript
|
||||
var Cylon = require('cylon');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: '<%= basename %>', adaptor: '<%= basename %>' },
|
||||
device: {name: '<%= basename %>', driver: '<%= basename %>'},
|
||||
|
||||
work: function(my) {
|
||||
// provide an example of your module here
|
||||
}
|
||||
}).start();
|
||||
```
|
||||
|
||||
### CoffeeScript
|
||||
|
||||
```
|
||||
Cylon = require 'cylon'
|
||||
|
||||
Cylon.robot
|
||||
connection: { name: '<%= basename %>', adaptor: '<%= basename %>' }
|
||||
device: { name: '<%= basename %>', driver: '<%= basename %>' }
|
||||
|
||||
work: (my) ->
|
||||
# provide an example of your module here
|
||||
|
||||
.start()
|
||||
```
|
||||
|
||||
Explain how to connect from the computer to the device here...
|
||||
|
||||
## Contributing
|
||||
|
@ -39,4 +65,4 @@ None yet...
|
|||
|
||||
## License
|
||||
|
||||
Copyright (c) 2013 Your Name Here. See `LICENSE` for more details
|
||||
Copyright (c) 2014 Your Name Here. See `LICENSE` for more details
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* <%= adaptorName %> adaptor
|
||||
* http://cylonjs.com
|
||||
*
|
||||
* Copyright (c) 2013-2014 Your Name Here
|
||||
* Licensed under the Apache 2.0 license.
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
var namespace,
|
||||
__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');
|
||||
|
||||
require('./<%= adaptorName %>');
|
||||
|
||||
require('./driver');
|
||||
|
||||
namespace('Cylon.Adaptors', function() {
|
||||
return this.<%= adaptorClassName %> = (function(_super) {
|
||||
__extends(<%= adaptorClassName %>, _super);
|
||||
|
||||
function <%= adaptorClassName %>(opts) {
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
<%= adaptorClassName %>.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
<%= adaptorClassName %>.prototype.connect = function(callback) {
|
||||
return <%= adaptorClassName %>.__super__.connect.apply(this, arguments);
|
||||
};
|
||||
|
||||
return <%= adaptorClassName %>;
|
||||
|
||||
})(Cylon.Adaptor);
|
||||
});
|
||||
|
||||
}).call(this);
|
|
@ -20,12 +20,20 @@
|
|||
adaptor: function() {
|
||||
var args;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
return function() {};
|
||||
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.<%= adaptorClassName %>, args, function(){});
|
||||
},
|
||||
driver: function() {
|
||||
var args;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
return function() {};
|
||||
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.<%= adaptorClassName %>, args, function(){});
|
||||
},
|
||||
register: function(robot) {}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* <%= adaptorName %> driver
|
||||
* http://cylonjs.com
|
||||
*
|
||||
* Copyright (c) 2013-2014 Your Name Here
|
||||
* Licensed under the Apache 2.0 license.
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
var namespace,
|
||||
__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; };
|
||||
|
||||
require('./<%= adaptorName %>');
|
||||
|
||||
require('./adaptor');
|
||||
|
||||
namespace = require('node-namespace');
|
||||
|
||||
namespace("Cylon.Drivers", function() {
|
||||
var _ref;
|
||||
return this.<%= adaptorClassName %> = (function(_super) {
|
||||
__extends(<%= adaptorClassName %>, _super);
|
||||
|
||||
function <%= adaptorClassName %>() {
|
||||
_ref = <%= adaptorClassName %>.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
}
|
||||
|
||||
<%= adaptorClassName %>.prototype.start = function(callback) {
|
||||
return <%= adaptorClassName %>.__super__.start.apply(this, arguments);
|
||||
};
|
||||
|
||||
return <%= adaptorClassName %>;
|
||||
|
||||
})(Cylon.Driver);
|
||||
});
|
||||
|
||||
}).call(this);
|
|
@ -0,0 +1,22 @@
|
|||
###
|
||||
* <%= adaptorName %> adaptor
|
||||
* http://cylonjs.com
|
||||
*
|
||||
* Copyright (c) 2013-2014 Your Name Here
|
||||
* Licensed under the Apache 2.0 license.
|
||||
###
|
||||
|
||||
"use strict"
|
||||
|
||||
namespace = require 'node-namespace'
|
||||
|
||||
require './<%= adaptorName %>'
|
||||
require './driver'
|
||||
|
||||
namespace 'Cylon.Adaptors', ->
|
||||
class @<%= adaptorClassName %> extends Cylon.Adaptor
|
||||
constructor: (opts = {}) ->
|
||||
super
|
||||
|
||||
connect: (callback) ->
|
||||
super
|
|
@ -18,14 +18,14 @@ module.exports =
|
|||
# the Sphero adaptor creates a new instance of the Sphero adaptor class:
|
||||
#
|
||||
# new Cylon.Adaptors.Sphero(args...)
|
||||
return ->
|
||||
new Cylon.Adaptors.<%= adaptorClassName %>(args...)
|
||||
|
||||
driver: (args...) ->
|
||||
# Provide a function that's an instance of your driver here. For example,
|
||||
# the Sphero adaptor creates a new instance of the Sphero driver class:
|
||||
#
|
||||
# new Cylon.Drivers.Sphero(args...)
|
||||
return ->
|
||||
new Cylon.Drivers.<%= adaptorClassName %>(args...)
|
||||
|
||||
register: (robot) ->
|
||||
# Bootstrap your adaptor here. For example, with a Sphero, you would call
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
###
|
||||
* <%= adaptorName %> driver
|
||||
* http://cylonjs.com
|
||||
*
|
||||
* Copyright (c) 2013-2014 Your Name Here
|
||||
* Licensed under the Apache 2.0 license.
|
||||
###
|
||||
|
||||
'use strict'
|
||||
|
||||
require './<%= adaptorName %>'
|
||||
require './adaptor'
|
||||
|
||||
namespace = require 'node-namespace'
|
||||
|
||||
namespace "Cylon.Drivers", ->
|
||||
class @<%= adaptorClassName %> extends Cylon.Driver
|
||||
start: (callback) ->
|
||||
super
|
|
@ -0,0 +1,13 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
var adaptor;
|
||||
|
||||
adaptor = source("adaptor");
|
||||
|
||||
describe("Cylon.Adaptors.<%= adaptorClassName %>", function() {
|
||||
var module;
|
||||
module = new Cylon.Adaptors.<%= adaptorClassName %>;
|
||||
return it("needs tests");
|
||||
});
|
||||
|
||||
}).call(this);
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
module = source("<%= adaptorName %>");
|
||||
|
||||
describe("basic tests", function() {
|
||||
describe("Cylon.<%= adaptorClassName %>", function() {
|
||||
it("standard async test", function(done) {
|
||||
var bool;
|
||||
bool = false;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
var driver;
|
||||
|
||||
driver = source("driver");
|
||||
|
||||
describe("Cylon.Drivers.<%= adaptorClassName %>", function() {
|
||||
var module;
|
||||
module = new Cylon.Drivers.<%= adaptorClassName %>({
|
||||
device: {
|
||||
connection: 'connect'
|
||||
}
|
||||
});
|
||||
return it("needs tests");
|
||||
});
|
||||
|
||||
}).call(this);
|
|
@ -0,0 +1,8 @@
|
|||
'use strict'
|
||||
|
||||
adaptor = source("adaptor")
|
||||
|
||||
describe "Cylon.Adaptors.<%= adaptorClassName %>", ->
|
||||
module = new Cylon.Adaptors.<%= adaptorClassName %>
|
||||
|
||||
it "needs tests"
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module = source "<%= adaptorName %>"
|
||||
|
||||
describe "<%= adaptorName %>", ->
|
||||
describe "Cylon.<%= adaptorClassName %>", ->
|
||||
it "standard async test", (done) ->
|
||||
bool = false
|
||||
bool.should.be.false
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
'use strict'
|
||||
|
||||
driver = source("driver")
|
||||
|
||||
describe "Cylon.Drivers.<%= adaptorClassName %>", ->
|
||||
module = new Cylon.Drivers.<%= adaptorClassName %>
|
||||
device: { connection: 'connect' }
|
||||
|
||||
it "needs tests"
|
Loading…
Reference in New Issue