sweet-moon 0.0.1 → 0.0.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.
data/controllers/state.rb CHANGED
@@ -26,23 +26,48 @@ module Controller
26
26
  },
27
27
 
28
28
  get!: ->(api, interpreter, state, variable, key = nil) {
29
+ if key.nil?
30
+ key = variable
31
+ variable = '_G'
32
+ end
33
+
34
+ State[:_get_key!].(api, interpreter, state, variable, key)
35
+ },
36
+
37
+ _get_key!: ->(api, interpreter, state, variable, key) {
29
38
  result = State[:_check!].(
30
39
  interpreter[:get_variable_and_push!].(api, state, variable, key)
31
40
  )
32
41
 
33
- result = State[:_check!].(interpreter[:read_and_pop!].(
34
- api, result[:state], -1, extra_pop: !key.nil?
35
- ))
42
+ result = State[:_check!].(
43
+ interpreter[:read_and_pop!].(
44
+ api, result[:state], -1, extra_pop: result[:extra_pop]
45
+ )
46
+ )
36
47
 
37
48
  { state: result[:state], output: result[:output] }
38
49
  },
39
50
 
40
- set!: ->(api, interpreter, state, variable, value) {
41
- result = State[:_check!].(interpreter[:push_value!].(api, state, value))
42
-
43
- result = State[:_check!].(
44
- interpreter[:pop_and_set_as!].(api, result[:state], variable.to_s)
45
- )
51
+ set!: ->(api, interpreter, state, variable, key_or_value, value = nil) {
52
+ if value.nil?
53
+ result = State[:_check!].(interpreter[:push_value!].(api, state,
54
+ key_or_value))
55
+
56
+ result = State[:_check!].(
57
+ interpreter[:pop_and_set_as!].(api, result[:state], variable.to_s)
58
+ )
59
+ else
60
+ result = State[:_check!].(
61
+ interpreter[:get_variable_and_push!].(api, state, variable)
62
+ )
63
+
64
+ result = State[:_check!].(interpreter[:push_value!].(api, result[:state],
65
+ key_or_value))
66
+ result = State[:_check!].(interpreter[:push_value!].(api, result[:state],
67
+ value))
68
+
69
+ result = State[:_check!].(interpreter[:set_table!].(api, result[:state]))
70
+ end
46
71
 
47
72
  { state: result[:state], output: result[:output] }
48
73
  },
@@ -9,7 +9,7 @@ module DSL
9
9
  paths = path
10
10
  paths = [path] unless paths.is_a? Array
11
11
 
12
- self.eval("#{target} = #{target} .. \";#{paths.join(';')}\"")
12
+ self.eval("#{target} = \"#{paths.join(';')};\" .. #{target}")
13
13
  end
14
14
 
15
15
  def package_path(target = 'package.path')
data/dsl/fennel.rb CHANGED
@@ -11,6 +11,9 @@ module DSL
11
11
  'table.insert(package.loaders or package.searchers, fennel.searcher)'
12
12
  )
13
13
 
14
+ # TODO: Makes sense?
15
+ # debug.traceback = fennel.traceback
16
+
14
17
  @eval = @state.get(:fennel, :eval)
15
18
  @dofile = @state.get(:fennel, :dofile)
16
19
  @version = @state.get(:fennel, :version)
data/dsl/state.rb CHANGED
@@ -34,8 +34,10 @@ module DSL
34
34
  @controller[:get!].(@api, @interpreter, state, variable, key)[:output]
35
35
  end
36
36
 
37
- def set(variable, value)
38
- @controller[:set!].(@api, @interpreter, state, variable, value)[:output]
37
+ def set(variable, key_or_value, value = nil)
38
+ @controller[:set!].(
39
+ @api, @interpreter, state, variable, key_or_value, value
40
+ )[:output]
39
41
  end
40
42
 
41
43
  def destroy
@@ -6,6 +6,7 @@ module Logic
6
6
  LUA_REGISTRYINDEX: -10_000,
7
7
  LUA_GLOBALSINDEX: -10_001,
8
8
 
9
+ # lua_isinteger lua_pushinteger lua_tointeger
9
10
  requires: %i[
10
11
  lua_close lua_gettable lua_gettop lua_insert lua_newtable lua_next lua_open
11
12
  lua_pcall lua_pushboolean lua_pushcclosure lua_pushnil lua_pushnumber
@@ -12,11 +12,11 @@ module Logic
12
12
 
13
13
  # lua_isinteger lua_pushinteger lua_tointeger
14
14
  requires: %i[
15
- lua_close lua_createtable lua_getfield lua_getglobal lua_gettop lua_next
16
- lua_pcall lua_pushboolean lua_pushcclosure lua_pushnil lua_pushnumber
17
- lua_pushstring lua_rawgeti lua_setglobal lua_settable lua_settop lua_toboolean
18
- lua_tonumber lua_topointer lua_tostring lua_type lua_typename luaL_loadfile
19
- luaL_loadstring luaL_newstate luaL_openlibs luaL_ref
15
+ lua_close lua_createtable lua_getfield lua_gettop lua_next lua_pcall
16
+ lua_pushboolean lua_pushcclosure lua_pushnil lua_pushnumber lua_pushstring
17
+ lua_rawgeti lua_settable lua_settop lua_toboolean lua_tonumber lua_topointer
18
+ lua_tostring lua_type lua_typename luaL_loadfile luaL_loadstring luaL_newstate
19
+ luaL_openlibs luaL_ref lua_getglobal lua_setglobal
20
20
  ],
21
21
 
22
22
  status: {
data/logic/spec.rb CHANGED
@@ -2,11 +2,14 @@ module Logic
2
2
  Spec = {
3
3
  name: 'sweet-moon',
4
4
  command: 'sweet-moon',
5
- version: '0.0.1',
5
+ version: '0.0.4',
6
6
  author: 'gbaptista',
7
- summary: 'Lua / Fennel from Ruby and vice versa.',
7
+ summary: 'Lua / Fennel from Ruby and vice versa. Support to LuaJIT, Lua 5.0, ' \
8
+ 'and 5.1. Lua C API for Lua 5, 4, and 3. LuaRocks and fnx integration.',
8
9
  description: 'A resilient solution that makes working with Lua / Fennel from ' \
9
- 'Ruby and vice versa a delightful experience.',
10
+ "Ruby and vice versa a delightful experience.\n\n" \
11
+ 'Support to LuaJIT, Lua 5.0, and 5.1. Lua C API for Lua 5, 4, ' \
12
+ 'and 3. LuaRocks and fnx integration.',
10
13
  github: 'https://github.com/gbaptista/sweet-moon',
11
14
  license: 'MIT'
12
15
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sweet-moon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - gbaptista
8
8
  autorequire:
9
9
  bindir: ports/in/shell
10
10
  cert_chain: []
11
- date: 2022-03-20 00:00:00.000000000 Z
11
+ date: 2022-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -30,8 +30,10 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.15.5
33
- description: A resilient solution that makes working with Lua / Fennel from Ruby and
34
- vice versa a delightful experience.
33
+ description: |-
34
+ A resilient solution that makes working with Lua / Fennel from Ruby and vice versa a delightful experience.
35
+
36
+ Support to LuaJIT, Lua 5.0, and 5.1. Lua C API for Lua 5, 4, and 3. LuaRocks and fnx integration.
35
37
  email:
36
38
  executables:
37
39
  - sweet-moon
@@ -43,6 +45,7 @@ files:
43
45
  - ".rubocop.yml"
44
46
  - Gemfile
45
47
  - Gemfile.lock
48
+ - LICENSE
46
49
  - README.md
47
50
  - components/api.rb
48
51
  - components/injections.rb
@@ -133,5 +136,6 @@ requirements: []
133
136
  rubygems_version: 3.2.3
134
137
  signing_key:
135
138
  specification_version: 4
136
- summary: Lua / Fennel from Ruby and vice versa.
139
+ summary: Lua / Fennel from Ruby and vice versa. Support to LuaJIT, Lua 5.0, and 5.1.
140
+ Lua C API for Lua 5, 4, and 3. LuaRocks and fnx integration.
137
141
  test_files: []