delorean_lang 0.4.00 → 0.4.1
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 +1 -4
- data/lib/delorean/model.rb +0 -8
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +0 -39
- data/spec/spec_helper.rb +0 -22
- 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: 5e16424d7fcee1580734a4acd92800dfe12d6843
|
4
|
+
data.tar.gz: b0e838fd40d2dc67e56c6a0902ac18c6334e62cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c206b29669d8089786b2e06bc33b2ed5f83c38d5c8feb648282b316aee98fb333cba456f042f321c3f89196e28ee0635165c49c1ce2a8dc2fcdf6f677cb738cd
|
7
|
+
data.tar.gz: 703a9c28bdfb4c52f0d242583a1003d1649601be87e06552dab7f8a860cd4193c5b3c22e3bac0dc1d23c452512f7567af438e4982f0d31e00653358b09367250
|
data/lib/delorean/base.rb
CHANGED
@@ -236,10 +236,7 @@ module Delorean
|
|
236
236
|
end
|
237
237
|
|
238
238
|
cls = obj.class
|
239
|
-
sig =
|
240
|
-
cls.ancestors.lazy.map do |an|
|
241
|
-
cls.delorean_instance_methods[[an, msg]]
|
242
|
-
end.find{|i|i} || RUBY_WHITELIST[msg]
|
239
|
+
sig = RUBY_WHITELIST[msg]
|
243
240
|
|
244
241
|
raise "no such method #{method}" unless sig
|
245
242
|
|
data/lib/delorean/model.rb
CHANGED
@@ -22,14 +22,6 @@ module Delorean
|
|
22
22
|
self.const_set(name.to_s.upcase+Delorean::SIG, sig)
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
def delorean_instance_method(name, sig = nil)
|
27
|
-
delorean_instance_methods[[self, name.to_sym]] = [self, *sig].compact
|
28
|
-
end
|
29
|
-
|
30
|
-
def delorean_instance_methods
|
31
|
-
@@delorean_instance_methods ||= {}
|
32
|
-
end
|
33
25
|
end
|
34
26
|
end
|
35
27
|
end
|
data/lib/delorean/version.rb
CHANGED
data/spec/eval_spec.rb
CHANGED
@@ -284,45 +284,6 @@ describe "Delorean" do
|
|
284
284
|
r.should == "CRJ-1.234"
|
285
285
|
end
|
286
286
|
|
287
|
-
it "should be able to access delorean_instance_method fns using .x syntax" do
|
288
|
-
engine.parse defn("A:",
|
289
|
-
' b = Dummy.i_just_met_you("I Really Like You", 1.234).name3("Run Away with Me")',
|
290
|
-
)
|
291
|
-
r = engine.evaluate("A", "b")
|
292
|
-
r.should == "I Really Like You-1.234-Run Away with Me"
|
293
|
-
end
|
294
|
-
|
295
|
-
it "delorean_instance_fn inheritance test 1" do
|
296
|
-
engine.parse defn("A:",
|
297
|
-
' b = DummyChild.hello.name3("child calling parent\'s dim")',
|
298
|
-
)
|
299
|
-
r = engine.evaluate("A", "b")
|
300
|
-
r.should == "child-99999.0-child calling parent's dim"
|
301
|
-
end
|
302
|
-
it "delorean_instance_fn inheritance test 2" do
|
303
|
-
engine.parse defn("A:",
|
304
|
-
' b = DummyChild.hello.name4("child calling own dim")',
|
305
|
-
)
|
306
|
-
r = engine.evaluate("A", "b")
|
307
|
-
r.should == "#4 child-99999.0-child calling own dim"
|
308
|
-
end
|
309
|
-
it "delorean_instance_fn inheritance test 3" do
|
310
|
-
# calling unrelated dim
|
311
|
-
engine.parse defn("A:",
|
312
|
-
" b = M::LittleDummy.sup.foob",
|
313
|
-
)
|
314
|
-
r = engine.evaluate("A", "b")
|
315
|
-
r.should == "bar"
|
316
|
-
end
|
317
|
-
it "delorean_instance_fn inheritance test 4" do
|
318
|
-
# parent calling its own dim (that a child also has)
|
319
|
-
engine.parse defn("A:",
|
320
|
-
' b = Dummy.i_just_met_you("Foo",321).name4("Bar")',
|
321
|
-
)
|
322
|
-
r = engine.evaluate("A", "b")
|
323
|
-
r.should == "Four Foo-321.0-Bar"
|
324
|
-
end
|
325
|
-
|
326
287
|
it "should be able to get attr on Hash objects using a.b syntax" do
|
327
288
|
engine.parse defn("A:",
|
328
289
|
' b = Dummy.i_threw_a_hash_in_the_well()',
|
data/spec/spec_helper.rb
CHANGED
@@ -78,18 +78,6 @@ class Dummy < ActiveRecord::Base
|
|
78
78
|
[a, b]
|
79
79
|
end
|
80
80
|
|
81
|
-
def name3 other_name
|
82
|
-
"#{name}-#{number.round(4)}-#{other_name}"
|
83
|
-
end
|
84
|
-
|
85
|
-
delorean_instance_method :name3, String
|
86
|
-
|
87
|
-
def name4 other_name
|
88
|
-
"Four #{name}-#{number.round(4)}-#{other_name}"
|
89
|
-
end
|
90
|
-
|
91
|
-
delorean_instance_method :name4, String
|
92
|
-
|
93
81
|
@@foo = 0
|
94
82
|
delorean_fn :side_effect, sig: 0 do
|
95
83
|
@@foo += 1
|
@@ -105,11 +93,6 @@ class DummyChild < Dummy
|
|
105
93
|
DummyChild.new(name: "child", number: 99999)
|
106
94
|
end
|
107
95
|
HELLO_SIG = [0, 0]
|
108
|
-
def name4 other_name
|
109
|
-
"#4 #{name}-#{number.round(4)}-#{other_name}"
|
110
|
-
end
|
111
|
-
|
112
|
-
delorean_instance_method :name4, String
|
113
96
|
end
|
114
97
|
|
115
98
|
module M
|
@@ -124,12 +107,7 @@ module M
|
|
124
107
|
LittleDummy.new
|
125
108
|
end
|
126
109
|
SUP_SIG = [0, 0]
|
127
|
-
def foob
|
128
|
-
"bar"
|
129
|
-
end
|
130
|
-
delorean_instance_method :foob
|
131
110
|
end
|
132
|
-
|
133
111
|
end
|
134
112
|
|
135
113
|
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.4.
|
4
|
+
version: 0.4.1
|
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-08-
|
11
|
+
date: 2018-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|