Nōdo streamlines the interaction between Ruby and Node.js, allowing Ruby code to seamlessly call Node.js functions and utilize JavaScript's capabilities in a performant way. With built-in IPC via UNIX sockets, enjoy efficient communication and maintain state across function calls without constant initialization. Perfect for integrating JavaScript libraries into Ruby applications.
Nōdo is a powerful library that enables seamless interaction between Ruby and JavaScript. It allows Ruby applications to invoke JavaScript functions executed in a dedicated Node.js process, providing a highly efficient way to leverage JavaScript's capabilities directly from Ruby code. The name "ノード" translates to "node" in Japanese, emphasizing the integration of these two powerful programming languages.
In Nōdo, JavaScript functions can be defined directly within Ruby classes, appearing similar to Ruby methods. For example:
class Foo < Nodo::Core
function :say_hi, <<~JS
(name) => {
return `Hello ${name}!`;
}
JS
end
foo = Foo.new
foo.say_hi('Nodo')
=> "Hello Nodo!"
Nōdo natively supports async functions, facilitating asynchronous operations while maintaining a synchronous Ruby call structure.
class SyncFoo < Nodo::Core
function :do_something, <<~JS
async () => { return await asyncFunc(); }
JS
end
By installing npm modules in the node_modules directory, users can easily integrate third-party libraries into their Ruby projects. For instance:
class Bar < Nodo::Core
require :uuid
function :v4, <<~JS
() => {
return uuid.v4();
}
JS
end
bar = Bar.new
bar.v4
=> "b305f5c4-db9a-4504-b0c3-4e097a5ec8b9"
nodo.import() method.For Rails developers, Nōdo provides features to manage node dependencies effectively, keeping them organized within the application's vendor directory.
Nōdo includes built-in support for detailed logging and debugging, allowing developers to track JavaScript errors and custom debug messages easily.
Evaluate JavaScript code within the Ruby context, enabling access to functions and constants defined in the Ruby classes.
foo.evaluate('3 + 5')
=> 8
Nōdo serves as a bridge between Ruby and JavaScript, empowering developers to harness the strengths of both languages seamlessly. It is a valuable tool for applications requiring interactive performance and efficient interlanguage operations.
No comments yet.
Sign in to be the first to comment.