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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b956f73e3ee6d788ed5d199cd9ea7f7c9f0ff214
4
- data.tar.gz: d2d0cb069ecf49e7ab8996dd6f2b1540da9ea957
3
+ metadata.gz: d828ae6c2a90a7279b8bc50e7ea693bf5f528aeb
4
+ data.tar.gz: e88e1188a4979f7e590d33bc56b360fec7ac2b87
5
5
  SHA512:
6
- metadata.gz: abab0d339baa484b8c6a94e0a4f72aef5bc46dbd9d5bbd5d8c55ec0dc1f100146c11b3c5228884ba3477331c22db048d0df855d48fd93de764bb0992bf23ae85
7
- data.tar.gz: a9d449549b94e672f6bc264ef65b28544a7259b606d3e3d68c14870282f6395d101a0a52e02d9ea6cbe33ee1b1cceaa3a9bfebc04e6532bb6e101949775ceecf
6
+ metadata.gz: 5d1b9ed7b15d2e6cb2fe340dee440661845d75fe63c2de938aef0e90db488eb45cd72d68abbd5b47e0bd6fc4f20ec99af484ff8365ba5763cd87ec299fd447f6
7
+ data.tar.gz: 20d16da4573467e11953252c0c5fafe530023d08a576b084a7c769e47b78b53c6b9717464d71c74f26b46ab99dd4a45a1123f591518a25303c03fdc5e3c2aee5
@@ -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
  ######################################################################
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.3.36"
2
+ VERSION = "0.3.37"
3
3
  end
@@ -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
@@ -94,6 +94,10 @@ class Dummy < ActiveRecord::Base
94
94
  delorean_fn :side_effect, sig: 0 do
95
95
  @@foo += 1
96
96
  end
97
+
98
+ delorean_fn :returns_openstruct, sig: 0 do
99
+ OpenStruct.new({"abc"=>"def"})
100
+ end
97
101
  end
98
102
 
99
103
  class DummyChild < Dummy
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.36
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-02-15 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop