Get a device by name.
elroy.get('joes-office-photosensor', function(err, photosensor) {
});| Feature: Root Resource | |
| As an API client | |
| I want to see the root resource | |
| So that I have a starting point to complete my task. | |
| Scenario: Request the root | |
| Given an anonymous client | |
| When I make a GET request to / | |
| Then I should get a 200 status code | |
| And the content type should be JSON |
| 0 info it worked if it ends with ok | |
| 1 verbose cli [ '/Users/kevin/nvm/v0.10.17/bin/node', | |
| 1 verbose cli '/Users/kevin/nvm/v0.10.17/bin/npm', | |
| 1 verbose cli 'publish' ] | |
| 2 info using npm@1.3.8 | |
| 3 info using node@v0.10.17 | |
| 4 verbose publish [ '.' ] | |
| 5 verbose cache add [ '.', null ] | |
| 6 verbose cache add name=undefined spec="." args=[".",null] | |
| 7 verbose parsed url { protocol: null, |
| var Scientist = require('../scientist'); | |
| var Nightlight = require('./nightlight'); | |
| var wrap = require('./elroy_promise'); | |
| var HelloApp = module.exports = function() { | |
| this.name = 'hello'; | |
| }; | |
| HelloApp.prototype.init = function(elroy) { | |
| elroy = wrap(elroy); |
| var Duplex = require('stream').Duplex; | |
| var util = require('util'); | |
| var FakeSocket = module.exports = function() { | |
| Duplex.call(this); | |
| this.source = new BufferSource(); | |
| this.on('finish', function() { | |
| this.source.state = 'ready'; |
| var Duplex = require('stream').Duplex; | |
| var util = require('util'); | |
| var BufferStream = module.exports = function() { | |
| Duplex.call(this); | |
| this.source = new BufferSource(); | |
| this.on('finish', function() { | |
| this.source.state = 'ready'; |
| /* | |
| +----------------------------------+ | |
| |S| MessageID (31bits) | | |
| +----------------------------------+ | |
| | Reserved (8) | Length (24 bits) | | |
| +----------------------------------+ | |
| | Data | | |
| +----------------------------------+ | |
| */ |
| var argo = require('argo'); | |
| argo() | |
| .use(function(handle) { | |
| handle('response', function(env, next) { | |
| env.response.setHeader('Access-Control-Allow-Origin', '*'); | |
| next(env); | |
| }); | |
| }) | |
| .use(function(handle) { |
| var HelloApp = module.exports = function() { | |
| this.name = 'hello'; | |
| }; | |
| HelloApp.prototype.init = function(elroy) { | |
| elroy.observe('type="led"') // set up an observer to grab LEDs | |
| .zip(elroy.observe('type="photosensor"')) // combine output with another observable | |
| .first() // only observe until the first pair is discovered | |
| .timeout(3000) // if the pair isn't discovered within 3 seconds, throw a timeout error | |
| .subscribe(function(err, devices) { // fires for each pair discovered. Because we called first(), this only happens once. |
| var Logger = require('./logger'); | |
| var Observable = module.exports = function(query, runtime) { | |
| this.query = query; | |
| this.runtime = runtime; | |
| this.registry = this.runtime.registry; | |
| this.logger = new Logger(); | |
| this.state = 'ready'; // disposed | |
| this.remainder = null; | |
| this.takePredicate = null; |