delorean_lang 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjQ5M2EzMTc3OGJlMmFhYTY0YmY1YTE5ODg5MTZiYjk2NmFjNDk1OA==
4
+ N2RjODkwNmY0M2EyNDgwNmZmZWE3YWU5ZTY1YmM0YjVjMDFmM2E3Mg==
5
5
  data.tar.gz: !binary |-
6
- NTVhYzM1MGQxNmNkNjM1YWQ4Zjc3ZjU2MDQzOGJjNzA5MjczNmNmNA==
6
+ YTRiZjEzOTJjMGI5MjkyYjJmZTQzZGQ1NTA0N2I0MzZmYmU4ODNlYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjA2NWM5NmQ0Zjg1NjkxYTI1YjBmZTEzYTdkNzJiODRkMzI2YTQ1NWNlZjA1
10
- ODgyZjkzODAxYWViOTBmNDI0ODViNzBmMWE0NjRjZjE2NzI4ZWZjMmMzZDYw
11
- YzhjMDQ5MjQyNzVhYjYyN2ZhYTMzODcyNzNkYTg4Y2Q5OWVmZWY=
9
+ YWZlMzhjOWEzZTJiNzQ0Y2E5YjBjNGJlYmY4ODU5MzcxNGUwMzdlN2ZjZWI0
10
+ ZjYzYWI3M2NkNzdlY2ExYmVhNDQyZjVhNjUxY2U5NjhjMDQ2MWI0NDBlZmY5
11
+ MzY4MjEyMzIyZjI1NzYzYjNhMThkNWY2ZDNlNzc4YjdlZmRmZTE=
12
12
  data.tar.gz: !binary |-
13
- NzQ5YTJmODYwNTdkMjYyM2I1NzZiYjU2MjIyZmMzNzk1MTU4YTJmNDBlMzE4
14
- MzlmYzU0ZmRmNmNmMThiYzA5ODdkNThhZjQ5MzAzZDI5MTVkMjk3MTE4ZjFl
15
- ZjAyYjkzOTA5YmJlMmYxYTk5YjcwOWMxYWJjMTJhNWJmY2U2MDI=
13
+ OGEzNmQ5NzQyNDkyYjIyNDI4ZjJiZmQwZDRmMmNkMjkwYTI3ZTUwMDdjZWNk
14
+ MjA3NzZjZTgwZWI5MmU3Y2I1NzQ3YTJkYjZmZTBkM2E4NzYwNGE1NzA0ZWVm
15
+ MTM0NWRhYzIzMGIxYTU4YzBkZTNiMzhiMGE4ZjNkOWM4NzcwM2U=
data/lib/delorean/base.rb CHANGED
@@ -7,62 +7,62 @@ module Delorean
7
7
  # hash. The whole whitelist mechanism should be eventually
8
8
  # rethought.
