Skip to content

ydah/rubree

 
 

Repository files navigation

CI Deploy

[WIP] Rubree

A Ruby-based regular expression editor.

Inspired by: https://rubular.com

Site View

Technology stack

⚙️ Backend

🎨 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

  • Forman 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

🚀 Deployment

  • Wasmify Rails tools and extensions to pack and run Rails apps on Wasm

🖥️ Production

  • GitHub Pages for Ruby on Rails on WebAssembly, the full-stack in-browser

🤖 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.
  • Regexp 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.

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

Lisence

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

About

a Ruby-based regular expression editor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 61.6%
  • HTML 28.3%
  • JavaScript 9.5%
  • Other 0.6%