goodguide-gibbon 0.11.7 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b87fbbaef96ba223caea6829637a4c7ab6daba5
4
- data.tar.gz: 4ed0b5550c8c267f29e81f2a7adfa9f43ab092d5
3
+ metadata.gz: dd0051c5ce366bc971e7da78cbbabbf1cd910ca0
4
+ data.tar.gz: 1d7e31d0f072cebd2c9fcfd0b1be31208a528d93
5
5
  SHA512:
6
- metadata.gz: 08fdfed3ab060c75e60be231ba3a508a5a7293f772471015882789636bf4c77b2e4931b06a792045d6ee38ba4a143824b85564ea51ab75a192454a8607343064
7
- data.tar.gz: 8c0da5fc5e7d391895b21da974bc95321d1a3ce309afa5503b8c646b1f0a640bee5c0eee10ff95ebb2ceec204ffc9c96416c502e52d7dfcc7e3db882a3323548
6
+ metadata.gz: 7d04d1bb9f9d3d442da46da10f250c323c69547e2d42f2809293c2b0a9242b302979810ac6f4084d06f60742f77e7f07cb66b6b70977fb9ccb7e6372b685d5b8
7
+ data.tar.gz: 13d9885e4c1bd39a1a334a1858cdf487b04622d09809121cfaccbe26d5575683d0f882690abe1acd74465a5dbe3ddeb4e46646f48191b62957621c6935049261
@@ -172,21 +172,30 @@ module GoodGuide
172
172
  end
173
173
  end
174
174
 
175
- class QueryError < StandardError; end
175
+ class GibbonError < StandardError
176
+ def to_js(gibbon)
177
+ raise "abstract"
178
+ end
179
+ end
180
+
181
+ class StaticError < GibbonError
182
+ def to_js(*)
183
+ message
184
+ end
185
+ end
186
+
187
+ class RuntimeError < GibbonError
188
+ end
176
189
 
177
- class RuntimeError < StandardError; end
178
190
  class MissingData < RuntimeError
179
191
  attr_reader :query_type, :id, :annotations
192
+ attr_accessor :annotations
180
193
  def initialize(type, id, annotations)
181
194
  @query_type, @id, @annotations = type, id, annotations
182
195
  end
183
196
 
184
- def equals(other)
185
- [
186
- query_type == other.query_type,
187
- id == other.id,
188
- annotations == other.annotations
189
- ].all?
197
+ def to_js(gibbon)
198
+ gibbon['Failure'].query(@id, @annotations)
190
199
  end
191
200
 
192
201
  def as_json(*)
@@ -199,16 +208,21 @@ module GoodGuide
199
208
  end
200
209
  end
201
210
 
202
- class Failure < RuntimeError
211
+ class QueryError < RuntimeError
203
212
  attr_reader :message
204
213
  def initialize(message)
205
214
  @message = message
206
215
  end
207
216
 
217
+ def to_js(gibbon)
218
+ gibbon['Failure'].message(@message)
219
+ end
220
+
208
221
  def as_json(*)
209
222
  {
210
223
  'status' => 'failure',
211
224
  'message' => message,
225
+ 'annotations' => annotations
212
226
  }
213
227
  end
214
228
  end
@@ -221,7 +235,7 @@ module GoodGuide
221
235
  context = info[:context] || Context.new
222
236
 
223
237
  syntax = context.parse(source)
224
- semantics, errors = context.analyze(syntax, global, client.to_js)
238
+ errors, semantics = context.analyze(syntax, global, client.to_js(context.gibbon))
225
239
 
226
240
  raise SemanticError.new(errors, context) if errors
227
241
 
@@ -264,16 +278,7 @@ module GoodGuide
264
278
  end
265
279
 
266
280
  def call(runtime_client, entity_id)
267
- values, error = @context.run_compiled(@compiled, entity_id, runtime_client.to_js)
268
-
269
- case error
270
- when String
271
- raise GoodGuide::Gibbon::Failure.new(error)
272
- when nil
273
- values
274
- else
275
- raise error
276
- end
281
+ @context.run_compiled(@compiled, entity_id, runtime_client.to_js(@context.gibbon))
277
282
  end
278
283
  end
279
284
 
@@ -286,7 +291,7 @@ module GoodGuide
286
291
  queries[type.to_s] = impl