9
9
  RUBY_WHITELIST = {
10
- compact: [Array],
11
- flatten: [Array, [Fixnum, nil]],
12
- length: [[Array, String]],
13
- max: [Array],
14
- member: "member?",
15
- member?: [Array, [Fixnum, String]],
16
- reverse: [Array],
17
- slice: [Array, Fixnum, Fixnum],
18
- sort: [Array],
19
- split: [String, String],
20
- uniq: [Array],
21
- sum: [Array],
22
- zip: [Array, [Array, Array, Array]],
23
- index: [Array, [Integer, Numeric, String, Array, Fixnum]],
24
- product: [Array, Array],
25
- first: [Enumerable, [nil, Fixnum]],
26
-
27
- keys: [Hash],
28
- values: [Hash],
29
- upcase: [String],
30
- downcase: [String],
31
- match: [String, [String], [nil, Fixnum]],
32
-
33
- hour: [[Date, Time, ActiveSupport::TimeWithZone]],
34
- min: [[Date, Time, ActiveSupport::TimeWithZone, Array]],
35
- sec: [[Date, Time, ActiveSupport::TimeWithZone]],
36
- to_date: [[Date, Time, ActiveSupport::TimeWithZone]],
37
-
38
- month: [[Date, Time, ActiveSupport::TimeWithZone]],
39
- day: [[Date, Time, ActiveSupport::TimeWithZone]],
40
- year: [[Date, Time, ActiveSupport::TimeWithZone]],
41
-
42
- next_month: [[Date, Time, ActiveSupport::TimeWithZone],
10
+ compact: [Array],
11
+ flatten: [Array, [Fixnum, nil]],
12
+ length: [[Array, String]],
13
+ max: [Array],
14
+ member: "member?",
15
+ member?: [Array, [Fixnum, String]],
16
+ reverse: [Array],
17
+ slice: [Array, Fixnum, Fixnum],
18
+ sort: [Array],
19
+ split: [String, String],
20
+ uniq: [Array],
21
+ sum: [Array],
22
+ zip: [Array, [Array, Array, Array]],
23
+ index: [Array, [Integer, Numeric, String, Array, Fixnum]],
24
+ product: [Array, Array],
25
+ first: [Enumerable, [nil, Fixnum]],
26
+
27
+ keys: [Hash],
28
+ values: [Hash],
29
+ upcase: [String],
30
+ downcase: [String],
31
+ match: [String, [String], [nil, Fixnum]],
32
+
33
+ hour: [[Date, Time, ActiveSupport::TimeWithZone]],
34
+ min: [[Date, Time, ActiveSupport::TimeWithZone, Array]],
35
+ sec: [[Date, Time, ActiveSupport::TimeWithZone]],
36
+ to_date: [[Date, Time, ActiveSupport::TimeWithZone]],
37
+
38
+ month: [[Date, Time, ActiveSupport::TimeWithZone]],
39
+ day: [[Date, Time, ActiveSupport::TimeWithZone]],
40
+ year: [[Date, Time, ActiveSupport::TimeWithZone]],
41
+
42
+ next_month: [[Date, Time, ActiveSupport::TimeWithZone],
43
43
  [nil, Fixnum],
44
44
  ],
45
- prev_month: [[Date, Time, ActiveSupport::TimeWithZone],
45
+ prev_month: [[Date, Time, ActiveSupport::TimeWithZone],
46
46
  [nil, Fixnum],
47
47
  ],
48
48
 
49
- beginning_of_month: [[Date, Time, ActiveSupport::TimeWithZone]],
49
+ beginning_of_month: [[Date, Time, ActiveSupport::TimeWithZone]],
50
50
 
51
- end_of_month: [[Date, Time, ActiveSupport::TimeWithZone]],
51
+ end_of_month: [[Date, Time, ActiveSupport::TimeWithZone]],
52
52
 
53
- next_day: [[Date, Time, ActiveSupport::TimeWithZone],
53
+ next_day: [[Date, Time, ActiveSupport::TimeWithZone],
54
54
  [nil, Fixnum],
55
55
  ],
56
- prev_day: [[Date, Time, ActiveSupport::TimeWithZone],
56
+ prev_day: [[Date, Time, ActiveSupport::TimeWithZone],
57
57
  [nil, Fixnum],
58
58
  ],
59
59
 
60
- to_i: [[Numeric, String]],
61
- to_f: [[Numeric, String]],
62
- to_d: [[Numeric, String]],
63
- to_s: [Object],
64
- abs: [Numeric],
65
- round: [Numeric, [nil, Integer]],
60
+ to_i: [[Numeric, String]],
61
+ to_f: [[Numeric, String]],
62
+ to_d: [[Numeric, String]],
63
+ to_s: [Object],
64
+ abs: [Numeric],
65
+ round: [Numeric, [nil, Integer]],
66
66
  }
67
67
 
68
68
  module BaseModule
@@ -78,6 +78,13 @@ module Delorean
78
78
  h[attr] = evaluate(attr)
79
79
  }
80
80
  end
81
+
82
+ # add new arguments, results in a new NodeCall
83
+ def +(args)
84
+ raise "bad arg to %" unless args.is_a?(Hash)
85
+
86
+ NodeCall.new(_e, engine, node, params.merge(args))
87
+ end
81
88
  end
82
89
 
83
90
  class BaseClass
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/spec/eval_spec.rb CHANGED
@@ -582,6 +582,19 @@ eof
582
582
  engine.evaluate_attrs("A", ["d", "f"]).should == [26, 2]
583
583
  end
584
584
 
585
+ it "should be able to amend node calls" do
586
+ engine.parse defn("A:",
587
+ " a =?",
588
+ " aa = a*2",
589
+ " e = A(a=12)",
590
+ " d = e+{'a':3}",
591
+ " f = e+{'a':4}",
592
+ " g = d.aa + f.aa",
593
+ )
594
+
595
+ engine.evaluate("A", "g").should == 3*2 + 4*2
596
+ end
597
+
585
598
  it "should eval module calls 1" do
586
599
  engine.parse defn("A:",
587
600
  " a = 123",
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-10 00:00:00.000000000 Z
11
+ date: 2014-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop