goodguide-gibbon 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/goodguide/gibbon.rb +37 -33
- data/vendor/gibbon/gibbon.browser.dev.js +641 -580
- data/vendor/gibbon/gibbon.browser.js +623 -563
- data/vendor/gibbon/package.json +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8b34db5c0525825c475f7d18109f8ffc5518e53
|
4
|
+
data.tar.gz: 9db9f664a974da99e90ad45855d9d42b91656a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 271a7ede66936d1e02e5eaf6852f8c78948fc4b989d6c4bc377ee1c34bde960ccbb16253db765e8e51595c1434639d0c1392181df31a137f05d6ca6ee55ef683
|
7
|
+
data.tar.gz: bf95e7975d0abec0c15131733ec04a38471f7c05d505d2aac0631081f774c65601d9efee3dd8de2f6d4caa26c87252c0033ce482e1ae4f332f0849f63d1533a0
|
data/lib/goodguide/gibbon.rb
CHANGED
@@ -173,6 +173,17 @@ module GoodGuide
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
+
class ParseError < SemanticError
|
177
|
+
attr_reader :message
|
178
|
+
def initialize(message)
|
179
|
+
@message = message.to_s
|
180
|
+
end
|
181
|
+
|
182
|
+
def messages
|
183
|
+
[message]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
176
187
|
class GibbonError < StandardError
|
177
188
|
def to_js(gibbon)
|
178
189
|
raise "abstract"
|
@@ -351,7 +362,17 @@ module GoodGuide
|
|
351
362
|
end
|
352
363
|
|
353
364
|
def to_js(gibbon)
|
354
|
-
|
365
|
+
analyze_proc = proc do |*args|
|
366
|
+
args.shift unless defined?(JRUBY_VERSION)
|
367
|
+
|
368
|
+
begin
|
369
|
+
{ :success => true, :analysis => analyze_query(*args) }
|
370
|
+
rescue GibbonError => e
|
371
|
+
{ :success => false, :error => e.to_js(gibbon) }
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
{ :analyzeQuery => analyze_proc }
|
355
376
|
end
|
356
377
|
end
|
357
378
|
|
@@ -450,10 +471,6 @@ module GoodGuide
|
|
450
471
|
def add_dependency!(key, dep)
|
451
472
|
(@dependencies[key] ||= []) << dep
|
452
473
|
end
|
453
|
-
|
454
|
-
def to_js(gibbon)
|
455
|
-
{ :performQuery => proc_for(gibbon, :perform_query) }
|
456
|
-
end
|
457
474
|
end
|
458
475
|
|
459
476
|
class Context
|
@@ -478,7 +495,7 @@ module GoodGuide
|
|
478
495
|
def parse(str)
|
479
496
|
obj_to_ruby self.gibbon.parse(str)
|
480
497
|
rescue JSError => e
|
481
|
-
raise
|
498
|
+
raise ParseError.new(e.value)
|
482
499
|
end
|
483
500
|
|
484
501
|
def compile(semantics)
|
@@ -489,39 +506,26 @@ module GoodGuide
|
|
489
506
|
obj_to_ruby(gibbon.compileRuby(obj_to_js(semantics)))
|
490
507
|
end
|
491
508
|
|
492
|
-
|
493
|
-
|
509
|
+
if defined?(JRUBY_VERSION)
|
510
|
+
def unwrap_error(e)
|
511
|
+
return e unless e.respond_to?(:value) and e.value.is_a? Rhino::Ruby::Object
|
494
512
|
|
495
|
-
|
496
|
-
|
513
|
+
e.value.unwrap
|
514
|
+
end
|
515
|
+
else
|
516
|
+
def unwrap_error(e)
|
517
|
+
e
|
497
518
|
end
|
498
|
-
|
499
|
-
obj_to_ruby(out)
|
500
519
|
end
|
501
520
|
|
502
|
-
|
503
|
-
|
504
|
-
callback_args = nil
|
505
|
-
call_count = 0
|
506
|
-
|
507
|
-
b.call do |*args|
|
508
|
-
# Rhino doesn't get "this", but V8 does.
|
509
|
-
args.shift unless defined?(JRUBY_VERSION)
|
510
|
-
|
511
|
-
call_count += 1
|
512
|
-
|
513
|
-
if call_count >= 2
|
514
|
-
first = callback_args.inspect
|
515
|
-
second = args.inspect
|
516
|
-
raise "gibbon: callback called twice with #{first} and #{second}"
|
517
|
-
end
|
518
|
-
|
519
|
-
callback_args = args
|
520
|
-
end
|
521
|
+
def analyze(syntax, global_table, static_client)
|
522
|
+
syntax = obj_to_js(syntax)
|
521
523
|
|
522
|
-
|
524
|
+
result = gibbon.analyze(syntax, global_table, static_client)
|
523
525
|
|
524
|
-
|
526
|
+
[ obj_to_ruby(result[:errors]), obj_to_ruby(result[:semantics]) ]
|
527
|
+
rescue => e
|
528
|
+
raise unwrap_error(e)
|
525
529
|
end
|
526
530
|
end
|
527
531
|
|