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 +8 -8
- data/lib/delorean/base.rb +51 -44
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2RjODkwNmY0M2EyNDgwNmZmZWE3YWU5ZTY1YmM0YjVjMDFmM2E3Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTRiZjEzOTJjMGI5MjkyYjJmZTQzZGQ1NTA0N2I0MzZmYmU4ODNlYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWZlMzhjOWEzZTJiNzQ0Y2E5YjBjNGJlYmY4ODU5MzcxNGUwMzdlN2ZjZWI0
|
10
|
+
ZjYzYWI3M2NkNzdlY2ExYmVhNDQyZjVhNjUxY2U5NjhjMDQ2MWI0NDBlZmY5
|
11
|
+
MzY4MjEyMzIyZjI1NzYzYjNhMThkNWY2ZDNlNzc4YjdlZmRmZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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:
|
11
|
-
flatten:
|
12
|
-
length:
|
13
|
-
max:
|
14
|
-
member:
|
15
|
-
member?:
|
16
|
-
reverse:
|
17
|
-
slice:
|
18
|
-
sort:
|
19
|
-
split:
|
20
|
-
uniq:
|
21
|
-
sum:
|
22
|
-
zip:
|
23
|
-
index:
|
24
|
-
product:
|
25
|
-
first:
|
26
|
-
|
27
|
-
keys:
|
28
|
-
values:
|
29
|
-
upcase:
|
30
|
-
downcase:
|
31
|
-
match:
|
32
|
-
|
33
|
-
hour:
|
34
|
-
min:
|
35
|
-
sec:
|
36
|
-
to_date:
|
37
|
-
|
38
|
-
month:
|
39
|
-
day:
|
40
|
-
year:
|
41
|
-
|
42
|
-
next_month:
|
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:
|
45
|
+
prev_month: [[Date, Time, ActiveSupport::TimeWithZone],
|
46
46
|
[nil, Fixnum],
|
47
47
|
],
|
48
48
|
|
49
|
-
beginning_of_month:
|
49
|
+
beginning_of_month: [[Date, Time, ActiveSupport::TimeWithZone]],
|
50
50
|
|
51
|
-
end_of_month:
|
51
|
+
end_of_month: [[Date, Time, ActiveSupport::TimeWithZone]],
|
52
52
|
|
53
|
-
next_day:
|
53
|
+
next_day: [[Date, Time, ActiveSupport::TimeWithZone],
|
54
54
|
[nil, Fixnum],
|
55
55
|
],
|
56
|
-
prev_day:
|
56
|
+
prev_day: [[Date, Time, ActiveSupport::TimeWithZone],
|
57
57
|
[nil, Fixnum],
|
58
58
|
],
|
59
59
|
|
60
|
-
to_i:
|
61
|
-
to_f:
|
62
|
-
to_d:
|
63
|
-
to_s:
|
64
|
-
abs:
|
65
|
-
round:
|
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
|
data/lib/delorean/version.rb
CHANGED
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.
|
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
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|