287
292
  end
288
293
 
289
- def to_js
294
+ def to_js(gibbon)
290
295
  raise 'abstract'
291
296
  end
292
297
 
@@ -295,15 +300,15 @@ module GoodGuide
295
300
  self.class.queries[type.to_s]
296
301
  end
297
302
 
298
- def proc_for(method)
299
- lambda do |this, *args|
300
- args = ([this] + args).compact if defined?(JRUBY_VERSION)
303
+ def proc_for(gibbon, method)
304
+ lambda do |*args|
305
+ args.shift unless defined?(JRUBY_VERSION)
301
306
 
302
307
  cb = args.pop
303
308
  err, val = begin
304
309
  [nil, send(method, *args)]
305
- rescue QueryError, RuntimeError => e
306
- [e, nil]
310
+ rescue GibbonError => e
311
+ [e.to_js(gibbon), nil]
307
312
  end
308
313
 
309
314
  cb.call(err, val)
@@ -315,7 +320,7 @@ module GoodGuide
315
320
  include Util
316
321
 
317
322
  def query_error!(*a)
318
- raise QueryError.new(*a)
323
+ raise StaticError.new(*a)
319
324
  end
320
325
 
321
326
  def self.query(type, opts={}, &impl)
@@ -339,8 +344,8 @@ module GoodGuide
339
344
  analysis
340
345
  end
341
346
 
342
- def to_js
343
- { :analyzeQuery => proc_for(:analyze_query) }
347
+ def to_js(gibbon)
348
+ { :analyzeQuery => proc_for(gibbon, :analyze_query) }
344
349
  end
345
350
  end
346
351
 
@@ -348,7 +353,6 @@ module GoodGuide
348
353
  include Util
349
354
  def perform_query(id, annotations)
350
355
  annotations = obj_to_ruby(annotations)
351
-
352
356
  query_type = annotations.delete('_query_type')
353
357
 
354
358
  # stash this data in case missing_data! is called
@@ -364,8 +368,8 @@ module GoodGuide
364
368
  raise MissingData.new(@last_query_type, @last_id, @last_annotations)
365
369
  end
366
370
 
367
- def to_js
368
- { :performQuery => proc_for(:perform_query) }
371
+ def to_js(gibbon)
372
+ { :performQuery => proc_for(gibbon, :perform_query) }
369
373
  end
370
374
  end
371
375
 
@@ -401,17 +405,16 @@ module GoodGuide
401
405
  end
402
406
 
403
407
  def run_compiled(compiled, entity_id, runtime_client)
404
- values, error = capture do |&callback|
405
- compiled.run('/', entity_id, runtime_client, callback)
408
+ results, _ = capture do |&callback|
409
+ compiled.run(entity_id, runtime_client, callback)
406
410
  end
407
411
 
408
- [hash_to_ruby(values), obj_to_ruby(error)]
412
+ obj_to_ruby(results)
409
413
  end
410
414
 
411
415
  private
412
416
  def capture(&b)
413
- output = nil
414
- error = nil
417
+ callback_args = nil
415
418
  call_count = 0
416
419
 
417
420
  b.call do |*args|
@@ -421,17 +424,17 @@ module GoodGuide
421
424
  call_count += 1
422
425
 
423
426
  if call_count >= 2
424
- first = [error, output].inspect
427
+ first = callback_args.inspect
425
428
  second = args.inspect
426
429
  raise "gibbon: callback called twice with #{first} and #{second}"
427
430
  end
428
431
 
429
- error, output = args[0..1]
432
+ callback_args = args
430
433
  end
431
434
 
432
435
  raise "gibbon: callback never called" unless call_count >= 1
433
436
 
434
- [output, error]
437
+ callback_args
435
438
  end
436
439
  end
437
440
 
@@ -469,7 +469,7 @@ Parsimmon.Parser = P(function(_, _super, Parser) {
469
469
  return Parsimmon;
470
470
  })()
471
471
  // Generated by CoffeeScript 1.6.3
472
- var AST, CompiledCode, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, inspectNative, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
472
+ var AST, CompiledCode, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Result, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, inspectNative, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
473
473
  __slice = [].slice,
474
474
  __hasProp = {}.hasOwnProperty,
475
475
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
@@ -1229,7 +1229,7 @@ parse = Gibbon.parse = (function() {
1229
1229
  string = Parsimmon.string, regex = Parsimmon.regex, succeed = Parsimmon.succeed, fail = Parsimmon.fail;
1230
1230
  seq = Parsimmon.seq, lazy = Parsimmon.lazy;
1231
1231
  whitespace = regex(/^[ \t]*/);
1232
- blankLines = regex(/^[\n\s]+/);
1232
+ blankLines = regex(/^[\n;\s]+/);
1233
1233
  comment = regex(/^#.*?(\n|$)/);
1234
1234
  lines = (blankLines.or(comment)).many();
1235
1235
  lexeme = function(p) {
@@ -2634,7 +2634,7 @@ analyze = Gibbon.analyze = (function() {
2634
2634
  })();
2635
2635
 
2636
2636
  eval_ = Gibbon["eval"] = function(semantics, table, id, client, finish) {
2637
- return Gibbon.compile(semantics).run('/', id, client, finish);
2637
+ return Gibbon.compile(semantics).run(id, client, finish);
2638
2638
  };
2639
2639
 
2640
2640
  Gibbon.Core = Core = (function(_super) {
@@ -5875,7 +5875,7 @@ stdlib = Gibbon.stdlib = (function() {
5875
5875
  first: {
5876
5876
  type: parse.type('first = [%a] -> %a'),
5877
5877
  compile: function(list) {
5878
- return list.delist(ZERO);
5878
+ return Core.len(list).op2('===', ZERO).branch(Core.fail('first: empty list'), list.delist(ZERO));
5879
5879
  }
5880
5880
  },
5881
5881
  left: {
@@ -6205,7 +6205,7 @@ Gibbon.Dependency = Dependency = (function(_super) {
6205
6205
  Dependency.variants({
6206
6206
  query: ['entity', 'query', 'value'],
6207
6207
  lexical: ['key'],
6208
- failure: ['failure']
6208
+ failure: ['entity', 'query']
6209
6209
  });
6210
6210
 
6211
6211
  Dependency.prototype.equals = function(other) {
@@ -6234,13 +6234,13 @@ Gibbon.Dependency = Dependency = (function(_super) {
6234
6234
  Dependency.prototype.inspect = function() {
6235
6235
  return this.cases({
6236
6236
  query: function(entity, query) {
6237
- return "" + (JSON.stringify(query)) + "<" + entity + ">";
6237
+ return "(query " + entity + ":" + (JSON.stringify(query)) + ")";
6238
6238
  },
6239
6239
  lexical: function(key) {
6240
- return "@" + key;
6240
+ return "(lexical " + key + ")";
6241
6241
  },
6242
- failure: function(failure) {
6243
- return "!";
6242
+ failure: function(entity, query) {
6243
+ return "(failure " + entity + " " + (JSON.stringify(query)) + ")";
6244
6244
  }
6245
6245
  });
6246
6246
  };
@@ -6296,6 +6296,23 @@ Gibbon.Failure = Failure = (function(_super) {
6296
6296
 
6297
6297
  })(Variant);
6298
6298
 
6299
+ Gibbon.Result = Result = (function(_super) {
6300
+ __extends(Result, _super);
6301
+
6302
+ function Result() {
6303
+ _ref18 = Result.__super__.constructor.apply(this, arguments);
6304
+ return _ref18;
6305
+ }
6306
+
6307
+ Result.variants({
6308
+ success: ['dependencies', 'value'],
6309
+ failure: ['dependencies', 'failure']
6310
+ });
6311
+
6312
+ return Result;
6313
+
6314
+ })(Variant);
6315
+
6299
6316
  Gibbon.CompiledCode = CompiledCode = (function() {
6300
6317
  var idFor, trampoline;
6301
6318
 
@@ -6323,35 +6340,45 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6323
6340
  }
6324
6341
 
6325
6342
  CompiledCode.prototype.functionFor = function(key) {
6326
- return this.functions.get(key);
6343
+ return this.functions.get(key) || (function() {
6344
+ throw "no such key " + key;
6345
+ })();
6327
6346
  };
6328
6347
 
6329
- CompiledCode.prototype.run = function(rootKey, input, client, cb) {
6330
- var FAIL, RETURN, dependencies, failures, mkQuery, results, runKey, thunk,
6348
+ CompiledCode.prototype.run = function(input, client, resultCallback) {
6349
+ var dependencies, failures, mapper, mkQuery, results, runKey,
6331
6350
  _this = this;
6332
6351
  results = new Hash;
6333
6352
  dependencies = new Hash;
6334
6353
  failures = new Hash;
6335
6354
  runKey = function(key, fail, succeed) {
6336
6355
  var deps, onFailure, onSuccess, query;
6337
- DEBUG.log('evaluating key', key);
6338
6356
  if (results.has(key)) {
6357
+ DEBUG.log("" + key + ": cached success");
6339
6358
  return succeed(results.get(key));
6340
6359
  }
6341
6360
  if (failures.has(key)) {
6361
+ DEBUG.log("" + key + ": cached failure");
6342
6362
  return fail(failures.get(key));
6343
6363
  }
6364
+ DEBUG.log("" + key + ": starting eval");
6344
6365
  deps = dependencies.set(key, []);
6345
6366
  query = mkQuery(function(d) {
6367
+ DEBUG.log("" + key + ": depends: " + (d.inspect()));
6346
6368
  return deps.push(d);
6347
6369
  });
6348
6370
  onSuccess = function(data) {
6371
+ DEBUG.log("" + key + ": success: " + (JSON.stringify(data)));
6349
6372
  results.set(key, data);
6350
6373
  return succeed(data);
6351
6374
  };
6352
6375
  onFailure = function(err) {
6376
+ if (typeof err === 'string') {
6377
+ err = Failure.message(err);
6378
+ }
6379
+ DEBUG.log("" + key + ": failure: " + (JSON.stringify(err)));
6353
6380
  failures.set(key, err);
6354
- return fail(err);
6381
+ return fail(err, dependencies);
6355
6382
  };
6356
6383
  return _this.functionFor(key)(input, query, onFailure, onSuccess);
6357
6384
  };
@@ -6367,7 +6394,7 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6367
6394
  out = client.performQuery(id, annotations, function(err, data) {
6368
6395
  var publicValue;
6369
6396
  if (err) {
6370
- pushDep(Dependency.failure(err));
6397
+ pushDep(Dependency.failure(id, annotations));
6371
6398
  if (isSynchronous) {
6372
6399
  return function() {
6373
6400
  return onFailure(err);
@@ -6391,13 +6418,10 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6391
6418
  return out;
6392
6419
  };
6393
6420
  };
6394
- FAIL = function(f) {
6395
- return cb(f);
6396
- };
6397
- RETURN = function(d) {
6398
- return cb(null, d);
6421
+ mapper = function(key, cb) {
6422
+ return trampoline(runKey(key, cb, cb));
6399
6423
  };
6400
- thunk = runKey(rootKey, cb, function() {
6424
+ return contMap(this.semantics.keys(), mapper, function() {
6401
6425
  var out;
6402
6426
  out = new Hash;
6403
6427
  results.each(function(k, v) {
@@ -6407,7 +6431,7 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6407
6431
  deps = uniq(deps, function(x, y) {
6408
6432
  return x.equals(y);
6409
6433
  });
6410
- return out.set(k, [value, deps]);
6434
+ return out.set(k, Result.success(deps, value));
6411
6435
  });
6412
6436
  failures.each(function(k, v) {
6413
6437
  var deps;
@@ -6415,11 +6439,10 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6415
6439
  deps = uniq(deps, function(x, y) {
6416
6440
  return x.equals(y);
6417
6441
  });
6418
- return out.set(k, [v, deps]);
6442
+ return out.set(k, Result.failure(deps, v));
6419
6443
  });
6420
- return cb(null, out);
6444
+ return resultCallback(out);
6421
6445
  });
6422
- return trampoline(thunk);
6423
6446
  };
6424
6447
 
6425
6448
  CompiledCode.prototype.outputType = function(key) {
@@ -469,7 +469,7 @@ Parsimmon.Parser = P(function(_, _super, Parser) {
469
469
  return Parsimmon;
470
470
  })()
471
471
  // Generated by CoffeeScript 1.6.3
472
- var AST, CompiledCode, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, inspectNative, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
472
+ var AST, CompiledCode, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Result, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, inspectNative, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
473
473
  __slice = [].slice,
474
474
  __hasProp = {}.hasOwnProperty,
475
475
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
@@ -1219,7 +1219,7 @@ parse = Gibbon.parse = (function() {
1219
1219
  string = Parsimmon.string, regex = Parsimmon.regex, succeed = Parsimmon.succeed, fail = Parsimmon.fail;
1220
1220
  seq = Parsimmon.seq, lazy = Parsimmon.lazy;
1221
1221
  whitespace = regex(/^[ \t]*/);
1222
- blankLines = regex(/^[\n\s]+/);
1222
+ blankLines = regex(/^[\n;\s]+/);
1223
1223
  comment = regex(/^#.*?(\n|$)/);
1224
1224
  lines = (blankLines.or(comment)).many();
1225
1225
  lexeme = function(p) {
@@ -2602,7 +2602,7 @@ analyze = Gibbon.analyze = (function() {
2602
2602
  })();
2603
2603
 
2604
2604
  eval_ = Gibbon["eval"] = function(semantics, table, id, client, finish) {
2605
- return Gibbon.compile(semantics).run('/', id, client, finish);
2605
+ return Gibbon.compile(semantics).run(id, client, finish);
2606
2606
  };
2607
2607
 
2608
2608
  Gibbon.Core = Core = (function(_super) {
@@ -5812,7 +5812,7 @@ stdlib = Gibbon.stdlib = (function() {
5812
5812
  first: {
5813
5813
  type: parse.type('first = [%a] -> %a'),
5814
5814
  compile: function(list) {
5815
- return list.delist(ZERO);
5815
+ return Core.len(list).op2('===', ZERO).branch(Core.fail('first: empty list'), list.delist(ZERO));
5816
5816
  }
5817
5817
  },
5818
5818
  left: {
@@ -6142,7 +6142,7 @@ Gibbon.Dependency = Dependency = (function(_super) {
6142
6142
  Dependency.variants({
6143
6143
  query: ['entity', 'query', 'value'],
6144
6144
  lexical: ['key'],
6145
- failure: ['failure']
6145
+ failure: ['entity', 'query']
6146
6146
  });
6147
6147
 
6148
6148
  Dependency.prototype.equals = function(other) {
@@ -6171,13 +6171,13 @@ Gibbon.Dependency = Dependency = (function(_super) {
6171
6171
  Dependency.prototype.inspect = function() {
6172
6172
  return this.cases({
6173
6173
  query: function(entity, query) {
6174
- return "" + (JSON.stringify(query)) + "<" + entity + ">";
6174
+ return "(query " + entity + ":" + (JSON.stringify(query)) + ")";
6175
6175
  },
6176
6176
  lexical: function(key) {
6177
- return "@" + key;
6177
+ return "(lexical " + key + ")";
6178
6178
  },
6179
- failure: function(failure) {
6180
- return "!";
6179
+ failure: function(entity, query) {
6180
+ return "(failure " + entity + " " + (JSON.stringify(query)) + ")";
6181
6181
  }
6182
6182
  });
6183
6183
  };
@@ -6233,6 +6233,23 @@ Gibbon.Failure = Failure = (function(_super) {
6233
6233
 
6234
6234
  })(Variant);
6235
6235
 
6236
+ Gibbon.Result = Result = (function(_super) {
6237
+ __extends(Result, _super);
6238
+
6239
+ function Result() {
6240
+ _ref18 = Result.__super__.constructor.apply(this, arguments);
6241
+ return _ref18;
6242
+ }
6243
+
6244
+ Result.variants({
6245
+ success: ['dependencies', 'value'],
6246
+ failure: ['dependencies', 'failure']
6247
+ });
6248
+
6249
+ return Result;
6250
+
6251
+ })(Variant);
6252
+
6236
6253
  Gibbon.CompiledCode = CompiledCode = (function() {
6237
6254
  var idFor, trampoline;
6238
6255
 
@@ -6260,35 +6277,45 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6260
6277
  }
6261
6278
 
6262
6279
  CompiledCode.prototype.functionFor = function(key) {
6263
- return this.functions.get(key);
6280
+ return this.functions.get(key) || (function() {
6281
+ throw "no such key " + key;
6282
+ })();
6264
6283
  };
6265
6284
 
6266
- CompiledCode.prototype.run = function(rootKey, input, client, cb) {
6267
- var FAIL, RETURN, dependencies, failures, mkQuery, results, runKey, thunk,
6285
+ CompiledCode.prototype.run = function(input, client, resultCallback) {
6286
+ var dependencies, failures, mapper, mkQuery, results, runKey,
6268
6287
  _this = this;
6269
6288
  results = new Hash;
6270
6289
  dependencies = new Hash;
6271
6290
  failures = new Hash;
6272
6291
  runKey = function(key, fail, succeed) {
6273
6292
  var deps, onFailure, onSuccess, query;
6274
-
6275
6293
  if (results.has(key)) {
6294
+
6276
6295
  return succeed(results.get(key));
6277
6296
  }
6278
6297
  if (failures.has(key)) {
6298
+
6279
6299
  return fail(failures.get(key));
6280
6300
  }
6301
+
6281
6302
  deps = dependencies.set(key, []);
6282
6303
  query = mkQuery(function(d) {
6304
+
6283
6305
  return deps.push(d);
6284
6306
  });
6285
6307
  onSuccess = function(data) {
6308
+
6286
6309
  results.set(key, data);
6287
6310
  return succeed(data);
6288
6311
  };
6289
6312
  onFailure = function(err) {
6313
+ if (typeof err === 'string') {
6314
+ err = Failure.message(err);
6315
+ }
6316
+
6290
6317
  failures.set(key, err);
6291
- return fail(err);
6318
+ return fail(err, dependencies);
6292
6319
  };
6293
6320
  return _this.functionFor(key)(input, query, onFailure, onSuccess);
6294
6321
  };
@@ -6304,7 +6331,7 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6304
6331
  out = client.performQuery(id, annotations, function(err, data) {
6305
6332
  var publicValue;
6306
6333
  if (err) {
6307
- pushDep(Dependency.failure(err));
6334
+ pushDep(Dependency.failure(id, annotations));
6308
6335
  if (isSynchronous) {
6309
6336
  return function() {
6310
6337
  return onFailure(err);
@@ -6328,13 +6355,10 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6328
6355
  return out;
6329
6356
  };
6330
6357
  };
6331
- FAIL = function(f) {
6332
- return cb(f);
6333
- };
6334
- RETURN = function(d) {
6335
- return cb(null, d);
6358
+ mapper = function(key, cb) {
6359
+ return trampoline(runKey(key, cb, cb));
6336
6360
  };
6337
- thunk = runKey(rootKey, cb, function() {
6361
+ return contMap(this.semantics.keys(), mapper, function() {
6338
6362
  var out;
6339
6363
  out = new Hash;
6340
6364
  results.each(function(k, v) {
@@ -6344,7 +6368,7 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6344
6368
  deps = uniq(deps, function(x, y) {
6345
6369
  return x.equals(y);
6346
6370
  });
6347
- return out.set(k, [value, deps]);
6371
+ return out.set(k, Result.success(deps, value));
6348
6372
  });
6349
6373
  failures.each(function(k, v) {
6350
6374
  var deps;
@@ -6352,11 +6376,10 @@ Gibbon.CompiledCode = CompiledCode = (function() {
6352
6376
  deps = uniq(deps, function(x, y) {
6353
6377
  return x.equals(y);
6354
6378
  });
6355
- return out.set(k, [v, deps]);
6379
+ return out.set(k, Result.failure(deps, v));
6356
6380
  });
6357
- return cb(null, out);
6381
+ return resultCallback(out);
6358
6382
  });
6359
- return trampoline(thunk);
6360
6383
  };
6361
6384
 
6362
6385
  CompiledCode.prototype.outputType = function(key) {
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "gibbon",
3
- "version": "0.11.7",
3
+ "version": "0.12.0",
4
4
  "description": "A data language",
5
5
  "keywords": ["language"],
6
- "author": "Jay Adkisson <jjmadkisson at gmail dot com>",
6
+ "author": "Jeanine Adkisson <jjmadkisson at gmail dot com>",
7
7
  "repository": "git://github.com/GoodGuide/gibbon",
8
8
 
9
9
  "files": ["index.js", "src", "test", "Makefile", "package.json"],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodguide-gibbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.7
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-15 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Run and analyze gibbon code from ruby or a browser (via a ruby app).
14
14
  email: