transparent-lua 0.1 → 0.2

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
- NThmMTMyNjhhM2Y1YTJlYjk2NGZhMmM1MzVkOGJmZDY2YTMzOWFjOQ==
4
+ YmYyZGQ3NzY0YzU1ZDBiY2I1YmE5YTA2MmI5ZjFlMGFlYmVhMWY0Mw==
5
5
  data.tar.gz: !binary |-
6
- NTYzNzE4MzU5YzkxODYwMjk5Y2UxNjE4YzQ5MWViNmM2NWFmN2ZjNw==
6
+ ODU4YjU0YWUxMWVmOWNiOWZiNDU5ZmEwMjBhODcyZGU2MzQzYzdiZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzQxODUwYjIzYWFiY2Y4OGFlY2E4ZGQ2NGYzMWE4NDRmMGFlNGQzNzk2MDdl
10
- NWZhZDI0MTk4NjkyYzA5MGY2NGFhZDAxZDMxZDAyMWU5ZmNiMDU5YzdlYjY5
11
- M2ZhNDZlZjJjNDBlOGJiODI2Y2FlNTI4ZTYzODAwOTUwN2Y5NDU=
9
+ NzQwZmExYjYxNzRiZTBiOGNmOGU1MjQ0NGM4ODJiN2FlMTcyOWQ3OGZmYzEz
10
+ NmU5ZjgwOGI1NDhkNDNmYjEwM2Y4ZTExYTAzNTc3ODc4NTE0ZmI5YTljYzVj
11
+ NjFlN2Q0MGNkMDQwNzY2YzNkNzFlN2M0ZjlkNjE3NTQzYjk0YjI=
12
12
  data.tar.gz: !binary |-
13
- NGViNzA2ZWU0ZTEzZWU3NjJjNmU2ZjJkNGYwMDk0YzQxYjY3OWM0ZDcxYTg2
14
- Nzc5MDczZTBhYzA0NDg1YzMxYTQwYjI0Zjk2ZTQzYWZkZGRiZjlmMTg0ZmI5
15
- ZjhkZjczODMyMDI4ZjFjY2FiZThjZDhmNGY3YjQ5ZmYxMTI0NjE=
13
+ MjQwMWJlZTFjMjUzMjAxMGJiMjk2ZjFhZjZmYzJmYTNlMzlmYmQzNjM1YTEw
14
+ NWYyNWRlZGMzODY0MjZlZGVmODExMTI5NWRhMGE3N2U1MjFhNzIwMDg0Y2Vk
15
+ MzQ2OTRjYWY5MzUwZjVhMWEwNjU3YjA5NGY5YzkxNmZkN2U0N2I=
@@ -62,4 +62,15 @@ Feature: Sandbox exposition
62
62
  When I execute the script
63
63
  Then it should return "HELLO"
64
64
 
65
+ Scenario: Setting attributes of members
66
+ Given an empty sandbox
67
+ And the following code executed in the sandbox: def struct; @struct ||= Struct.new(:attr).new; end
68
+ And the following Lua script:
69
+ """
70
+ s = struct
71
+ s.attr = 'Hi'
72
+ """
73
+ When I execute the script
74
+ Then the result of @sandbox.struct.values should include('Hi')
75
+
65
76
 
@@ -32,7 +32,7 @@ Given(/^an sandbox with an empty member class$/) do
32
32
  end
33
33
  end
34
34
 
35
- And(/^the following method definition as part of the sandbox: (.*)$/) do |method_definition|
35
+ And(/^the following (?:method definition as part of|code executed in) the sandbox: (.*)$/) do |method_definition|
36
36
  @sandbox_class.class_eval(method_definition)
37
37
  end
38
38
 
@@ -44,4 +44,7 @@ And(/^the following line as Lua script: (.*)$/) do |script|
44
44
  @script = String(script).strip
45
45
  end
46
46
 
47
+ And(/^the following Lua script:$/) do |script|
48
+ @script = String(script).strip
49
+ end
47
50
 
@@ -9,3 +9,8 @@ Then(/^the attribute "([^"]*)" of the sandbox is (.*)$/) do |attribute, expected
9
9
 
10
10
  expect(@sandbox.public_send(attribute.to_sym)).to eq(expected_return_value)
11
11
  end
12
+
13
+
14
+ Then(/^the result of (.+) should (.*)$/) do |subject, expectation|
15
+ expect(instance_eval(String(subject))).to eval(expectation)
16
+ end
@@ -23,9 +23,9 @@ class TransparentLua
23
23
  # The sandbox must store the values itself or an error will be raised.
24
24
  # When false the locals are not reflected in the sandbox
25
25
  def initialize(sandbox, options = {})
26
- @sandbox = sandbox
27
- @state = options.fetch(:state) { Lua::State.new }
28
- leak_locals = options.fetch(:leak_globals) { false }
26
+ @sandbox = sandbox
27
+ @state = options.fetch(:state) { Lua::State.new }
28
+ leak_locals = options.fetch(:leak_globals) { false }
29
29
  setup(leak_locals)
30
30
  end
31
31
 
@@ -53,7 +53,10 @@ class TransparentLua
53
53
  return object
54
54
  end
55
55
 
56
- metatable = { '__index' => index_table(object) }
56
+ metatable = {
57
+ '__index' => index_table(object),
58
+ '__newindex' => newindex_table(object),
59
+ }
57
60
  metatable(metatable)
58
61
  end
59
62
 
@@ -1,3 +1,3 @@
1
1
  class TransparentLua
2
- VERSION = 0.1
2
+ VERSION = 0.2
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transparent-lua
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Haase