Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Ruby binding #1032

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

kuboon
Copy link

@kuboon kuboon commented Feb 18, 2025

  • cargo & gem build
    • cargo build on windows fails
  • Connection object from rust to ruby.
  • gem name "limbo" has been taken. which name should be better?
  • get query results (in rust. WIP)

@kuboon
Copy link
Author

kuboon commented Feb 18, 2025

Oh sorry, I intended to create PR for my own repo.

@penberg
Copy link
Collaborator

penberg commented Feb 18, 2025

Hey @kuboon! I am more than happy to have Ruby bindings in the Limbo source tree if that's something you're interested in contributing. The test failure is not related to your PR at all so AFAICT we could just merge this. Let me know what your plans are and feel free to drop by the Limbo developer Discord if you want to chat more.


```ruby
require 'rutie'
require_relative 'path/to/your/shared/library/file'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to hide the rutie import from applications by providing some wrapper they import? I would encourage to make this gem API-compatible with sqlite3-ruby to make it easier for applications to use it.

Copy link
Author

@kuboon kuboon Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think using https://github.com/bytecodealliance/wasmtime-rb instead of building native FFI?

Anyway, I will try to implement thin wrapper gem to make compat with sqlite3-ruby

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will use magnus instead rutie.

@kuboon kuboon marked this pull request as draft February 19, 2025 09:07
@@ -0,0 +1,18 @@
Gem::Specification.new do |s|
s.name = "limbo"
Copy link
Author

@kuboon kuboon Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://rubygems.org/gems/limbo has taken. need to change.

@kuboon
Copy link
Author

kuboon commented Feb 22, 2025

I found bundle gem limbo --ext=rust is the best starting point. It initializes magnus and all build scripts.

The biggest problem is magnus currently doesn't support async fn.

#[magnus::init(name = "limbo")]
fn init(ruby: &Ruby) -> std::result::Result<(), magnus::Error> {
let module = ruby.define_module("Limbo")?;
module.const_set("CORE_VERSION", "0.0.14")?;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I get from Cargo.toml metadata?

database_class.define_method("connect", method!(Database::connect, 0))?;

let connection_class = module.define_class("Connection", ruby.class_object())?;
// connection_class.define_method("prepare", method!(Connection::prepare, 1))?;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not solve type error here.

}
},
"onCreateCommand": "pwd; cd bindings/ruby; bundle install"
}
Copy link
Author

@kuboon kuboon Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.devcontainer/bindings-ruby files are for ruby users (like me) to easily join contributing.
You can add .devcontainer/bindings-python etc.
https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#devcontainerjson

if [ ${{ github.event_name }} == "pull_request" ]; then
echo "ruby-versions=[\"3.4\"]" >> $GITHUB_OUTPUT
else
echo "ruby-versions=[\"3.1\",\"3.2\",\"3.3\",\"3.4\"]" >> $GITHUB_OUTPUT
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kuboon kuboon marked this pull request as ready for review February 25, 2025 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants