diff --git a/bindings/ruby/Cargo.toml b/bindings/ruby/Cargo.toml
new file mode 100644
index 0000000..a864e4d
--- /dev/null
+++ b/bindings/ruby/Cargo.toml
@@ -0,0 +1,3 @@
+[workspace]
+members = ["ext/regorusrb"]
+resolver = "2"
diff --git a/bindings/ruby/Gemfile b/bindings/ruby/Gemfile
index 21c6136..80c35e6 100644
--- a/bindings/ruby/Gemfile
+++ b/bindings/ruby/Gemfile
@@ -10,7 +10,7 @@ gemspec
gem "minitest", "~> 5.16"
gem "rake", "~> 13.0"
gem "rake-compiler"
-gem "rb_sys", "~> 0.9.63"
+gem "rake-compiler-dock"
gem "rubocop", "~> 1.62", require: false
gem "rubocop-minitest", require: false
gem "rubocop-rake", require: false
diff --git a/bindings/ruby/Gemfile.lock b/bindings/ruby/Gemfile.lock
index cc83c86..7059106 100644
--- a/bindings/ruby/Gemfile.lock
+++ b/bindings/ruby/Gemfile.lock
@@ -2,12 +2,13 @@ PATH
remote: .
specs:
regorusrb (0.1.0)
+ rb_sys (~> 0.9.91)
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
- json (2.7.1)
+ json (2.7.2)
language_server-protocol (3.17.0.3)
minitest (5.22.3)
parallel (1.24.0)
@@ -16,13 +17,14 @@ GEM
racc
racc (1.7.3)
rainbow (3.1.1)
- rake (13.1.0)
+ rake (13.2.1)
rake-compiler (1.2.7)
rake
- rb_sys (0.9.90)
+ rake-compiler-dock (1.4.0)
+ rb_sys (0.9.91)
regexp_parser (2.9.0)
rexml (3.2.6)
- rubocop (1.62.1)
+ rubocop (1.63.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
@@ -51,7 +53,7 @@ DEPENDENCIES
minitest (~> 5.16)
rake (~> 13.0)
rake-compiler
- rb_sys (~> 0.9.63)
+ rake-compiler-dock
regorusrb!
rubocop (~> 1.62)
rubocop-minitest
diff --git a/bindings/ruby/LICENSE.txt b/bindings/ruby/LICENSE.txt
deleted file mode 120000
index 30cff74..0000000
--- a/bindings/ruby/LICENSE.txt
+++ /dev/null
@@ -1 +0,0 @@
-../../LICENSE
\ No newline at end of file
diff --git a/bindings/ruby/LICENSE.txt b/bindings/ruby/LICENSE.txt
new file mode 100644
index 0000000..9e841e7
--- /dev/null
+++ b/bindings/ruby/LICENSE.txt
@@ -0,0 +1,21 @@
+ MIT License
+
+ Copyright (c) Microsoft Corporation.
+
+ 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:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ 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
diff --git a/bindings/ruby/README.md b/bindings/ruby/README.md
index 6d2dc25..0313827 100644
--- a/bindings/ruby/README.md
+++ b/bindings/ruby/README.md
@@ -10,14 +10,18 @@
Regorus can be used in Ruby by configuring bundler to build from the remote git source.
-Use the bundler CLI to add the gem from remote git source:
+If using [Bundler](https://bundler.io/) to manage gems (recommended), edit your gemfile to include the following
`
-bundle add regorus --git 'https://github.com/microsoft/regorus/tree/main/bindings/ruby'
+gem "regorusrb", git: "https://github.com/microsoft/regorus/", glob: "bindings/ruby/*.gemspec"
`
-or manually edit your gemfile to include the following
+or manually install checkout the source and build the gem
+
`
-gem "regorus", git: "https://github.com/microsoft/regorus/tree/main/bindings/ruby"
+git clone https://github.com/microsoft/regorus/
+cd regorus/bindings/ruby
+rake && rake build # should eventually output 'regorusrb 0.1.0 built to pkg/regorusrb-0.1.0.gem.'
+gem install --local ./pkg/regorusrb-0.1.0.gem
`
It is not yet available in rubygems.
diff --git a/bindings/ruby/Rakefile b/bindings/ruby/Rakefile
index 9b8e4f2..7bf7edd 100644
--- a/bindings/ruby/Rakefile
+++ b/bindings/ruby/Rakefile
@@ -2,22 +2,28 @@
require "bundler/gem_tasks"
require "minitest/test_task"
+require "rake/extensiontask"
+require "rubocop/rake_task"
+require "rb_sys/extensiontask"
Minitest::TestTask.create
-require "rubocop/rake_task"
-
RuboCop::RakeTask.new
-require "rb_sys/extensiontask"
-
desc "build the .gem file, including native extensions, according to the .gemspec"
task build: :compile
GEMSPEC = Gem::Specification.load("regorusrb.gemspec")
RbSys::ExtensionTask.new("regorusrb", GEMSPEC) do |ext|
- ext.lib_dir = "lib/regorusrb"
+ ext.lib_dir = "lib/regorus"
+ ext.cross_compile = true
+ ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux x86_64-darwin arm64-darwin]
end
task default: %i[compile test rubocop]
+
+desc "Build native extension for a given platform (i.e. rake 'native[x86_64-linux]')"
+task :native, [:platform] do |_t, platform:|
+ sh "bundle", "exec", "rb-sys-dock", "--platform", platform, "--build"
+end
diff --git a/bindings/ruby/ext/regorusrb/Cargo.toml b/bindings/ruby/ext/regorusrb/Cargo.toml
index 8f5be43..180b5c0 100644
--- a/bindings/ruby/ext/regorusrb/Cargo.toml
+++ b/bindings/ruby/ext/regorusrb/Cargo.toml
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
path = "src/lib.rs"
[dependencies]
-magnus = { version = "0.6.2" }
-regorus = { path = "../../../.." }
+magnus = { version = "0.6.3" }
+regorus = { git = "https://github.com/microsoft/regorus" }
serde_json = "1.0.115"
serde_magnus = "0.8.1"
diff --git a/bindings/ruby/ext/regorusrb/extconf.rb b/bindings/ruby/ext/regorusrb/extconf.rb
index 2e7d4a7..f2c54b4 100644
--- a/bindings/ruby/ext/regorusrb/extconf.rb
+++ b/bindings/ruby/ext/regorusrb/extconf.rb
@@ -3,4 +3,6 @@
require "mkmf"
require "rb_sys/mkmf"
-create_rust_makefile("regorusrb/regorusrb")
+create_rust_makefile("regorus/regorusrb") do |r|
+ r.auto_install_rust_toolchain = true
+end
diff --git a/bindings/ruby/ext/regorusrb/src/lib.rs b/bindings/ruby/ext/regorusrb/src/lib.rs
index ed8e419..d9e36fe 100644
--- a/bindings/ruby/ext/regorusrb/src/lib.rs
+++ b/bindings/ruby/ext/regorusrb/src/lib.rs
@@ -158,9 +158,9 @@ impl Engine {
})
}
- fn eval_rule(&self, path: String) -> Result