Skip to content

Instantly share code, notes, and snippets.

@gotascii
Created September 14, 2011 13:35
Show Gist options
  • Save gotascii/1216556 to your computer and use it in GitHub Desktop.
Save gotascii/1216556 to your computer and use it in GitHub Desktop.
Node in Max/MSP
# Compile the coffee in bare joined mode.
{exec, spawn} = require 'child_process'
fs = require 'fs'
util = require 'util'
print = (data) ->
console.log data.trimRight()
task 'build', 'Compile Coffeescript to Javascript', ->
exec 'mkdir -p lib && coffee --bare --output lib --compile --join weird.js src/*.coffee'
task 'clean', 'Remove generated Javascripts', ->
exec 'rm -fr lib'
task 'test', 'Run the tests', ->
vows = exec "vows --spec test/*test*"
vows.stdout.on 'data', print
vows.stderr.on 'data', print
# test/helper.coffee
# Create globals for the classes under test.
global.util = require 'util'
global.assert = require 'assert'
require '../src/array'
global.World = require('../src/world').World
global.Inspector = require('../src/inspector').Inspector
global.Lseq = require('../src/lseq').Lseq
vows = require 'vows'
w = new World 16, 8
gw = new Global "world"
@bang = ->
post w.cells.length
# src/world.coffee
# Define classes as top level vars.
@World = class
constructor: (@lseq, @cells) ->
unless @cells?
@cells = @generateCells()
@reset()
generateCells: ->
len = @length() - 1
@lseq.toCoords(i) for i in [0..len]
# test/world_test.coffee
# Test the globals defined in helper.coffee.
require './helper'
test module, 'World',
'constructor with an lseq and no provided cells':
topic: ->
@lseq = new Lseq({x:0, y:0}, 2, 2)
@world = new World @lseq
'has an lseq': ->
@world.lseq.should eq @lseq
'has an array of cells with 0 state': ->
cells = [
{x: 0, y: 0, state: 0},
{x: 1, y: 0, state: 0},
{x: 0, y: 1, state: 0},
{x: 1, y: 1, state: 0}
]
@world.cells.should deq cells
@hems
Copy link

hems commented May 16, 2013

I talked to some c74 guys when i speak at http://code-control.com and showed them coffee script and talked about Node.

Lets see what they will do about it ( :

Hope they enjoyed the ideas, and pay me a beer after they get millionare

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment