Shell Syntax for Mustermann

This gem implements the rails pattern type for Mustermann. It is compatible with common Unix shells (like bash or zsh).

Overview

Supported options: uri_decode and ignore_unknown_options.

External documentation: Ruby's fnmatch, Wikipedia: Glob (programming)

require 'mustermann'

pattern = Mustermann.new('/*', type: :shell)
pattern === "/foo.bar" # => true
pattern === "/foo/bar" # => false

pattern = Mustermann.new('/**/*', type: :shell)
pattern === "/foo.bar" # => true
pattern === "/foo/bar" # => true

pattern = Mustermann.new('/{foo,bar}', type: :shell)
pattern === "/foo"     # => true
pattern === "/bar"     # => true
pattern === "/baz"     # => false

Syntax

Syntax Element Description
* Matches anything but a slash.
** Matches anything.
[set] Matches one character in set.
{a,b} Matches a or b.
\x Matches x or URI encoded version of x. For instance \* matches *.
any other character Matches exactly that character or a URI encoded version of it.