-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Ruby flavor #48
Comments
I'd love to, but I would need to look into a good way of doing this without incorporating a server.. |
How do you currently do it with Python and PHP? Don't those need a server? |
Maybe you could try compiling Rubinius's implementation of |
@firasdib So do you think it would be feasible to compile Rubinius's implementation of Ruby's |
I don't have the time to fiddle with it right now, but you're free to. I would suspect Opal would use javascript regex implementation and not rubys own engine. |
@firasdib Yeah, Opal's native implementation of Maybe I'll look into this a bit deeper later. Really there's only so far I can go though without having access to Regex101's source (e.g. I can't do the final step of integrating my solution with Regex101 and sending a pull request). |
Keep me posted! As long as you can get a basic working sample I can finish the rest. |
No idea how different Ruby's regex is. There is Rubular which is a browser based regex editor/tester. Not sure if it uses a server execution. Ruby could be a solid addition since you already have python regex. I would have suggested it myself. |
@bryc Rubular runs server side, which is something I'm trying to avoid. I agree this would be a great addition, but I need to think of a good way of doing this. |
+1 |
👍 Waiting for Ruby support |
@firasdib I too would really love Ruby support, as while I use Rubular now, the explanations and match information on regex101 are really invaluable to someone like me learning several flavors at once. Regarding running a Ruby engine server-side: feel free to email me privately if you want, but what sort of server specs would you need (processing capabilities, RAM, monthly data transfer amounts, disk space, etc.), or are you just not interested in a server-side approach at all? I ask because I'm a very happy customer of Webfaction, and I'd be willing to donate some space, or donate money to support a separate account (whatever would work best). |
👍 |
1 similar comment
👍 |
The new release will feature a code generator for Ruby which might help some. The PCRE engine is still as close as you're going to get, which is likely going to cover it for most of your cases. But so far I have not been able to get the actual engine running. Sorry! |
👍 |
This might be possible now with the emergence of WebAssembly. In fact, there's a project called ruby-wasm that can compile Ruby scripts into WebAssembly modules (technically, it actually compiles a minimal interpreter and embeds the script), and it even allows the use of some gems, such as mruby-onig-regexp, an MRuby version of the Onigmo regex library, the default regex library for Ruby 2.x. The only issue is that you can't call from Ruby into JavaScript or JavaScript into Ruby, which unfortunately means it can't be used for this project yet. However, it is something to watch and probably the quickest and easiest way of implementing Ruby regexes client-side. |
I also found onigasm, which is Oniguruma compiled to WebAssembly, and that is in a usable state. |
This is the same method that is currently being tested for .NET flavour. If that goes well, maybe something similar could be done for Ruby. |
Has there been any advancements that will allow us to run the ruby regex engine using WASM? If someone can whip up an example and show me how to build it, I can add it to the website. |
This PR seems to address that point: k-takata/Onigmo#153 Got it compiled with below git clone [email protected]:interscript/Onigmo.git
cd Onigmo
git remote set-url origin [email protected]:k-takata/Onigmo.git
git fetch
git pull --no-commit
docker run --rm -e BUILD="stdlib" -v $(pwd):/src emscripten/emsdk bash -c "apt-get up
date; apt-get install wabt;bash build-wasm.sh" Test import in node cat << EOF > index.mjs
import * as M from '/onigmo.wasm'
console.log(M);
EOF
docker run --rm -v $(pwd)/onigmo.wasm:/onigmo.wasm -v $(pwd)/index.mjs:/index.mjs node
--experimental-modules --experimental-wasm-modules index.mjs Or in browser <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Onigmo WebAssembly Example</title>
<script type="application/javascript">
WebAssembly.instantiateStreaming(
fetch('onigmo.wasm'), importObject).then(obj => {
console.log(obj);
})
</script>
</head> |
@scodeman The PR looks stale, do you know if there is any progress? Fwiw, Onigmo seems quite similar to PCRE. |
I just wanted to highlight that Ruby 3.2.0 will come with WASM / WASI support. I wrote an article (in french) talking about that. There are WebAssembly runtime for Ruby like wasmer-ruby. Some people already made Ruby in the browser projects using WASM like runrb.io (source) or try ruby. So maybe the better way would be to compile Ruby to webassembly? |
Please add ruby support.
The text was updated successfully, but these errors were encountered: