delorean_lang 0.2.3 → 0.2.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2JmZWI1ZDg4M2ZlMTViMjAxNWFiODhmYzkyOTJjZGZkZTRiODM5NQ==
4
+ MThkOGViN2U0NDc5MjEyMmVhM2Y0NGIyN2QwNTRhZjFhY2M1NTMyMA==
5
5
  data.tar.gz: !binary |-
6
- OTZlYjcxNGFhMmE4MjhlZmM4NDE3NGQ5ODBhNzc0ODk1ZWFkMWE2Mw==
6
+ ODhlNDc3ODRkZGI4OWMwNzRiNzM1ODA4ZWI3MzY2OWYzNTdhZGRiOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Nzg2NjUyZTc4NmExOTI3MDUxNTBlZjg4NTEwMGFkNTIxZGM5ZDY5YjI0MWM1
10
- ZjlmMmNiYjU5ODM3NzFlM2NmOGUxOTUyMzZiYjk3OWYxODI0ZmM3NDY3ZWEw
11
- MjFkZTJlZTk3ODQwZjAyOWU2MzgyNzAyZGVkNmZjYmFkOTAwNzQ=
9
+ NjY0MzZiZTZmNDUzMmM2YmYyYjAxZjNiY2QxODY1OTQzNmZiNjJkOWM3NTMz
10
+ ZDhjYTFjZWRjYzE4ZmFmYWYyMmQ5NzY3OTFiODg5MDdlZGM5YWMwZjRiZWFh
11
+ MGNkYTczZGJmOTY1Zjg2MTM0ZjlhNDcyZTQzNjUzYzdmMDBiODM=
12
12
  data.tar.gz: !binary |-
13
- NmM1NWFiMTAzNjczNmYxOGNhZjQ3Y2Y5YThhN2M4ZDY3YmE4NGFjODc3NWQz
14
- ZjdkZDBlNWEzOWJiMTk3NjQxZjBkNDMxMWVmNGY1NDFiNmQ2MDhkNDBmZTE4
15
- ODI2MjA4NDZmYmFjYjU3NDdkYjI2MjI1NjBhZTVmZjZiMzg1NTg=
13
+ YjFiN2E5YjdiYmE1NjA3OTY5OTYyZDE5N2MzZGUyMjk1YjdmMTYzNmExNjRm
14
+ ZDhmMWE2OTFlMGYyZGRmNzMxZTIwMTliNjAyNDljNWRiN2MxYTdkMjg0OTcz
15
+ NGUwYjhmYTIzNDE3MDgzODE0YTdhMGNmNzM3NWEzN2VhYmRiNzk=
@@ -91,6 +91,8 @@ module Delorean
91
91
 
92
92
  class BaseClass
93
93
  def self._get_attr(obj, attr, _e)
94
+ # FIXME: even Javascript which is superpermissive raises an
95
+ # exception on null getattr.
94
96
  return nil if obj.nil?
95
97
 
96
98
  # NOTE: should keep this function consistent with _index
@@ -104,7 +106,13 @@ module Delorean
104
106
  return obj.send(attr.to_sym) if
105
107
  klass.reflect_on_all_associations.map(&:name).member? attr.to_sym
106
108
 
107
- raise InvalidGetAttribute, "ActiveRecord lookup '#{attr}' on #{obj}"
109
+ # FIXME: should call _instance_call for other types as well.
110
+ # Too lazy to implement this now.
111
+ begin
112
+ return _instance_call(obj, attr, [])
113
+ rescue
114
+ raise InvalidGetAttribute, "ActiveRecord lookup '#{attr}' on #{obj}"
115
+ end
108
116
  elsif obj.instance_of?(NodeCall)
109
117
  return obj.evaluate(attr)
110
118
  elsif obj.instance_of?(Hash)
@@ -113,7 +121,6 @@ module Delorean
113
121
  elsif obj.instance_of?(Class) && (obj < BaseClass)
114
122
  return obj.send((attr + POST).to_sym, _e)
115
123
  end
116
-
117
124
  raise InvalidGetAttribute,
118
125
  "bad attribute lookup '#{attr}' on <#{obj.class}> #{obj}"
119
126
  end
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -252,6 +252,14 @@ describe "Delorean" do
252
252
  r.should == "CRJ"
253
253
  end
254
254
 
255
+ it "should be able to access ActiveRecord whitelisted fns using .attr syntax" do
256
+ engine.parse defn("A:",
257
+ ' b = Dummy.i_just_met_you("CRJ", 1.234).name2',
258
+ )
259
+ r = engine.evaluate("A", "b")
260
+ r.should == "CRJ-1.234"
261
+ end
262
+
255
263
  it "should be able to get attr on Hash objects using a.b syntax" do
256
264
  engine.parse defn("A:",
257
265
  ' b = Dummy.i_threw_a_hash_in_the_well()',
@@ -60,6 +60,10 @@ class Dummy < ActiveRecord::Base
60
60
  end
61
61
 
62
62
  I_THREW_A_HASH_IN_THE_WELL_SIG = [0, 0]
63
+
64
+ def name2
65
+ "#{name}-#{number}"
66
+ end
63
67
  end
64
68
 
65
69
  module M
@@ -73,6 +77,11 @@ module M
73
77
  end
74
78
  end
75
79
 
80
+ Delorean::RUBY_WHITELIST.
81
+ merge!({
82
+ name2: [Dummy],
83
+ })
84
+
76
85
  ######################################################################
77
86
 
78
87
  class TestContainer < Delorean::AbstractContainer
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.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop