pulse-node

Starts and manages an Ind.ie Pulse process. Includes configuration and API.

Installation

./install

Used in Heartbeat and Waystone.

Pulse Process

Create the process and use the passed homeDirectory:

Pulse = require 'pulse-node'

delegate =
    pulseProcessRestApiIsReady: ->
        // etc.
    // …Other delegate methods.

pulseProcess = new Pulse.Process(delegate, homeDirectory)
pulseProcess.start()

If homeDirectory is not provided, the data directory is used.

Generate a new Pulse configuration

pulseProcess = new Pulse.Process(delegate, homeDirectory)
pulseProcess.start(generate=true, name='Waystone')

This would create a new Pulse configuration and call the device ‘Waystone’.

Example

Pulse = require 'pulse-process'

class TestPulseProcess

    pulseProcess = null

    constructor: ->
        @pulseProcess = new Pulse.Process(this)
        @pulseProcess.start()

    pulseProcessRestApiIsReady: ->
        process.stdout.write '.'
        @stopTheProcess()

    pulseProcessFailedToStartProcess: (data) ->
        console.log 'Delegate: pulseProcessFailedToStartProcess error with data:'
        console.log data

    pulseProcessDidSendData: (data) ->
        process.stdout.write '.'

    pulseProcessDidSendErrorData: (data) ->
        console.log 'Delegate: pulseProcessDidSendErrorData with data:'
        console.log data

    pulseProcessDidExitWithCode: (code) ->
        process.stdout.write '.'
        console.log '\nSuccessfully connected to Pulse process and got confirmation of REST API readiness.'
        process.exit(0)

    stopTheProcess: ->
        @pulseProcess.stop()

testPulseProcess = new TestPulseProcess()

Pulse API

Usage

Pulse = require 'pulse-node'

pulseAPI = new Pulse.API('<YOUR_API_KEY_HERE>')

pulseAPI.version()
    .then (result) ->
        console.log 'Version: ' + result
    .catch (error) ->
        console.log 'Error while attempting to get version: ' + error

Tests

Credits

Copyright © 2014, 2015 Aral Balkan. Licensed under the ind.ie/license. Released with ❤ by ind.ie