WIP on device

This commit is contained in:
deadprogram 2013-10-22 13:13:55 -07:00
parent f2e90634c5
commit af4636598a
2 changed files with 15 additions and 7 deletions

View File

@ -9,10 +9,20 @@
'use strict'; 'use strict';
module.exports = class Device module.exports = class Device
constructor: (opts) -> constructor: (opts = {}) ->
@parent = opts.parent
@name = opts.name @name = opts.name
@driver = opts.driver @connection = @determineConnection(opts.connection) or @defaultConnection
@driver = @requireDriver(opts.driver)
start: -> start: ->
console.log "started" console.log "started"
determineConnection: (c) ->
@parent.connections(c) if c
defaultConnection: ->
@parent.connections.first
requireDriver: (driverName) ->
console.log "dynamic load driver"

View File

@ -8,7 +8,5 @@ describe "devices", ->
it "should have a name", -> it "should have a name", ->
device.name.should.be.equal 'devisive' device.name.should.be.equal 'devisive'
it "should have an driver", -> it "should have a connection"
device.driver.should.be.equal 'driving' it "should have an driver"
it "should be able to require an external driver module"