From af4636598aabcaa225878276ad29cbdfa22b97fe Mon Sep 17 00:00:00 2001 From: deadprogram Date: Tue, 22 Oct 2013 13:13:55 -0700 Subject: [PATCH] WIP on device --- src/device.coffee | 16 +++++++++++++--- test/src/specs/device.spec.coffee | 6 ++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/device.coffee b/src/device.coffee index ba4a1e0..5b2ccd7 100644 --- a/src/device.coffee +++ b/src/device.coffee @@ -9,10 +9,20 @@ 'use strict'; module.exports = class Device - constructor: (opts) -> + constructor: (opts = {}) -> + @parent = opts.parent @name = opts.name - @driver = opts.driver + @connection = @determineConnection(opts.connection) or @defaultConnection + @driver = @requireDriver(opts.driver) start: -> console.log "started" - \ No newline at end of file + + determineConnection: (c) -> + @parent.connections(c) if c + + defaultConnection: -> + @parent.connections.first + + requireDriver: (driverName) -> + console.log "dynamic load driver" diff --git a/test/src/specs/device.spec.coffee b/test/src/specs/device.spec.coffee index 1e23abe..7315041 100644 --- a/test/src/specs/device.spec.coffee +++ b/test/src/specs/device.spec.coffee @@ -8,7 +8,5 @@ describe "devices", -> it "should have a name", -> device.name.should.be.equal 'devisive' - it "should have an driver", -> - device.driver.should.be.equal 'driving' - - it "should be able to require an external driver module" + it "should have a connection" + it "should have an driver"