Skip to content

yasulab/rubree

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

546 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI Deploy Coverage Code to Test Ratio Test Execution Time

Rubree

A Ruby-based regular expression editor.

Inspired by: https://rubular.com

Site View

Technology stack

⚙️ Backend

  • Ruby 3.3

    Ruby 3.4 causes runtime issues in WebAssembly builds due to missing bigdecimal support when used as a gem,
    as described in wasmify-rails Issue #7.
    We use Ruby 3.3 as a stable fallback until full 3.4 support is confirmed.

  • Ruby on Rails 8.0

    Rails 8.1 currently triggers build failures of the json gem’s native extension in wasmify-rails.
    We remain on Rails 8.0 for stability until a compatible wasmify-rails release or workaround is available, as discussed in wasmify-rails Issue #9.

  • Regexp::Parser a regular expression parser library for Ruby

🎨 Frontend

  • Hotwire for building the frontend without using much JavaScript by sending HTML instead of JSON over the wire
  • TailwindCSS to not have to write CSS at all
  • RailroadDiagrams a tiny Ruby+SVG library for drawing railroad syntax diagrams like JSON.org

🛠️ Development

  • Foreman for jsbundling-rails, cssbundling-rails
  • Lefthook Fast and powerful Git hooks manager for any type of projects

🧹 Linting and testing

  • Rubocop the Ruby Linter/Formatter that Serves and Protects
  • ERB Lint Lint your ERB or HTML files
  • Biome Format, lint, and more in a fraction of a second
  • RSpec for Ruby testing
  • Playwright for E2E testing
  • Octocov octocov is a toolkit for collecting code metrics

🚀 Build / Deployment

  • Wasmify Rails — Build Rails apps into WebAssembly so the application can run in the browser
  • GitHub Pages — Host the generated static site (Wasm bundles and assets) as the deployment target

🤖 Shift-left security

  • Dependabot automated dependency updates built into GitHub
  • Gitleaks Find secrets with Gitleaks
  • Brakeman a static analysis security vulnerability scanner for Ruby on Rails applications

▶️ CI/CD Tool

  • GitHub Actions for testing, linting, and building web application and deploy to GitHub Pages

Getting started

Install for development

  1. Clone the repo locally:
git clone https://github.com/aim2bpg/rubree.git
cd rubree
  1. Install gem and NPM packages and start the application locally:
bin/setup
  1. Then open http://localhost:3000 in your browser.

  2. (Optional) Install lefthook:

brew install lefthook
lefthook install
  1. (Optional) Install gitleaks for lefthook:
brew install gitleaks

Running linters

Rubocop:

bin/rubocop

ERB Lint:

bin/erb_lint --lint-all

Biome Lint:

bin/yarn biome check

Brakeman (security scan):

bin/brakeman --no-pager --skip-files app/assets/builds/,build/,node_modules/,pwa/,rubies/

Fixing lint errors

Rubocop:

bin/rubocop -a

ERB Lint:

bin/erb_lint --lint-all -a

Biome Lint:

bin/yarn biome check --write
bin/yarn biome migrate --write

Running tests locally

Run tests with the default Playwright (Chromium, headless) driver:

bin/rspec

Run tests with a specific driver by setting the DRIVER environment variable:

# Playwright - Chromium (with browser UI)
DRIVER=playwright_chromium bin/rspec

# Playwright - Chromium (headless)
DRIVER=playwright_chromium_headless bin/rspec

# Playwright - Firefox (with browser UI)
DRIVER=playwright_firefox bin/rspec

# Playwright - Firefox (headless)
DRIVER=playwright_firefox_headless bin/rspec

# Playwright - WebKit (with browser UI)
DRIVER=playwright_webkit bin/rspec

# Playwright - WebKit (headless)
DRIVER=playwright_webkit_headless bin/rspec

# Selenium - Chrome (with browser UI)
DRIVER=selenium_chrome bin/rspec

# Selenium - Chrome (headless)
DRIVER=selenium_chrome_headless bin/rspec

# Rack Test (no JS support)
DRIVER=rack_test bin/rspec

Test deployment locally

