delorean_lang 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delorean/nodes.rb +8 -5
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +13 -0
- data/spec/parse_spec.rb +17 -1
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5f384dcfb07455b430f7e5cc39832349e90102061dd4938ae1c91b87705cd01
|
4
|
+
data.tar.gz: 53cc908c85b3ee1a22254aadc4e20994fd41d49b9dc1997de49faba053348b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af272886e5cfff2facfec56ec8a7b4e4b49453752740b07b45aff6ab1d2e47359707a04d7451e89bc7f58bd9752a4cdc88a859ed4299fee4de23eab96dc98774
|
7
|
+
data.tar.gz: ce15844ba019fa48b70ec47ed9fbe6f22956309375dd297a0cdab0ae289d5d663d0ad037cc82cb61f59de9014c570ad322d96240723aa17b94d1b63184c50d57
|
data/lib/delorean/nodes.rb
CHANGED
@@ -132,6 +132,10 @@ eos
|
|
132
132
|
@text = text
|
133
133
|
end
|
134
134
|
|
135
|
+
def +(other)
|
136
|
+
self.to_s + other
|
137
|
+
end
|
138
|
+
|
135
139
|
def to_s
|
136
140
|
text
|
137
141
|
end
|
@@ -375,11 +379,10 @@ eos
|
|
375
379
|
end
|
376
380
|
|
377
381
|
def rewrite(context)
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
].compact.sum
|
382
|
+
rest = ", " + args_rest.args.rewrite(context) if
|
383
|
+
defined?(args_rest.args) && !args_rest.args.text_value.empty?
|
384
|
+
|
385
|
+
[arg0.rewrite(context), rest].compact.sum
|
383
386
|
end
|
384
387
|
|
385
388
|
def arg_count
|
data/lib/delorean/version.rb
CHANGED
data/spec/eval_spec.rb
CHANGED
@@ -656,6 +656,19 @@ eof
|
|
656
656
|
engine.evaluate("A", ["d", "f"]).should == [26, 2]
|
657
657
|
end
|
658
658
|
|
659
|
+
it "allows node calls from attrs" do
|
660
|
+
engine.parse defn("A:",
|
661
|
+
" a =?",
|
662
|
+
" c =?",
|
663
|
+
" b = a**2",
|
664
|
+
" e = A(a=13)",
|
665
|
+
" d = e(a=4, **{'c': 5})",
|
666
|
+
" f = d.b + d.c + e().a",
|
667
|
+
)
|
668
|
+
|
669
|
+
engine.evaluate("A", ["f"]).should == [16+5+13]
|
670
|
+
end
|
671
|
+
|
659
672
|
it "should eval multi-var hash comprehension" do
|
660
673
|
engine.parse defn("A:",
|
661
674
|
" b = {k*5 : v+1 for k, v in {1:2, 7:-30}}",
|
data/spec/parse_spec.rb
CHANGED
@@ -379,6 +379,14 @@ describe "Delorean" do
|
|
379
379
|
}.should_not raise_error
|
380
380
|
end
|
381
381
|
|
382
|
+
it "should be able to pass model class to model functions" do
|
383
|
+
lambda {
|
384
|
+
engine.parse defn("A:",
|
385
|
+
" b = Dummy.i_just_met_you(Dummy, 1)"
|
386
|
+
)
|
387
|
+
}.should_not raise_error
|
388
|
+
end
|
389
|
+
|
382
390
|
it "should be able to call class methods on ActiveRecord classes" do
|
383
391
|
engine.parse defn("A:",
|
384
392
|
" b = Dummy.call_me_maybe()",
|
@@ -388,7 +396,7 @@ describe "Delorean" do
|
|
388
396
|
it "should get exception on arg count to class method call" do
|
389
397
|
lambda {
|
390
398
|
engine.parse defn("A:",
|
391
|
-
' b = Dummy.i_just_met_you(
|
399
|
+
' b = Dummy.i_just_met_you(1, 2, 3)',
|
392
400
|
)
|
393
401
|
}.should raise_error(Delorean::BadCallError)
|
394
402
|
end
|
@@ -753,6 +761,14 @@ describe "Delorean" do
|
|
753
761
|
)
|
754
762
|
end
|
755
763
|
|
764
|
+
it "should allow node calls to attrs" do
|
765
|
+
engine.parse defn("A:",
|
766
|
+
" x=?",
|
767
|
+
" a = A(x=123)",
|
768
|
+
" d = a(x=456).x",
|
769
|
+
)
|
770
|
+
end
|
771
|
+
|
756
772
|
it "allow conditional args to node calls" do
|
757
773
|
engine.parse defn("A:",
|
758
774
|
" d = A(a=1, b=4 if true, c=4 if false)",
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delorean_lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|