delorean_lang 0.3.36 → 0.3.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delorean/base.rb +4 -2
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +12 -1
- data/spec/spec_helper.rb +4 -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: d828ae6c2a90a7279b8bc50e7ea693bf5f528aeb
|
4
|
+
data.tar.gz: e88e1188a4979f7e590d33bc56b360fec7ac2b87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d1b9ed7b15d2e6cb2fe340dee440661845d75fe63c2de938aef0e90db488eb45cd72d68abbd5b47e0bd6fc4f20ec99af484ff8365ba5763cd87ec299fd447f6
|
7
|
+
data.tar.gz: 20d16da4573467e11953252c0c5fafe530023d08a576b084a7c769e47b78b53c6b9717464d71c74f26b46ab99dd4a45a1123f591518a25303c03fdc5e3c2aee5
|
data/lib/delorean/base.rb
CHANGED
@@ -155,6 +155,8 @@ module Delorean
|
|
155
155
|
return obj.send(attr.to_sym) if obj.class.reflections[attr]
|
156
156
|
when NodeCall
|
157
157
|
return obj.evaluate(attr)
|
158
|
+
when OpenStruct
|
159
|
+
return obj[attr.to_sym]
|
158
160
|
when Class
|
159
161
|
return obj.send((attr + POST).to_sym, _e) if obj < BaseClass
|
160
162
|
end
|
@@ -176,7 +178,7 @@ module Delorean
|
|
176
178
|
# FIXME: even Javascript which is superpermissive raises an
|
177
179
|
# exception on null getattr.
|
178
180
|
return nil
|
179
|
-
when Hash, ActiveRecord::Base, NodeCall, Class
|
181
|
+
when Hash, ActiveRecord::Base, NodeCall, Class, OpenStruct
|
180
182
|
raise InvalidIndex unless args.length == 1
|
181
183
|
_get_attr(obj, args[0], _e)
|
182
184
|
when Array, String, MatchData
|
@@ -264,7 +266,7 @@ module Delorean
|
|
264
266
|
# calls (e.g. the chaining modifies the relation object. Not
|
265
267
|
# sure what this side-effect means. Delorean code which
|
266
268
|
# perform queries on queries seems to work.
|
267
|
-
ActiveRecord::Relation === res ? res : res.freeze
|
269
|
+
(ActiveRecord::Relation === res || Class === res) ? res : res.freeze
|
268
270
|
end
|
269
271
|
|
270
272
|
######################################################################
|
data/lib/delorean/version.rb
CHANGED
data/spec/eval_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
2
|
describe "Delorean" do
|
4
3
|
|
5
4
|
let(:sset) {
|
@@ -1030,6 +1029,18 @@ eof
|
|
1030
1029
|
expect(r).to eq 3
|
1031
1030
|
end
|
1032
1031
|
|
1032
|
+
it "understands openstructs" do
|
1033
|
+
engine.parse defn("A:",
|
1034
|
+
" os = Dummy.returns_openstruct",
|
1035
|
+
" abc = os.abc",
|
1036
|
+
" not_found = os.not_found"
|
1037
|
+
)
|
1038
|
+
r = engine.evaluate("A", ["os", "abc", "not_found"])
|
1039
|
+
expect(r[0].abc).to eq("def")
|
1040
|
+
expect(r[1]).to eq("def")
|
1041
|
+
expect(r[2]).to be_nil
|
1042
|
+
end
|
1043
|
+
|
1033
1044
|
xit "can use nodes as continuations" do
|
1034
1045
|
|
1035
1046
|
# FIME: This is actually a trivial exmaple. Ideally we should be
|
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.3.
|
4
|
+
version: 0.3.37
|
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-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|