delorean_lang 0.3.33 → 0.3.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/delorean/base.rb +4 -2
- data/lib/delorean/model.rb +1 -1
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +31 -0
- data/spec/spec_helper.rb +27 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f665bb92a67fd0769a477d7ef174267535c75b6b
|
4
|
+
data.tar.gz: afa0d72489613c49cf37785cdcbf90c95fa62074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb713258835e5dbbbd94deaadec930fbc5585f6cba6cb87b6dbf06cb1d4ed737e68b37205aa6b70928ef8fa23764834c7f91c680c6a4fb2fc2c2e8fac55f863
|
7
|
+
data.tar.gz: 84f522bdc77047a4e74f22e25b028842cb9a30068bd9e7f9a43113451d22b89c03893ef4055c2163e2c7e803f1f4fe6d885e30030ef41417f7811ea9d5d4527a
|
data/Gemfile
CHANGED
data/lib/delorean/base.rb
CHANGED
@@ -234,8 +234,10 @@ module Delorean
|
|
234
234
|
end
|
235
235
|
|
236
236
|
cls = obj.class
|
237
|
-
sig =
|
238
|
-
|
237
|
+
sig = cls < Delorean::Model &&
|
238
|
+
cls.ancestors.lazy.map do |an|
|
239
|
+
cls.delorean_instance_methods[[an, msg]]
|
240
|
+
end.find{|i|i} || RUBY_WHITELIST[msg]
|
239
241
|
|
240
242
|
raise "no such method #{method}" unless sig
|
241
243
|
|
data/lib/delorean/model.rb
CHANGED
data/lib/delorean/version.rb
CHANGED
data/spec/eval_spec.rb
CHANGED
@@ -319,6 +319,37 @@ describe "Delorean" do
|
|
319
319
|
r.should == "I Really Like You-1.234-Run Away with Me"
|
320
320
|
end
|
321
321
|
|
322
|
+
it "delorean_instance_fn inheritance test 1" do
|
323
|
+
engine.parse defn("A:",
|
324
|
+
' b = DummyChild.hello.name3("child calling parent\'s dim")',
|
325
|
+
)
|
326
|
+
r = engine.evaluate("A", "b")
|
327
|
+
r.should == "child-99999.0-child calling parent's dim"
|
328
|
+
end
|
329
|
+
it "delorean_instance_fn inheritance test 2" do
|
330
|
+
engine.parse defn("A:",
|
331
|
+
' b = DummyChild.hello.name4("child calling own dim")',
|
332
|
+
)
|
333
|
+
r = engine.evaluate("A", "b")
|
334
|
+
r.should == "#4 child-99999.0-child calling own dim"
|
335
|
+
end
|
336
|
+
it "delorean_instance_fn inheritance test 3" do
|
337
|
+
# calling unrelated dim
|
338
|
+
engine.parse defn("A:",
|
339
|
+
" b = M::LittleDummy.sup.foob",
|
340
|
+
)
|
341
|
+
r = engine.evaluate("A", "b")
|
342
|
+
r.should == "bar"
|
343
|
+
end
|
344
|
+
it "delorean_instance_fn inheritance test 4" do
|
345
|
+
# parent calling its own dim (that a child also has)
|
346
|
+
engine.parse defn("A:",
|
347
|
+
' b = Dummy.i_just_met_you("Foo",321).name4("Bar")',
|
348
|
+
)
|
349
|
+
r = engine.evaluate("A", "b")
|
350
|
+
r.should == "Four Foo-321.0-Bar"
|
351
|
+
end
|
352
|
+
|
322
353
|
it "should be able to get attr on Hash objects using a.b syntax" do
|
323
354
|
engine.parse defn("A:",
|
324
355
|
' b = Dummy.i_threw_a_hash_in_the_well()',
|
data/spec/spec_helper.rb
CHANGED
@@ -84,12 +84,30 @@ class Dummy < ActiveRecord::Base
|
|
84
84
|
|
85
85
|
delorean_instance_method :name3, String
|
86
86
|
|
87
|
+
def name4 other_name
|
88
|
+
"Four #{name}-#{number.round(4)}-#{other_name}"
|
89
|
+
end
|
90
|
+
|
91
|
+
delorean_instance_method :name4, String
|
92
|
+
|
87
93
|
@@foo = 0
|
88
94
|
delorean_fn :side_effect, sig: 0 do
|
89
95
|
@@foo += 1
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|
99
|
+
class DummyChild < Dummy
|
100
|
+
def self.hello
|
101
|
+
DummyChild.new(name: "child", number: 99999)
|
102
|
+
end
|
103
|
+
HELLO_SIG = [0, 0]
|
104
|
+
def name4 other_name
|
105
|
+
"#4 #{name}-#{number.round(4)}-#{other_name}"
|
106
|
+
end
|
107
|
+
|
108
|
+
delorean_instance_method :name4, String
|
109
|
+
end
|
110
|
+
|
93
111
|
module M
|
94
112
|
class LittleDummy
|
95
113
|
include Delorean::Model
|
@@ -98,7 +116,16 @@ module M
|
|
98
116
|
|*a|
|
99
117
|
a.inject(0, :+)
|
100
118
|
end
|
119
|
+
def self.sup
|
120
|
+
LittleDummy.new
|
121
|
+
end
|
122
|
+
SUP_SIG = [0, 0]
|
123
|
+
def foob
|
124
|
+
"bar"
|
125
|
+
end
|
126
|
+
delorean_instance_method :foob
|
101
127
|
end
|
128
|
+
|
102
129
|
end
|
103
130
|
|
104
131
|
Delorean::RUBY_WHITELIST.
|
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.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.6.
|
121
|
+
rubygems_version: 2.6.14
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Delorean compiler
|