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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f883290f82867edc3d1c7d8fa4414bb5dccbc9561619a1af1ab99348518828cd
4
- data.tar.gz: b7f0128847fbb2ac7ff0f1364f549e3911a981a64ed07a2b0de8005ae2e7abb7
3
+ metadata.gz: c5f384dcfb07455b430f7e5cc39832349e90102061dd4938ae1c91b87705cd01
4
+ data.tar.gz: 53cc908c85b3ee1a22254aadc4e20994fd41d49b9dc1997de49faba053348b53
5
5
  SHA512:
6
- metadata.gz: 27541d90b44f21b3dcc24055c548059282c4a857ef32aec58b97a20c0ded8f752aa1bc1be763e207e7222914711935baa9f3d1295132a6719ab5a3b664c1f836
7
- data.tar.gz: 516c7f76522351367deb20ed771dc87b239cee2665dc05ddcebd2b0fcba106396db9a9d0e12e3f7b9729470a530739e6f756298b1c46780dc7d27407fc3566c2
6
+ metadata.gz: af272886e5cfff2facfec56ec8a7b4e4b49453752740b07b45aff6ab1d2e47359707a04d7451e89bc7f58bd9752a4cdc88a859ed4299fee4de23eab96dc98774
7
+ data.tar.gz: ce15844ba019fa48b70ec47ed9fbe6f22956309375dd297a0cdab0ae289d5d663d0ad037cc82cb61f59de9014c570ad322d96240723aa17b94d1b63184c50d57
@@ -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
- arg0.rewrite(context),
380
- (", " + args_rest.args.rewrite(context) if
381
- defined?(args_rest.args) && !args_rest.args.text_value.empty?),
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
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
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("CRJ")',
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
@@ -38,7 +38,7 @@ class Dummy < ActiveRecord::Base
38
38
  Dummy.new(name: name, number: number)
39
39
  end
40
40
 
41
- I_JUST_MET_YOU_SIG = [2, 2]
41
+ I_JUST_MET_YOU_SIG = [1, 2]
42
42
 
43
43
  def self.call_me_maybe(*a)
44
44
  a.inject(0, :+)
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.5
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-10-20 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop