transparent-lua 0.8.1 → 0.8.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45de970bf1cddd693ba675a7132668c2e9405b67
4
- data.tar.gz: 750dd4bdaea7412106b05f88fe6817fd9638b292
3
+ metadata.gz: a126305ad9b96ba8fb19d04f79708ee1886a0e20
4
+ data.tar.gz: f99a404b17d4b2bb6336d87c77972bc896e79c7b
5
5
  SHA512:
6
- metadata.gz: 84698ddea80f1e079e9ead57a64ce137d6fdf8c4fbe129fe066add23e97c0dc24532639ff02fa3003b2100aa25a12e9bc75d750c88d53f3eb3bbf6f0286a2839
7
- data.tar.gz: 024da8693ad602c5c183f616e20c54cbcea6bf95911f5dbb4178467ee5314bfaad7fdf3abf4d766ee3d90f70cf753cd76ef394fb8ab96bc6c7289b40633088a7
6
+ metadata.gz: c36bd8b18999098fbe41ab2ca160c29373e6fd7773da56b05e468982b225f7182e4e6df3c6797be9531e08416645b61969c8b50eb8b914b1cfec37394d0a10af
7
+ data.tar.gz: d4cb5497c7bf2845f7b31a9e04e51eccea90d417566689f3692d941d1bbe00996ca3687dfe96bcbff126aafd2fa0f2fb8ed3ac31af0da54c07500b96ec7cd69b
@@ -3,16 +3,14 @@ require 'logger'
3
3
 
4
4
  class TransparentLua
5
5
  SUPPORTED_SIMPLE_DATATYPES = [
6
- NilClass,
7
- TrueClass,
8
- FalseClass,
9
- Fixnum,
10
- Bignum,
11
- Float,
12
- Proc,
13
- String,
14
- Hash,
15
- Array,
6
+ NilClass,
7
+ TrueClass,
8
+ FalseClass,
9
+ Fixnum,
10
+ Bignum,
11
+ Float,
12
+ Proc,
13
+ String,
16
14
  ]
17
15
 
18
16
  attr_reader :sandbox, :state, :logger
@@ -44,7 +42,7 @@ class TransparentLua
44
42
  state.__load_stdlib :all
45
43
 
46
44
  global_metatable = {
47
- '__index' => index_table(sandbox)
45
+ '__index' => index_table(sandbox)
48
46
  }
49
47
  global_metatable['__newindex'] = newindex_table(sandbox) if leak_globals
50
48
 
@@ -78,13 +76,11 @@ class TransparentLua
78
76
  end
79
77
 
80
78
  def getter_table(object)
81
- if SUPPORTED_SIMPLE_DATATYPES.include? object.class
82
- return object
83
- end
79
+ return object if is_supported_simple_datatype? object
84
80
 
85
81
  metatable = {
86
- '__index' => index_table(object),
87
- '__newindex' => newindex_table(object),
82
+ '__index' => index_table(object),
83
+ '__newindex' => newindex_table(object),
88
84
  }
89
85
  delegation_table(object, metatable)
90
86
  end
@@ -122,13 +118,13 @@ class TransparentLua
122
118
  # @param [Method] method
123
119
  def method_table(method)
124
120
  delegation_table(
125
- '__call' => ->(t, *args) do
126
- converted_args = args.collect do |arg|
127
- lua2rb(arg)
128
- end
129
-
130
- getter_table(method.call(*converted_args))
121
+ '__call' => ->(t, *args) do
122
+ converted_args = args.collect do |arg|
123
+ lua2rb(arg)
131
124
  end
125
+
126
+ getter_table(method.call(*converted_args))
127
+ end
132
128
  )
133
129
  end
134
130
 
@@ -166,10 +162,17 @@ class TransparentLua
166
162
  def get_ruby_method_name(lua_method_name)
167
163
  lua_method_name = String(lua_method_name)
168
164
  case lua_method_name
169
- when /^is_(.*)$/, /^(has_.*)$/
165
+ when /^is_(.*)$/, /^has_(.*)$/
170
166
  return :"#{$1}?"
171
167
  else
172
168
  return lua_method_name.to_sym
173
169
  end
174
170
  end
171
+
172
+ def is_supported_simple_datatype?(object)
173
+ return true if SUPPORTED_SIMPLE_DATATYPES.include? object.class
174
+ return true if Array === object && object.all? { |i| is_supported_simple_datatype?(i) }
175
+ return true if Hash === object && object.keys.all? { |k| is_supported_simple_datatype?(k) } && object.values.all? { |v| is_supported_simple_datatype?(v) }
176
+ false
177
+ end
175
178
  end
@@ -1,3 +1,3 @@
1
1
  class TransparentLua
2
- VERSION = '0.8.1'
2
+ VERSION = '0.8.2'
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.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rlua