Use Modules From Any Technology
Goal
Use a module from any supported technology directly in a Ruby service with Graftcode - no REST wrapper, no rewrite, no custom interop. In this tutorial we use a .NET NuGet module as the example.
What You'll See
- Install a module from another technology as a strongly-typed Graft using RubyGems - just like any other gem.
- Configure the generated client for in-memory execution when the Graft ships the Receiver inside the package.
- Import and call it from your Ruby code as if it were a native library.
Prerequisites
- Ruby (3.2 or newer recommended) and Bundler installed locally
- .NET SDK (or a
Microsoft.NETCore.Appruntime) installed locally -inmemoryloads this Graft on Netcore, not on the Ruby interpreter alone
Step 1. Create a project folder
Create a new folder for your project:
mkdir ruby-dotnet-module-demo cd ruby-dotnet-module-demo
Step 2. Install a module from another technology
For this example we'll use a .NET sample library from NuGet (sdnTestSimpleCar / SimpleCar), but the same approach works with any module from a supported repository - npm, PyPI, Maven, or NuGet.
The published RubyGems package name is all lowercase (graft-nuget-sdntestsimplecar) — not graft-nuget-sdnTestSimpleCar. If bundle exec ruby main.rb says the gem is missing, your Gemfile likely used the wrong casing; fix the name and run bundle install again.
Install from the CLI:
gem install graft-nuget-sdntestsimplecar -v "0.1.0" --source https://grft.dev/
Or add a Gemfile (registry — copy from Vision when connecting to your own gateway):
# frozen_string_literal: true source "https://rubygems.org" source "https://grft.dev/" do gem "graft-nuget-sdntestsimplecar", "0.1.0" end
bundle install
This installs a Graft - a strongly-typed Ruby client generated from the remote module. You import and call it like any other gem, regardless of which technology the module was originally written in.
Step 3. Set the SDK key
Set the HYPERTUBE_KEY environment variable in your terminal before running the project:
PowerShell:
$env:HYPERTUBE_KEY="f7GZ-De6k-Mx4p-t7FN-q5DC"
Bash (macOS / Linux):
export HYPERTUBE_KEY="f7GZ-De6k-Mx4p-t7FN-q5DC"
Windows CMD:
set HYPERTUBE_KEY=f7GZ-De6k-Mx4p-t7FN-q5DC
The first successful activation creates a hypertube.lic file. Later runs (and other local projects) can reuse that license. Activating the same key again in a clean environment may return ERROR:Key already used.
Step 4. Call the cross-language module and run it
Create main.rb:
# frozen_string_literal: true require "bundler/setup" require "graft_nuget_sdntestsimplecar" GraftConfig.host = "inMemory" car = SimpleCar.new("Toyota", "Corolla", 2022, "car-001") puts car.to_string puts "Running: #{car.is_running}" car.start puts "Running: #{car.is_running}"
Run it:
ruby main.rb
Prefer property and method names from the installed gem or Vision - generated Ruby often uses snake_case (to_string, is_running) even when the .NET API uses PascalCase.
You should see the car description and running state printed in your terminal. SimpleCar comes from a .NET NuGet package, but your code reads like ordinary Ruby - no HTTP stack, no manual deserialization. GraftConfig.host = "inMemory" tells Graftcode to load and execute the .NET assembly inside the Hypertube bridge for this Graft.
Step 5. Run with a Project Key (recommended for real-world usage)
Everything above works without any account - perfect for learning and local development. When you're ready for real-world usage, create a free account at portal.graftcode.com, set up a project, and copy its Project Key.
With a Project Key, point GraftConfig.host at your project's stable WebSocket endpoint when you switch from in-memory to remote execution. A Project Key gives you:
- Stable registry URL - the address for your Grafts stays permanent, so install commands don't change when you redeploy.
- Portal visibility - see all your gateways and services in one place at gateways.graftcode.com.
- Access control - decide who can download your Grafts using package manager authentication and permissions.