Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/camertron/onigmo-ruby
The Onigmo regular expression engine compiled to WASM and wrapped in a Ruby embrace.
https://github.com/camertron/onigmo-ruby
Last synced: 18 days ago
JSON representation
The Onigmo regular expression engine compiled to WASM and wrapped in a Ruby embrace.
- Host: GitHub
- URL: https://github.com/camertron/onigmo-ruby
- Owner: camertron
- License: mit
- Created: 2024-06-23T17:32:23.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-23T20:17:33.000Z (7 months ago)
- Last Synced: 2024-11-04T00:41:59.827Z (2 months ago)
- Language: Ruby
- Size: 130 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## onigmo-ruby
![Unit Tests](https://github.com/camertron/onigmo-ruby/actions/workflows/unit_tests.yml/badge.svg?branch=main)
The [Onigmo](https://github.com/k-takata/Onigmo) regular expression engine compiled to WASM and wrapped in a Ruby embrace.
## What is this thing?
I know what you're thinking. Onigmo is built into Ruby - why is this project necessary?? Simple! I created it to serve as an example of how to interact with a WASM module in Ruby. Onigmo is a non-trivial project and one that has real-world use-cases, which makes it a better case study than many of the examples that can be found online.
So, please don't use this project as your regular expression engine. But please _do_ use it to learn how to call WASM functions from Ruby, read WASM memory, etc etc.
## Usage
Compile a regex:
```ruby
re = Onigmo::OnigRegexp.compile("[abc]")
```Search for text:
```ruby
match_data = re.search("foo a zoo")match_data.captures # => [[4, 5]]
match_data.match(0) # => "a"
match_data.get_begin(0) # => 4
match_data.get_end(0) # => 5
```## WASM module
The WASM module at vendor/onigmo.wasm was built from [onigmo-wasm](https://github.com/camertron/onigmo-wasm).
## Running Tests
`bundle exec rake` should do the trick.
## License
Licensed under the MIT license. See LICENSE for details.
## Authors
* ongimo-ruby: Cameron C. Dutro: http://github.com/camertron
* Onigmo: K. Takata: https://github.com/k-takata