your personal string matching expert
This repository contains multiple projects (each installable as separate gems).
You can easily use the latest edge version from GitHub of any of these gems via Bundler:
git 'https://github.com/rkh/mustermann.git' do
gem 'mustermann'
gem 'mustermann-rails'
end
The identity
, regexp
and sinatra
types are included in the mustermann
gem, all the other types have their own gems.
Type | Example | Compatible with | Notes |
---|---|---|---|
cake | /:prefix/** | CakePHP | |
express | /:prefix+/:id(\d+) | Express, pillar.js | |
flask | /<prefix>/<int:id> | Flask, Werkzeug | |
identity | /image.png | any software using strings | Exact string matching (no parameter parsing). |
pyramid | /{prefix:.*}/{id} | Pyramid, Pylons | |
rails | /:slug(.:ext) | Ruby on Rails, Journey, HTTP Router, Hanami, Scalatra (if configured), NYNY | |
regexp | /(?<slug>[^\/]+) | Oniguruma, Onigmo, regular expressions |
Created when you pass a regexp to Mustermann.new. Does not support expanding or generating templates. |
shell | /*.{png,jpg} | Unix Shell (bash, zsh) | Does not support expanding or generating templates. |
simple | /:slug.:ext | Sinatra (1.x), Scalatra, Dancer, Finatra, Spark, RCRouter, kick.js |
Implementation is a direct copy from Sinatra 1.3. It is the predecessor of sinatra. Does not support expanding or generating templates. |
sinatra | /:slug(.:ext)? | Sinatra (2.x), Padrino (>= 0.13.0), Pendragon, Angelo |
This is the default and the only type "invented here". It is a superset of simple and has a common subset with template (and others). |
uri-template | /{+pre}/{page}{?q} | RFC 6570, JSON API, JSON Home Documents and many more | Standardized URI templates, can be generated from most other types. |
Any software using Mustermann is obviously compatible with at least one of the above.
Mustermann depends on tool (which has been extracted from Mustermann and Sinatra 2.0), and a Ruby 2.1 compatible Ruby implementation.
It is known to work on MRI 2.1.
JRuby will hopefully be supported with the release of JRuby 9000.
Rubinius is not currently supported. As of Rubinius 2.3.1, a large portion of the specs pass (3870 out of 3943), but certain parts are not working yet.
If you need Ruby 1.9 support, you might be able to use the unofficial mustermann19 gem based on namusyaka's fork.
Mustermann follows Semantic Versioning 2.0. Anything documented in the README or via YARD and not declared private is part of the public API.
mustermann
, and mustermann-contrib
gemsMustermann::Pattern#+
).Mustermann::Sinatra#|
may now generate a Sinatra pattern instead of a real composite.tool
gem EqualityMap
to Mustermann::EqualityMap
in corePattern#to_proc
.Pattern#|
, Pattern#&
and Pattern#^
.Pattern#peek
, Pattern#peek_size
, Pattern#peek_match
and Pattern#peek_params
.Mustermann::StringScanner
.Pattern#to_templates
.|
syntax to sinatra
templates.sinatra
templates.cake
, express
, flask
and pyramid
patterns.Pattern#expand
.identity
patterns.mustermann-fileutils
.mustermann-visualizer
.Mustermann === Mustermann.new('...')
returns true
.regexp
pattern.Mustermann::Mapper
.Pattern#expand
for generating strings from patterns.