gist access through SuperCollider


27 July 2011

To research possibilities for a public Synthdef repository a la openprocessing.org, I did some research into the gist API and its use in SuperCollider. Below, you find the resulting code plus an updated version of wslib’s curl method in case you want to share the experience or even add a POST example / parsing method for json strings / tag search example.

Demands

An outline of demands for a web-based platform can be found in this gist:

You’re invited to fork your modifications and I’ll integrate them after discussion over at the list.

Implementation

Implementation currently is threefold; curl interface to gist (based on code by wslib; thanx!), a json parser, and a gist interface to retrieve gists as dictionaries.

This is the updated String:curl method stack:

+ String {
	curlMsg { |path, options|
		var expr;

		expr = "curl % %".format( options ? "", this.quote );
		path.notNil.if{
			expr = expr + "-o %".format(path.quote);
		};

		^expr;
	}
	
	curl { |path, options, action, postOutput = true|
		var msg = this.curlMsg(path, options);
		
		path.notNil.if({
			^msg.unixCmd(action, postOutput);
		}, {
			^msg.unixCmdGetStdOut;
		})
	}
}