sweet-moon 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e216a8bf96c191f08675bad6b2d4d9a1dceb9649a5e856ce4d6b4894e09b35e
4
- data.tar.gz: b807eb9b92df1e53a0e0011f6132724c95b11a76dafab1073a46d2c5bf35c6ab
3
+ metadata.gz: 46891cd3e8103176f3f909415432df155df1bd33cbed89a80f0042f5d303a2b7
4
+ data.tar.gz: af7617e43eacc588135285dbd652f644d9bda8b87735c86ff89a7719ce6bfe1a
5
5
  SHA512:
6
- metadata.gz: 538a7a773c11fe66a13c0be49efeb1f8d37da83f52a85d32fe8a7c52b3b590d155b0cdfb50efec3755181947db6a7b67a238b31c10bc382362b70301594949fb
7
- data.tar.gz: 95d84ea3cf24919e4646c766f66302308f22392434ba5f76b0ae7743d4ef9ad3868d90b13b3d4bf26d58d7500d276b88be7ee26393818cf00950f08f4e6c4fc6
6
+ metadata.gz: 1949e5f83c00dd65cdf78e2e8ebd4f66654dc24df1769add99ad8f01e75cc97bcb090e9d0dc0cf5d10dcdd4d1d338252b4ad78894bd3d4cef40b91ae31aab3d0
7
+ data.tar.gz: 9a09f1231c7e02250f232e368abd95b7bb1b4d5e366ef2614ce9871248c49201fb480b8b698833df66d769e7688602e8c3415a454366ef5ad3ede02163e1c5a4
data/README.md CHANGED
@@ -30,7 +30,9 @@ _Sweet Moon_ is a resilient solution that makes working with [Lua](https://www.l
30
30
  - [Fennel Global vs Local Variables](#fennel-global-vs-local-variables)
31
31
  - [Fennel Setup](#fennel-setup)
32
32
  - [Integration with fnx](#integration-with-fnx)
33
+ - [Fennel REPL](#fennel-repl)
33
34
  - [Global vs Isolated](#global-vs-isolated)
35
+ - [Global FFI](#global-ffi)
34
36
  - [Error Handling](#error-handling)
35
37
  - [Ruby feat. Lua Errors](#ruby-feat-lua-errors)
36
38
  - [Where can I find .so files?](#where-can-i-find-so-files)
@@ -72,7 +74,7 @@ gem install sweet-moon
72
74
  > **Disclaimer:** It's an early-stage project, and you should expect breaking changes.
73
75
 
74
76
  ```ruby
75
- gem 'sweet-moon', '~> 0.0.5'
77
+ gem 'sweet-moon', '~> 0.0.6'
76
78
  ```
77
79
 
78
80
  ```ruby
@@ -889,6 +891,44 @@ To enforce the path for the `.fnx.fnl` file:
889
891
  fennel.eval('(let [fnx (require :fnx)] (fnx.bootstrap! "/project/.fnx.fnl"))')
890
892
  ```
891
893
 
894
+ ### Fennel REPL
895
+
896
+ In Ruby, you can start a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) at any time somewhere in your code with [_pry_](https://github.com/pry/pry):
897
+
898
+ ```ruby
899
+ require 'pry'
900
+
901
+ binding.pry
902
+ ```
903
+
904
+ The same is true for Fennel, you just need to:
905
+ ```fnl
906
+ (let [fennel (require :fennel)]
907
+ (fennel.repl {}))
908
+ ```
909
+
910
+ Fennel's REPL won't have your _local_ values. But, you can tweak it to receive values to be checked inside the REPL:
911
+
912
+ ```fnl
913
+ (fn my-repl [to-expose]
914
+ (let [fennel (require :fennel) env _G]
915
+ (each [key value (pairs to-expose)] (tset env key value))
916
+ (fennel.repl {:env env})))
917
+
918
+ (local value "some value")
919
+
920
+ (my-repl {:value value})
921
+
922
+ ; Inside the REPL:
923
+
924
+ ; >> value
925
+ ; "some value"
926
+ ```
927
+
928
+ You can install [_readline_](https://luarocks.org/modules/peterbillam/readline) for a better experience, e.g., autocompleting.
929
+
930
+ > _Check [Fennel's documentation](https://fennel-lang.org/api#start-a-configurable-repl) to learn more about the REPL._
931
+
892
932
  ## Global vs Isolated
893
933
 
894
934
  You can use the **global** helper that provides an _API_ and a _State_ for quick-and-dirty coding. It uses internally a Ruby [_Singleton_](https://docs.ruby-lang.org/en/3.1/Singleton.html):
@@ -935,6 +975,8 @@ api_5.luaL_newstate
935
975
  api_3.luaH_new
936
976
  ```
937
977
 
978
+ > _Check the caveats related to [_Global FFI_](#global-ffi) when working with multiple versions._
979
+
938
980
  On the other hand, using the **global** _State_ may lead to a lot of issues. You need to consider from simple things – _"If I load two different files, the first file may impact the state of the second one?"_ – to more complex ones like multithreading, concurrency, etc.
939
981
 
940
982
  So, you can at any time create a new isolated _State_ and destroy it when you don't need it anymore:
@@ -964,6 +1006,48 @@ state_5.eval('return _VERSION') # => Lua 5.4
964
1006
  state_3.eval('return _VERSION') # => Lua 3.2
965
1007
  ```
966
1008
 
1009
+ > _Check the caveats related to [_Global FFI_](#global-ffi) when working with multiple versions._
1010
+
1011
+ ## Global FFI
1012
+
1013
+ Some Lua libraries (e.g., [_readline_](https://pjb.com.au/comp/lua/readline.html) and [_luafilesystem_](https://keplerproject.github.io/luafilesystem/)) require the Lua C API functions available in the global C environment.
1014
+
1015
+ By default, _Sweet Moon_ enables [_Global FFI_](https://github.com/ffi/ffi/wiki/Loading-Libraries#function-visibility) to reduce friction when using popular libraries.
1016
+
1017
+ Using distinct Lua versions simultaneously with multiple _Shared Objects_ may be dangerous in this setup: Two APIs with the same name functions could be an issue because something will be overwritten.
1018
+
1019
+ Also, libraries that need Lua C API functions are compiled for a specific Lua version. If you are, e.g., using _LuaJIT_ and your library expects the _Standard Lua_, you may face issues.
1020
+
1021
+ You can disable _Global FFI_ at any time with:
1022
+
1023
+ ```ruby
1024
+ require 'sweet-moon'
1025
+
1026
+ SweetMoon.global.config(global_ffi: false)
1027
+
1028
+ SweetMoon::State.new(global_ffi: false)
1029
+
1030
+ SweetMoon::API.new(global_ffi: false)
1031
+ ```
1032
+
1033
+ To check if it's enabled or not:
1034
+
1035
+ ```ruby
1036
+ require 'sweet-moon'
1037
+
1038
+ SweetMoon.global.api.meta.global_ffi # => true
1039
+ SweetMoon.global.state.meta.global_ffi # => true
1040
+
1041
+ SweetMoon::API.new.meta.global_ffi # => true
1042
+
1043
+ SweetMoon::State.new.meta.global_ffi # => true
1044
+ ```
1045
+
1046
+ **Caveats:**
1047
+
1048
+ Binding globally a C API is irreversible, so if you start something with `global_ffi: true` and then change to `global_ffi: false`, it won't make the global one disappear. If you need _local_, ensure that you do it from the first line and never put anything as global throughout the entire program life cycle.
1049
+
1050
+ Also, the simple action of accessing `meta.global_ff` will bind the API, so you need to set your desired configuration before checking.
967
1051
 
968
1052
  ## Error Handling
969
1053
 
@@ -1364,6 +1448,8 @@ Update the [`config/tests.yml`](https://github.com/gbaptista/sweet-moon/blob/mai
1364
1448
 
1365
1449
  Alternatively: Find or build the _Shared Objects_ for your Operating System on your own.
1366
1450
 
1451
+ Install the expected Lua _rocks_ described in `config/tests.yml`.
1452
+
1367
1453
  ### Running
1368
1454
 
1369
1455
  ```sh
data/components/api.rb CHANGED
@@ -2,7 +2,7 @@ require 'ffi'
2
2
 
3
3
  module Component
4
4
  API = {
5
- open!: ->(shared_objects) {
5
+ open!: ->(shared_objects, options = {}, default = {}) {
6
6
  api = Module.new
7
7
 
8
8
  api.extend FFI::Library
@@ -10,8 +10,11 @@ module Component
10
10
  # TODO: Lua Constants
11
11
  # attach_variable
12
12
 
13
- if shared_objects.size > 1
14
- # TODO: Dangerous
13
+ global_ffi = default[:global_ffi]
14
+
15
+ global_ffi = options[:global_ffi] unless options[:global_ffi].nil?
16
+
17
+ if global_ffi
15
18
  api.ffi_lib_flags(:global, :now)
16
19
  else
17
20
  api.ffi_lib_flags(:local, :now)
@@ -0,0 +1,17 @@
1
+ require 'singleton'
2
+
3
+ module Component
4
+ class Default
5
+ include Singleton
6
+
7
+ attr_reader :options
8
+
9
+ def initialize
10
+ @options = { global_ffi: true }
11
+ end
12
+
13
+ def set(key, value)
14
+ @options[key.to_sym] = value
15
+ end
16
+ end
17
+ end
@@ -4,16 +4,16 @@ module Component
4
4
  module V50
5
5
  Function = Component::V54::Function
6
6
 
7
- LUA_HANDLER = <<LUA
8
- return function (...)
9
- result = _ruby(unpack(arg))
7
+ LUA_HANDLER = <<~LUA
8
+ return function (...)
9
+ result = _ruby(unpack(arg))
10
10
 
11
- if result['error'] then
12
- error(result['output'])
13
- else
14
- return result['output']
11
+ if result['error'] then
12
+ error(result['output'])
13
+ else
14
+ return result['output']
15
+ end
15
16
  end
16
- end
17
- LUA
17
+ LUA
18
18
  end
19
19
  end
@@ -96,16 +96,16 @@ module Component
96
96
  }
97
97
  }
98
98
 
99
- LUA_HANDLER = <<LUA
100
- return function (...)
101
- result = _ruby(...)
102
-
103
- if result['error'] then
104
- error(result['output'] .. ' ' .. debug.traceback())
105
- else
106
- return result['output']
99
+ LUA_HANDLER = <<~LUA
100
+ return function (...)
101
+ result = _ruby(...)
102
+
103
+ if result['error'] then
104
+ error(result['output'] .. ' ' .. debug.traceback())
105
+ else
106
+ return result['output']
107
+ end
107
108
  end
108
- end
109
- LUA
109
+ LUA
110
110
  end
111
111
  end
@@ -3,11 +3,12 @@
3
3
  fennel-dev: '/home/me/sweet-moon-test/fennel/dev/?.lua'
4
4
 
5
5
  luarocks:
6
+ expected: ['dkjson', 'supernova', 'readline']
6
7
  path:
7
8
  - /home/me/.luarocks/share/lua/5.4/?.lua
8
9
  - /home/me/.luarocks/share/lua/5.4/?/init.lua
10
+ cpath:
9
11
  - /home/me/.luarocks/lib/lua/5.4/?.so
10
- expected: ['supernova', 'dkjson', 'lfs']
11
12
 
12
13
  jit:2.0.5:
13
14
  description: 'Lua Jit 2.0.5 + Fennel 1.0.0'
data/controllers/api.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require_relative '../components/injections'
2
2
  require_relative '../components/api'
3
+ require_relative '../components/default'
3
4
  require_relative '../components/io'
4
5
  require_relative '../dsl/errors'
5
6
 
@@ -11,7 +12,9 @@ module Controller
11
12
  handle!: ->(options) {
12
13
  shared_objects = API[:elect_shared_objects!].(options[:shared_objects])
13
14
 
14
- api = Component::API[:open!].(shared_objects)
15
+ api = Component::API[:open!].(
16
+ shared_objects, options, Component::Default.instance.options
17
+ )
15
18
 
16
19
  api_reference = API[:elect_api_reference!].(
17
20
  api.ffi_libraries, options[:api_reference]
data/dsl/api.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require_relative '../components/default'
2
+
1
3
  module DSL
2
4
  class Api
3
5
  attr_reader :functions, :meta
@@ -7,13 +9,31 @@ module DSL
7
9
 
8
10
  @functions = @component[:signatures].keys
9
11
 
10
- @meta = Struct.new(
11
- *@component[:meta][:elected].keys
12
- ).new(*@component[:meta][:elected].values)
12
+ build_meta
13
13
 
14
14
  extend @component[:api]
15
15
  end
16
16
 
17
+ def build_global_ffi
18
+ global_ffi = Component::Default.instance.options[:global_ffi]
19
+
20
+ unless @component[:meta][:options][:global_ffi].nil?
21
+ global_ffi = @component[:meta][:options][:global_ffi]
22
+ end
23
+
24
+ global_ffi
25
+ end
26
+
27
+ def build_meta
28
+ meta_data = @component[:meta][:elected].clone
29
+
30
+ meta_data[:global_ffi] = build_global_ffi
31
+
32
+ @meta = Struct.new(
33
+ *meta_data.keys
34
+ ).new(*meta_data.values)
35
+ end
36
+
17
37
  def signature_for(function)
18
38
  @component[:signatures][function.to_sym]
19
39
  end
data/dsl/cache.rb CHANGED
@@ -7,112 +7,126 @@ require_relative '../controllers/state'
7
7
  require_relative 'api'
8
8
  require_relative 'sweet_moon'
9
9
 
10
- class Cache
11
- include Singleton
10
+ module DSL
11
+ class Cache
12
+ include Singleton
12
13
 
13
- def clear_global!
14
- @cache[:global_state]&._unsafely_destroy
14
+ API_KEYS = %i[shared_objects api_reference global_ffi]
15
+ STATE_KEYS = %i[interpreter package_path package_cpath]
15
16
 
16
- @cache.each_key { |key| @cache.delete(key) if key[/^global/] }
17
- end
17
+ def api_keys?(options)
18
+ API_KEYS.each { |key| return true if options.key?(key) }
19
+ false
20
+ end
18
21
 
19
- def keys
20
- @cache.keys
21
- end
22
+ def state_keys?(options)
23
+ STATE_KEYS.each { |key| return true if options.key?(key) }
24
+ false
25
+ end
22
26
 
23
- def initialize
24
- @cache = {}
25
- end
27
+ def clear_global!
28
+ @cache[:global_state]&._unsafely_destroy
26
29
 
27
- def global_state(options = {}, recreate: false)
28
- key = :global_state
30
+ @cache.each_key { |key| @cache.delete(key) if key[/^global/] }
31
+ end
29
32
 
30
- clear_global_state_cache!(options) if recreate
33
+ def keys
34
+ @cache.keys
35
+ end
31
36
 
32
- return @cache[key] if @cache[key]
37
+ def initialize
38
+ @cache = {}
39
+ end
33
40
 
34
- api = Cache.instance.api_module(options, :global_api_module)
35
- interpreter = Cache.instance.interpreter_module(
36
- api, options, :global_interpreter_module
37
- )
41
+ def global_state(options = {}, recreate: false)
42
+ key = :global_state
38
43
 
39
- @cache[key] = DSL::State.new(api, interpreter, Controller::State, options)
40
- @cache[key].instance_eval('undef :destroy', __FILE__, __LINE__)
44
+ clear_global_state_cache!(options) if recreate
41
45
 
42
- @cache[key]
43
- end
46
+ return @cache[key] if @cache[key]
44
47
 
45
- def global_api(options = {}, recreate: false)
46
- key = :global_api
48
+ api = Cache.instance.api_module(options, :global_api_module)
49
+ interpreter = Cache.instance.interpreter_module(
50
+ api, options, :global_interpreter_module
51
+ )
47
52
 
48
- clear_global_api_cache! if recreate
53
+ @cache[key] = DSL::State.new(api, interpreter, Controller::State, options)
54
+ @cache[key].instance_eval('undef :destroy', __FILE__, __LINE__)
49
55
 
50
- @cache[key] ||= api(options, :global_api, :global_api_module)
51
- end
56
+ @cache[key]
57
+ end
52
58
 
53
- def api(options = {}, key = nil, api_module_key = nil)
54
- key ||= cache_key_for(:api, options, %i[shared_objects api_reference])
55
- @cache[key] ||= DSL::Api.new(api_module(options, api_module_key))
56
- end
59
+ def global_api(options = {}, recreate: false)
60
+ key = :global_api
57
61
 
58
- def api_module(options = {}, key = nil)
59
- key ||= cache_key_for(:api_module, options, %i[shared_objects api_reference])
60
- @cache[key] ||= Controller::API[:handle!].(options)
61
- end
62
+ clear_global_api_cache! if recreate
62
63
 
63
- def interpreter_module(api, options = {}, key = nil)
64
- key ||= cache_key_for(
65
- :interpreter_module,
66
- { shared_objects: api[:meta][:elected][:shared_objects],
67
- api_reference: api[:meta][:elected][:api_reference],
68
- interpreter: options[:interpreter], package_path: options[:package_path],
69
- package_cpath: options[:package_cpath] },
70
- %i[shared_objects api_reference interpreter package_path package_cpath]
71
- )
72
-
73
- @cache[key] ||= Controller::Interpreter[:handle!].(api, options)
74
- end
64
+ @cache[key] ||= api(options, :global_api, :global_api_module)
65
+ end
75
66
 
76
- private
67
+ def api(options = {}, key = nil, api_module_key = nil)
68
+ key ||= cache_key_for(:api, options, API_KEYS)
69
+ @cache[key] ||= DSL::Api.new(api_module(options, api_module_key))
70
+ end
77
71
 
78
- def clear_global_api_cache!
79
- @cache[:global_state]&._unsafely_destroy
72
+ def api_module(options = {}, key = nil)
73
+ key ||= cache_key_for(:api_module, options, API_KEYS)
74
+ @cache[key] ||= Controller::API[:handle!].(options)
75
+ end
80
76
 
81
- %i[global_api global_api_module
82
- global_interpreter_module
83
- global_state].each do |key|
84
- @cache.delete(key)
77
+ def interpreter_module(api, options = {}, key = nil)
78
+ key ||= cache_key_for(
79
+ :interpreter_module,
80
+ { shared_objects: api[:meta][:elected][:shared_objects],
81
+ api_reference: api[:meta][:elected][:api_reference],
82
+ global_ffi: api[:meta][:global_ffi],
83
+ interpreter: options[:interpreter], package_path: options[:package_path],
84
+ package_cpath: options[:package_cpath] },
85
+ API_KEYS.concat(STATE_KEYS)
86
+ )
87
+
88
+ @cache[key] ||= Controller::Interpreter[:handle!].(api, options)
85
89
  end
86
- end
87
90
 
88
- def clear_global_state_cache!(options)
89
- @cache[:global_state]&._unsafely_destroy
91
+ def cache_key_for(prefix, options = {}, relevant_keys = [])
92
+ values = [prefix]
90
93
 
91
- %i[global_interpreter_module global_state].each do |key|
92
- @cache.delete(key)
93
- end
94
+ relevant_keys.each do |key|
95
+ value = options[key]
96
+ value = options[key.to_s] if value.nil?
94
97
 
95
- return unless options.key?(:shared_objects) || options.key?(:api_reference)
98
+ values << (value.is_a?(Array) ? value.sort.join(':') : value.inspect)
99
+ end
96
100
 
97
- %i[global_api global_api_module].each do |key|
98
- @cache.delete(key)
101
+ values.join('|')
99
102
  end
100
103
 
101
- global_api(options, recreate: true)
102
- end
104
+ private
103
105
 
104
- def cache_key_for(prefix, options = {}, relevant_keys = [])
105
- values = [prefix]
106
+ def clear_global_api_cache!
107
+ @cache[:global_state]&._unsafely_destroy
106
108
 
107
- relevant_keys.each do |key|
108
- value = options[key] || options[key.to_s]
109
- if value.is_a?(Array)
110
- values << value.sort.join(':')
111
- elsif value
112
- values << value
109
+ %i[global_api global_api_module
110
+ global_interpreter_module
111
+ global_state].each do |key|
112
+ @cache.delete(key)
113
113
  end
114
114
  end
115
115
 
116
- values.join('|')
116
+ def clear_global_state_cache!(options)
117
+ @cache[:global_state]&._unsafely_destroy
118
+
119
+ %i[global_interpreter_module global_state].each do |key|
120
+ @cache.delete(key)
121
+ end
122
+
123
+ return unless api_keys?(options)
124
+
125
+ %i[global_api global_api_module].each do |key|
126
+ @cache.delete(key)
127
+ end
128
+
129
+ global_api(options, recreate: true)
130
+ end
117
131
  end
118
132
  end
data/dsl/global.rb CHANGED
@@ -2,41 +2,40 @@ require_relative '../logic/options'
2
2
 
3
3
  require_relative 'cache'
4
4
 
5
- module Global
6
- def api
7
- Cache.instance.global_api
8
- end
5
+ module DSL
6
+ module Global
7
+ def api
8
+ Cache.instance.global_api
9
+ end
9
10
 
10
- def state
11
- Cache.instance.global_state
12
- end
11
+ def state
12
+ Cache.instance.global_state
13
+ end
13
14
 
14
- def config(options = {})
15
- options = Logic::Options[:normalize].(options)
15
+ def config(options = {})
16
+ options = Logic::Options[:normalize].(options)
16
17
 
17
- if options.key?(:shared_objects) || options.key?(:api_reference)
18
- Cache.instance.global_api(options, recreate: true)
19
- end
18
+ if Cache.instance.api_keys?(options)
19
+ Cache.instance.global_api(options, recreate: true)
20
+ end
20
21
 
21
- return unless
22
- options.key?(:interpreter) ||
23
- options.key?(:package_path) ||
24
- options.key?(:package_cpath)
22
+ return unless Cache.instance.state_keys?(options)
25
23
 
26
- Cache.instance.global_state(options, recreate: true)
24
+ Cache.instance.global_state(options, recreate: true)
27
25
 
28
- nil
29
- end
26
+ nil
27
+ end
30
28
 
31
- def cached(all: false)
32
- return Cache.instance.keys if all
29
+ def cached(all: false)
30
+ return Cache.instance.keys if all
33
31
 
34
- Cache.instance.keys.select { |key| key[/^global/] }
35
- end
32
+ Cache.instance.keys.select { |key| key[/^global/] }
33
+ end
36
34
 
37
- def clear
38
- Cache.instance.clear_global!
39
- end
35
+ def clear
36
+ Cache.instance.clear_global!
37
+ end
40
38
 
41
- module_function :api, :state, :config, :cached, :clear
39
+ module_function :api, :state, :config, :cached, :clear
40
+ end
42
41
  end
data/dsl/state.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative 'errors'
2
2
  require_relative 'concerns/packages'
3
3
  require_relative 'concerns/fennel'
4
+ require_relative '../components/default'
4
5
 
5
6
  module DSL
6
7
  class State
@@ -87,13 +88,25 @@ module DSL
87
88
 
88
89
  private
89
90
 
90
- def build_meta(api_component, interpreter_component)
91
- meta_data = {
91
+ def build_api_meta(api_component)
92
+ global_ffi = Component::Default.instance.options[:global_ffi]
93
+
94
+ unless api_component[:meta][:options][:global_ffi].nil?
95
+ global_ffi = api_component[:meta][:options][:global_ffi]
96
+ end
97
+
98
+ {
92
99
  api_reference: api_component[:meta][:elected][:api_reference],
93
100
  shared_objects: api_component[:meta][:elected][:shared_objects],
94
- interpreter: interpreter_component[:meta][:elected][:interpreter],
95
- runtime: interpreter_component[:meta][:runtime][:lua]
101
+ global_ffi: global_ffi
96
102
  }
103
+ end
104
+
105
+ def build_meta(api_component, interpreter_component)
106
+ meta_data = build_api_meta(api_component)
107
+
108
+ meta_data[:interpreter] = interpreter_component[:meta][:elected][:interpreter]
109
+ meta_data[:runtime] = interpreter_component[:meta][:runtime][:lua]
97
110
 
98
111
  @meta = Struct.new(*meta_data.keys).new(*meta_data.values)
99
112
  end
data/dsl/sweet_moon.rb CHANGED
@@ -11,7 +11,7 @@ require_relative '../logic/interpreter'
11
11
  module SweetMoon
12
12
  module API
13
13
  def new(options = {})
14
- Cache.instance.api(Logic::Options[:normalize].(options))
14
+ DSL::Cache.instance.api(Logic::Options[:normalize].(options))
15
15
  end
16
16
 
17
17
  module_function :new
@@ -21,9 +21,9 @@ module SweetMoon
21
21
  def new(options = {})
22
22
  options = Logic::Options[:normalize].(options)
23
23
 
24
- api = Cache.instance.api_module(options)
24
+ api = DSL::Cache.instance.api_module(options)
25
25
 
26
- interpreter = Cache.instance.interpreter_module(api, options)
26
+ interpreter = DSL::Cache.instance.interpreter_module(api, options)
27
27
 
28
28
  DSL::State.new(api, interpreter, Controller::State, options)
29
29
  end
@@ -46,7 +46,7 @@ module SweetMoon
46
46
  end
47
47
 
48
48
  def global
49
- Global
49
+ DSL::Global
50
50
  end
51
51
 
52
52
  module_function :meta, :global
data/logic/spec.rb CHANGED
@@ -2,7 +2,7 @@ module Logic
2
2
  Spec = {
3
3
  name: 'sweet-moon',
4
4
  command: 'sweet-moon',
5
- version: '0.0.5',
5
+ version: '0.0.6',
6
6
  author: 'gbaptista',
7
7
  summary: 'Lua / Fennel from Ruby and vice versa. Support to LuaJIT, Lua 5.0, ' \
8
8
  'and 5.1. Lua C API for Lua 5, 4, and 3. LuaRocks and fnx integration.',
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.5
4
+ version: 0.0.6
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-25 00:00:00.000000000 Z
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -48,6 +48,7 @@ files:
48
48
  - LICENSE
49
49
  - README.md
50
50
  - components/api.rb
51
+ - components/default.rb
51
52
  - components/injections.rb
52
53
  - components/injections/injections_503.rb
53
54
  - components/injections/injections_514.rb