sweet-moon 0.0.1 → 0.0.2

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: 1e1ed99acf5622e7a68168e97a5543a952da6cbd057b29d35dcac167cdd7ed3e
4
- data.tar.gz: 30ffaf5cd2c96429114950db5e44c39c328cdefeb711df44eba1d5b288d34a1e
3
+ metadata.gz: 7bc6ba34912c2d5c9e26b95b385e4a992b186b6adbe81e40e0e6068cc363a948
4
+ data.tar.gz: 751f266193c94b533cf8f0b38f99745870688a2efd01e5277bb25d0aafe4b314
5
5
  SHA512:
6
- metadata.gz: 375db63fb25932d6d1e0d1fda599c996a62efd2f51691528785e34b2bba37078dcb98db1f05f669375759852671cf0792aed27110fea91e8d351406ba219823f
7
- data.tar.gz: bd4732726abfb6f8ce2dcf0b4bc81d858bb03d9cde60610f0e02372e29c2951cf47f2b2d6cebd3f2eb5d25b23daa29ec6097f8603e578d4dfcd572486b3c1eee
6
+ metadata.gz: 1fac3cd35cc1afd5cf1918f98326237203f9e12c631ccde66946a6496d24d90e69cf06a43413b1f58527c486f81f50098d7d866547389936becac5b6ba8eda84
7
+ data.tar.gz: e14b5c3eecbdeefa68747f4b2cf8377c0b99289783bfd5dd3eec5c295368bea65eca70be594f4272777cbd811ecdb6a3fef36ce73103349831072d44851a51bb
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2022 Guilherme Baptista
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Sweet Moon
2
+ [![Gem Version](https://badge.fury.io/rb/sweet-moon.svg)](https://badge.fury.io/rb/sweet-moon)
2
3
 
3
4
  _Sweet Moon_ is a resilient solution that makes working with [Lua](https://www.lua.org) / [Fennel](https://fennel-lang.org) from [Ruby](https://www.ruby-lang.org) and vice versa a delightful experience.
4
5
 
@@ -26,6 +27,7 @@ _Sweet Moon_ is a resilient solution that makes working with [Lua](https://www.l
26
27
  - [Fennel](#fennel)
27
28
  - [Fennel Usage](#fennel-usage)
28
29
  - [Fennel Setup](#fennel-setup)
30
+ - [Integration with fnx](#integration-with-fnx)
29
31
  - [Global vs Isolated](#global-vs-isolated)
30
32
  - [Error Handling](#error-handling)
31
33
  - [Where can I find .so files?](#where-can-i-find-so-files)
@@ -38,6 +40,9 @@ _Sweet Moon_ is a resilient solution that makes working with [Lua](https://www.l
38
40
  - [Lua 5.4](#lua-54)
39
41
  - [Lua 4.0](#lua-40)
40
42
  - [Development](#development)
43
+ - [Tests Setup](#tests-setup)
44
+ - [Running](#running)
45
+ - [Supporting New Versions](#supporting-new-versions)
41
46
 
42
47
  ## Supported Versions
43
48
 
@@ -64,7 +69,7 @@ gem install sweet-moon
64
69
  > **Disclaimer:** It's an early-stage project, and you should expect breaking changes.
65
70
 
66
71
  ```ruby
67
- gem 'sweet-moon', '~> 0.0.1'
72
+ gem 'sweet-moon', '~> 0.0.2'
68
73
  ```
69
74
 
70
75
  ```ruby
@@ -552,8 +557,8 @@ require 'sweet-moon'
552
557
 
553
558
  state = SweetMoon::State.new
554
559
 
555
- state.eval('package.path = package.path .. ";/my-modules/?.lua"')
556
- state.eval('package.cpath = package.cpath .. ";/my-modules/?.so"')
560
+ state.eval('package.path = "/my-modules/?.lua;" .. package.path')
561
+ state.eval('package.cpath = "/my-modules/?.so;" .. package.cpath')
557
562
 
558
563
  state.eval('some_package = require("my_module")')
559
564
  ```
@@ -682,7 +687,7 @@ For global:
682
687
  ```ruby
683
688
  require 'sweet-moon'
684
689
 
685
- SweetMoon.global.config.new(
690
+ SweetMoon.global.config(
686
691
  package_path: [
687
692
  '/home/me/.luarocks/share/lua/5.4/?.lua',
688
693
  '/home/me/.luarocks/share/lua/5.4/?/init.lua'
@@ -783,6 +788,28 @@ SweetMoon.global.config(package_path: '/folder/fennel.lua')
783
788
  SweetMoon.global.state.fennel.eval('(+ 1 1)') # => 2
784
789
  ```
785
790
 
791
+ ### Integration with fnx
792
+
793
+ [fnx](https://github.com/gbaptista/fnx) is a package manager for the Fennel language.
794
+
795
+ After installing `fnx` and configuring it for [_Embedding_](https://github.com/gbaptista/fnx#embedding), you can:
796
+
797
+ ```ruby
798
+ require 'sweet-moon'
799
+
800
+ fennel = SweetMoon::State.new.fennel
801
+
802
+ fennel.eval('(let [fnx (require :fnx)] (fnx.bootstrap!))')
803
+ ```
804
+
805
+ Done. It will automatically inject all your dependencies according to your `.fnx.fnl` file, similar to using the `fnx` command.
806
+
807
+ To enforce the path for the `.fnx.fnl` file:
808
+
809
+ ```ruby
810
+ fennel.eval('(let [fnx (require :fnx)] (fnx.bootstrap! "/project/.fnx.fnl"))')
811
+ ```
812
+
786
813
  ## Global vs Isolated
787
814
 
788
815
  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):
@@ -821,8 +848,8 @@ You may want to use an isolated API for scenarios like interacting with two Lua
821
848
  ```ruby
822
849
  require 'sweet-moon'
823
850
 
824
- api_5 = SweetMoon.global.config(shared_object: '/usr/lib/liblua5.s')
825
- api_3 = SweetMoon.global.config(shared_object: '/usr/lib/liblua3.so')
851
+ api_5 = SweetMoon::API.new(shared_object: '/usr/lib/liblua5.s')
852
+ api_3 = SweetMoon::API.new(shared_object: '/usr/lib/liblua3.so')
826
853
 
827
854
  api_5.luaL_newstate
828
855
 
@@ -882,7 +909,7 @@ require 'sweet-moon'
882
909
 
883
910
  begin
884
911
  SweetMoon.global.state.eval('return 1 + true')
885
- rescue SweetMoon::Errors::LuaSyntaxError => error
912
+ rescue SweetMoon::Errors::LuaRuntimeError => error
886
913
  puts error.message
887
914
  # => [string "return 1 + true"]:1: attempt to perform arithmetic on a boolean value
888
915
  end
@@ -896,7 +923,7 @@ require 'sweet-moon/errors'
896
923
 
897
924
  begin
898
925
  SweetMoon.global.state.eval('return 1 + true')
899
- rescue LuaSyntaxError => error
926
+ rescue LuaRuntimeError => error
900
927
  puts error.message
901
928
  # => [string "return 1 + true"]:1: attempt to perform arithmetic on a boolean value
902
929
  end
@@ -904,9 +931,9 @@ end
904
931
 
905
932
  ## Where can I find .so files?
906
933
 
907
- Due to the Lua's popularity, you likely have it already on your system, and _Sweet Moon_ will be able to find the files on its own.
934
+ Due to the Lua's popularity, you likely have it already on your system, and _Sweet Moon_ will be able to find the files by itself.
908
935
 
909
- Either way, you can download it from this page:
936
+ Either way, you can download it from:
910
937
  - [Lua Binaries](http://luabinaries.sourceforge.net)
911
938
  - [LuaJIT releases](http://luajit.org/download.html)
912
939
 
@@ -1138,6 +1165,26 @@ rubocop -a
1138
1165
  rspec
1139
1166
  ```
1140
1167
 
1168
+ ### Tests Setup
1169
+
1170
+ To setup tests:
1171
+
1172
+ ```
1173
+ cp config/tests.sample.yml config/tests.yml
1174
+ ```
1175
+
1176
+ Clone the [sweet-moon-test](https://github.com/gbaptista/sweet-moon-test) repo somewhere:
1177
+
1178
+ ```sh
1179
+ git clone git@github.com:gbaptista/sweet-moon-test.git
1180
+ ```
1181
+
1182
+ Update the [`config/tests.yml`](https://github.com/gbaptista/sweet-moon/blob/main/config/tests.sample.yml) accordingly.
1183
+
1184
+ Alternatively: Find or build the _Shared Objects_ for your Operating System on your own.
1185
+
1186
+ ### Running
1187
+
1141
1188
  ```sh
1142
1189
  ./ports/in/shell/sweet-moon version
1143
1190
 
@@ -1147,3 +1194,21 @@ bundle exec sweet-moon signatures /lua/lib/542 542.rb
1147
1194
 
1148
1195
  bundle exec ruby some/file.rb
1149
1196
  ```
1197
+
1198
+ ### Supporting New Versions
1199
+
1200
+ Download both the source code and the libraries.
1201
+
1202
+ Example: For [Lua 5.4.2](https://sourceforge.net/projects/luabinaries/files/5.4.2/), you would download _"Linux Libraries"_ and _"Docs and Sources."_
1203
+
1204
+ Extract everything to a folder, e.g., `lua-542-source-libs`.
1205
+
1206
+ Run the command to extract the signatures:
1207
+
1208
+ ```shell
1209
+ bundle exec sweet-moon signatures /home/me/lua-542-source-libs 542.rb
1210
+ ```
1211
+
1212
+ Check the `542.rb` file for the output and then start coding.
1213
+
1214
+ You can use the [`logic/signatures`](https://github.com/gbaptista/sweet-moon/tree/main/logic/signatures) folder as a reference starting point.
@@ -1,15 +1,54 @@
1
+ # Available at https://github.com/gbaptista/sweet-moon-test
2
+
1
3
  luarocks:
2
4
  - /home/me/.luarocks/share/lua/5.4/?.lua
3
5
  - /home/me/.luarocks/share/lua/5.4/?/init.lua
4
6
  - /home/me/.luarocks/lib/lua/5.4/?.so
5
7
 
8
+ jit:2.0.5:
9
+ description: 'Lua Jit 2.0.5 + Fennel 1.0.0'
10
+ shared_object: /home/me/sweet-moon-test/libluajit.so.2.0.5
11
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
12
+
6
13
  5.4.4:
7
14
  description: 'Lua 5.4.4 + Fennel 1.0.0'
8
- shared_object: /resources/liblua.so.5.4.4
9
- fennel: /resources/fennel.lua
15
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.4.4
16
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
17
+
18
+ 5.4.2:
19
+ description: 'Lua 5.4.2 + Fennel 1.0.0'
20
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.4.2
21
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
22
+
23
+ 5.3.3:
24
+ description: 'Lua 5.3.3'
25
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.3.3
26
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
27
+
28
+ 5.2.4:
29
+ description: 'Lua 5.2.4'
30
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.2.4
31
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
32
+
33
+ 5.1.5:
34
+ description: 'Lua 5.1.5'
35
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.1.5
36
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
37
+
38
+ 5.0.3:
39
+ description: 'Lua 5.0.3'
40
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.0.3
10
41
 
11
42
  4.0.1:
12
43
  description: 'Lua 4.0.1'
13
44
  shared_objects:
14
- - /resources/liblua.so.4.0.1
15
- - /resources/liblualib.so.4.0.1
45
+ - /home/me/sweet-moon-test/liblua.so.4.0.1
46
+ - /home/me/sweet-moon-test/liblualib.so.4.0.1
47
+
48
+ 3.2.2:
49
+ description: 'Lua 3.2.2'
50
+ shared_object: /home/me/sweet-moon-test/liblua.so.3.2.2
51
+
52
+ '?':
53
+ description: 'Lua ?'
54
+ shared_object: /home/me/sweet-moon-test/liblua.so
@@ -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/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.2',
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.2
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-22 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: []