~cytrogen/masto-fe

ref: 8131a5b330c6fb20ca9aa5cd1ba04c7f9ddc33d2 masto-fe/app/lib/scope_parser.rb -rw-r--r-- 401 bytes
8131a5b3 — Eugen Rochko Add ALT badges to media that has alternative text in web UI (#24782) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
# frozen_string_literal: true

class ScopeParser < Parslet::Parser
  rule(:term)      { match('[a-z]').repeat(1).as(:term) }
  rule(:colon)     { str(':') }
  rule(:access)    { (str('write') | str('read')).as(:access) }
  rule(:namespace) { str('admin').as(:namespace) }
  rule(:scope)     { ((namespace >> colon).maybe >> ((access >> colon >> term) | access | term)).as(:scope) }
  root(:scope)
end