Roadmap

  • Basic Match Handling: Provides functionality to match regular expressions against test strings.
  • Match Positions: Supports the extraction and display of match start and end positions.
  • Capture Groups: Extracts and displays capture groups from regex matches.
  • Named Captures: Supports capturing named groups from regex matches.
  • Regex Quick Reference: Provides a concise list of commonly used regex syntax for quick reference.
  • Regex Examples: Interactive examples to test and visualize regex patterns in real-time.
  • Execution Time Measurement: Measures and reports the execution time of regex operations.
  • Regex Diagram Generation: Generates and visualizes regex patterns using SVG diagrams.
  • Regex Substitution Function: Supports regex-based string substitution.
  • Ruby Code Snippet Generation: Automatically generates Ruby code snippets for testing regex patterns.
  • Web Interface for Regex Testing: Interactive web UI to test and visualize regular expressions in real-time.
  • Permalink / Shareable URL generation: Create shareable URLs that encode the editor state (regex, sample text, and options) for easy reproduction.
  • ReDoS Check Integration: Check regular expressions for ReDoS vulnerabilities via embedded recheck Playground with one-click pattern copying. (#306)

Supported Scope of Regexp::Parser Used for SVG Output in Railroad Diagrams

  • Alternation: a\|b\|c

  • Anchors: \A, ^, \b

  • Character Classes: [abc], [^\\], [a-d&&aeiou]

  • Character Types: \d, \H, \s

  • Cluster Types: \R, \X

  • Conditional Expressions: (?(cond)yes-subexp), (?(cond)yes-subexp\|no-subexp)

  • Escape Sequences: \t, \\+, \?

  • Free Space: whitespace and # Comments (x modifier)

  • Grouped Expressions:

    • Assertions:
      • Lookahead: (?=abc)
      • Negative Lookahead: (?!abc)
      • Lookbehind: (?<=abc)
      • Negative Lookbehind: (?<!abc)
    • Atomic: (?>abc)
    • Absence: (?~abc)
  • Back-references:

    • Named: \k<name>
    • Nest Level: \k<n-1>
    • Numbered: \k<1>
    • Relative: \k<-2>
    • Traditional: \1 through \9
  • Capturing: (abc)

  • Comments: (?# comment text)

  • Named Captures: (?<name>abc), (?'name'abc)

  • Options: (?mi-x:abc), (?a:\s\w+), (?i)

  • Passive Captures: (?:abc)

  • Subexpression Calls: \g<name>, \g<1>

  • Keep: \K, (ab\Kc\|d\Ke)f

  • Literals (utf-8):

    • Ruby, ルビー, روبي
  • POSIX Classes:

    • [:alpha:], [:^digit:]
  • Quantifiers:

    • Greedy: ?, *, +, {m,M}
    • Reluctant (Lazy): ??, *?, +?
    • Possessive: ?+, *+, ++
  • String Escapes:

    • Control: \C-C, \cD
    • Hex: \x20, \xE2\x82\xAC
    • Meta: \M-c, \M-\C-C, \M-\cC, \C-\M-C, \c\M-C
    • Octal: \0, \01, \012
    • Unicode: \uHHHH, \u{H+ H+}
  • Unicode Properties (Unicode 15.0.0):

    • Age: \p{Age=5.2}, \P{age=7.0}, \p{^age=8.0}
    • Blocks: \p{InArmenian}, \P{InKhmer}, \p{^InThai}
    • Classes: \p{Alpha}, \P{Space}, \p{^Alnum}
    • Derived: \p{Math}, \P{Lowercase}, \p{^Cased}
    • General Categories: \p{Lu}, \P{Cs}, \p{^sc}
    • Scripts: \p{Arabic}, \P{Hiragana}, \p{^Greek}
    • Simple: \p{Dash}, \p{Extender}, \p{^Hyphen}

For more detailed information about supported syntax, refer to the official documentation: Supported Syntax - Regexp::Parser GitHub README

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/aim2bpg/rubree

Licence

This project is licensed under the MIT License, see the LICENSE file for details

Articles & Announcements

About

A Ruby-based regular expression editor.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Ruby 44.2%
  • HTML 24.8%
  • JavaScript 24.8%
  • CSS 4.9%
  • Shell 1.3%