javascriptrubyregexopalrb

Run Ruby library from JavaScript


I found a sweet library written in Ruby which I would like to use in my JS application. The library is a regular expression -> NFA conversion library and would fit perfectly for my needs.

Is there a way to call this ruby library and process the output in JavaScript?


Solution

  • If you want to run it on the back end (and I would guess you are most probably using node for that), you can call it via child_process.

    If you want to run it in a browser, your best bet is to try to transcribe the library using Ruby Opal. However, note that Opal is not fully compatible with MRI and you might need to do some tweaking.

    I would recommend searching extensively to find a similar javascript library first.