delorean_lang 0.3.32 → 0.3.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/lib/delorean/base.rb +6 -5
- data/lib/delorean/model.rb +1 -1
- data/lib/delorean/version.rb +1 -1
- data/spec/func_spec.rb +12 -0
- 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: e6f8891a8771615853e2c27e6a990885dadb65f9
|
4
|
+
data.tar.gz: 7025ffd4e2f0ca45ed5f0f8c5cb7c966fb34eac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78942629bdf7d297a2eda5e7ba808f0f88da8cdfb9d7bad0f03841fa17094e2d185218aaa748865771d06fc8383bf986a4697acd05df7f753da8cb8324f9df0e
|
7
|
+
data.tar.gz: ccb53908b8c1924f090ad263289057339847702b3111ab9f96b3facf02fc4bf6d21767d9d6101b4cf0f8734f7af1d29df7355f951b7ce6645211016d11abc1a3
|
data/Gemfile
CHANGED
data/lib/delorean/base.rb
CHANGED
@@ -6,7 +6,7 @@ module Delorean
|
|
6
6
|
|
7
7
|
DT_TYPES = [Date, Time, ActiveSupport::TimeWithZone]
|
8
8
|
NUM_OR_STR = [Numeric, String]
|
9
|
-
NUM_OR_NIL = [nil,
|
9
|
+
NUM_OR_NIL = [nil, Integer]
|
10
10
|
|
11
11
|
# FIXME: the whitelist is quite hacky. It's currently difficult to
|
12
12
|
# override it. A user will likely want to directly modify this
|
@@ -27,8 +27,8 @@ module Delorean
|
|
27
27
|
empty?: [Enumerable],
|
28
28
|
except: [Hash, String] + [[nil, String]]*9,
|
29
29
|
reverse: [Array],
|
30
|
-
slice: [Array,
|
31
|
-
each_slice: [Array,
|
30
|
+
slice: [Array, Integer, Integer],
|
31
|
+
each_slice: [Array, Integer],
|
32
32
|
sort: [Array],
|
33
33
|
split: [String, String],
|
34
34
|
uniq: [Array],
|
@@ -45,6 +45,7 @@ module Delorean
|
|
45
45
|
|
46
46
|
keys: [Hash],
|
47
47
|
values: [Hash],
|
48
|
+
fetch: [Hash, Object, [Object]],
|
48
49
|
upcase: [String],
|
49
50
|
downcase: [String],
|
50
51
|
match: [String, [String], NUM_OR_NIL],
|
@@ -179,8 +180,8 @@ module Delorean
|
|
179
180
|
_get_attr(obj, args[0], _e)
|
180
181
|
when Array, String, MatchData
|
181
182
|
raise InvalidIndex unless args.length <= 2 &&
|
182
|
-
args[0].is_a?(
|
183
|
-
(args[1].nil? || args[1].is_a?(
|
183
|
+
args[0].is_a?(Integer) &&
|
184
|
+
(args[1].nil? || args[1].is_a?(Integer))
|
184
185
|
obj[*args]
|
185
186
|
else
|
186
187
|
raise InvalidIndex
|
data/lib/delorean/model.rb
CHANGED
@@ -17,7 +17,7 @@ module Delorean
|
|
17
17
|
raise "no signature" unless sig
|
18
18
|
|
19
19
|
if sig
|
20
|
-
sig = [sig, sig] if sig.is_a?
|
20
|
+
sig = [sig, sig] if sig.is_a? Integer
|
21
21
|
raise "Bad signature" unless (sig.is_a? Array and sig.length==2)
|
22
22
|
self.const_set(name.to_s.upcase+Delorean::SIG, sig)
|
23
23
|
end
|
data/lib/delorean/version.rb
CHANGED
data/spec/func_spec.rb
CHANGED
@@ -78,6 +78,18 @@ describe "Delorean" do
|
|
78
78
|
r.should == ["hello", '12.3456', [1,2,3].to_s]
|
79
79
|
end
|
80
80
|
|
81
|
+
it "should handle FETCH" do
|
82
|
+
engine.parse defn("A:",
|
83
|
+
" h = {'a':123, 1:111}",
|
84
|
+
" a = h.fetch('a')",
|
85
|
+
" b = h.fetch(1)",
|
86
|
+
" c = h.fetch('xxx', 456)",
|
87
|
+
)
|
88
|
+
|
89
|
+
r = engine.evaluate("A", ["a", "b", "c"])
|
90
|
+
r.should == [123, 111, 456]
|
91
|
+
end
|
92
|
+
|
81
93
|
it "should handle TIMEPART" do
|
82
94
|
engine.parse defn("A:",
|
83
95
|
" p =?",
|
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.3.
|
4
|
+
version: 0.3.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|