delorean_lang 0.3.33 → 0.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6f8891a8771615853e2c27e6a990885dadb65f9
4
- data.tar.gz: 7025ffd4e2f0ca45ed5f0f8c5cb7c966fb34eac8
3
+ metadata.gz: f665bb92a67fd0769a477d7ef174267535c75b6b
4
+ data.tar.gz: afa0d72489613c49cf37785cdcbf90c95fa62074
5
5
  SHA512:
6
- metadata.gz: 78942629bdf7d297a2eda5e7ba808f0f88da8cdfb9d7bad0f03841fa17094e2d185218aaa748865771d06fc8383bf986a4697acd05df7f753da8cb8324f9df0e
7
- data.tar.gz: ccb53908b8c1924f090ad263289057339847702b3111ab9f96b3facf02fc4bf6d21767d9d6101b4cf0f8734f7af1d29df7355f951b7ce6645211016d11abc1a3
6
+ metadata.gz: cdb713258835e5dbbbd94deaadec930fbc5585f6cba6cb87b6dbf06cb1d4ed737e68b37205aa6b70928ef8fa23764834c7f91c680c6a4fb2fc2c2e8fac55f863
7
+ data.tar.gz: 84f522bdc77047a4e74f22e25b028842cb9a30068bd9e7f9a43113451d22b89c03893ef4055c2163e2c7e803f1f4fe6d885e30030ef41417f7811ea9d5d4527a
data/Gemfile CHANGED
@@ -5,4 +5,5 @@ gemspec
5
5
 
6
6
  group :development, :test do
7
7
  gem 'rspec-instafail', require: false
8
+ gem 'pry'
8
9
  end
@@ -234,8 +234,10 @@ module Delorean
234
234
  end
235
235
 
236
236
  cls = obj.class
237
- sig = (cls < Delorean::Model && cls.delorean_instance_methods[msg]) ||
238
- RUBY_WHITELIST[msg]
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
 
@@ -24,7 +24,7 @@ module Delorean
24
24
  end
25
25
 
26
26
  def delorean_instance_method(name, sig = nil)
27
- delorean_instance_methods[name.to_sym] = [self, *sig].compact
27
+ delorean_instance_methods[[self, name.to_sym]] = [self, *sig].compact
28
28
  end
29
29
 
30
30
  def delorean_instance_methods
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.3.33"
2
+ VERSION = "0.3.34"
3
3
  end
@@ -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()',
@@ -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.33
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: 2017-12-28 00:00:00.000000000 Z
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.13
121
+ rubygems_version: 2.6.14
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Delorean compiler