transparent-lua 0.6 → 0.6.1

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
- ZTlhMmE0NTMxZTY0ZDZjZjMzNzM3ZWY0YzdhMWFlYmNmNDNjNDQxZQ==
4
+ YWQ4YjFmNGNmNmJmMmU4OTBlOGY3NTYzN2U3ZGNkMTFiYWQ4YjllZA==
5
5
  data.tar.gz: !binary |-
6
- Y2UzNDM3MGFkNjYyNzkzNDI5YmJiNjkwZDRiOTNhYjU3NTdlM2Q0Mw==
6
+ ZjZmNDJhNzRlODIyMmJkMDRlY2Q5M2I0MzZiNjRmMDM2NjY1N2RjNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTNkNWExYWEyZGVkYzgxMGY3NmNmOWVjYzI4MDk4MzUwNGI5ZDlhMGZjYjZj
10
- NzQ2YjAzYWU0NTI4ZjA5NGMwZWI2OGQwYzk0NTMyMTAwNTU3NWE1Y2RkMzhl
11
- NzBkODBkNTRlNDliZDAyMDJkNTk5YTk2NTBhYjI0ZGE0OTgzNjM=
9
+ YjA0MzZiMTM1MGE4NDA4MTEzNWUyYWYyNTZmMWM3YWRiMjIwODI1N2VlNDc2
10
+ ODg2M2NhZDhlYWEwNThiZTc4NDc4ODQ2OWQ1Mzc1MGIzYmNmZDgzOTkyNDcy
11
+ NGNlNDk1YmEzYTYzMTc2OTU3Nzg0YzgyZjM5YmVkOGEwMDg4N2M=
12
12
  data.tar.gz: !binary |-
13
- NzM4ZjA1MTZiNGE1ZWJkMzVlNWQ0OTBlZjVjMTE4MjM3NGY5NTc0YzhhNzIy
14
- MDFiYTM2NzdmZTkzZTI3ZGY0NDdjZTE4MDUwN2RmYjYzYzkwMmVhOWUyMzJl
15
- OTYwMjE1MjdmM2Y4ZjU1ZjY4Zjc1NTkxYTA3NDE5Y2RlZGY1ZDg=
13
+ YzAxMDk0ZjkyOGZlOTcyNTVkNjg2MzY0Njg5ZWJhZGFkNmYzMzJjMjIzYzUw
14
+ YTA3ZjMyM2E4YWMxN2ZjOWQ3OWE2YjVmN2RiMWIyNjU3OWU5N2RhMzlkNWEy
15
+ ZmQ2YThhZmZhMTQwNmUwNTQ1OGE3MzNhNDc3NmY3NWUzZmY4MDg=
@@ -0,0 +1 @@
1
+ require 'cucumber/rspec/doubles'
@@ -1,4 +1,5 @@
1
1
  require 'rlua'
2
+ require 'logger'
2
3
 
3
4
  class TransparentLua
4
5
  SUPPORTED_SIMPLE_DATATYPES = [
@@ -14,7 +15,7 @@ class TransparentLua
14
15
  Array,
15
16
  ]
16
17
 
17
- attr_reader :sandbox, :state
18
+ attr_reader :sandbox, :state, :logger
18
19
 
19
20
  # @param [Object] sandbox The object which will be made visible to the lua script
20
21
  # @param [Hash] options
@@ -25,6 +26,7 @@ class TransparentLua
25
26
  def initialize(sandbox, options = {})
26
27
  @sandbox = sandbox
27
28
  @state = options.fetch(:state) { Lua::State.new }
29
+ @logger = options.fetch(:logger) { Logger.new('/dev/null') }
28
30
  leak_locals = options.fetch(:leak_globals) { false }
29
31
  setup(leak_locals)
30
32
  end
@@ -97,18 +99,14 @@ class TransparentLua
97
99
  def index_table(object)
98
100
  ->(t, k, *newindex_args) do
99
101
  method = get_method(object, k)
102
+ logger.debug { "Dispatching method #{method}(#{method.parameters})" }
100
103
 
101
104
  case method
102
105
  when ->(m) { m.arity == 0 }
103
- # No or mandatory arguments
106
+ logger.debug { "Creating a getter table for #{method}" }
104
107
  getter_table(object.public_send(k.to_sym, *newindex_args))
105
- # when ->(m) { m.parameters == [[:rest]] }
106
- # # Forced to be a method
107
- # method_table(method)
108
- # when ->(m) { m.arity < 0 }
109
- # warn "Method #{method} has optional parameters. We dont like that"
110
- # method_table(method)
111
108
  else
109
+ logger.debug { "Creating a method table for #{method}" }
112
110
  method_table(method)
113
111
  end
114
112
  end
@@ -144,9 +142,9 @@ class TransparentLua
144
142
  when ->(t) { has_rb_object_id?(t) }
145
143
  ObjectSpace._id2ref(Integer(v.__rb_object_id))
146
144
  when ->(t) { Lua::Table === t && t.to_hash.keys.all? { |k| k.is_a? Numeric } }
147
- v.to_hash.values
145
+ v.to_hash.values.collect { |v| lua2rb(v) }
148
146
  when Lua::Table
149
- v.to_hash
147
+ v.to_hash.each_with_object({}) { |(k, v), h| h[lua2rb(k)] = lua2rb(v) }
150
148
  else
151
149
  v
152
150
  end
@@ -1,3 +1,3 @@
1
1
  class TransparentLua
2
- VERSION = 0.6
2
+ VERSION = '0.6.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transparent-lua
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-17 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rlua
@@ -79,6 +79,7 @@ files:
79
79
  - Guardfile
80
80
  - README.md
81
81
  - Rakefile
82
+ - features/env.rb
82
83
  - features/sandbox_exposition.feature
83
84
  - features/step_definitions/preparation_steps.rb
84
85
  - features/step_definitions/transparent_lua_steps.rb
@@ -114,6 +115,7 @@ specification_version: 4
114
115
  summary: This library enables an easy way to pass complex objects between Ruby and
115
116
  Lua in a transparent way.
116
117
  test_files:
118
+ - features/env.rb
117
119
  - features/sandbox_exposition.feature
118
120
  - features/step_definitions/preparation_steps.rb
119
121
  - features/step_definitions/transparent_lua_steps.rb