The Amazing Mustermann
This repository contains multiple projects (each installable as separate gems).
- mustermann: Your personal string matching expert. This is probably what you're looking for.
- mustermann-contrib: A meta gem depending on all other official mustermann gems.
- mustermann-fileutils: Efficient file system operations using Mustermann patterns.
- mustermann-strscan: A version of Ruby's StringScanner made for pattern objects.
- mustermann-visualizer: Syntax highlighting and tree visualization for patterns.'
- A selection of pattern types for mustermann, each as their own little library, see below.
Git versions with Bundler
You can easily use the latest edge version from GitHub of any of these gems via Bundler:
github 'sinatra/mustermann' do
gem 'mustermann'
gem 'mustermann-contrib'
end
Pattern Types
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.
Requirements
Ruby 2.6+ compatible Ruby implementation.
JRuby support is unknown, see more in issue #72.
Release History
Mustermann follows Semantic Versioning 2.0. Anything documented in the README or via YARD and not declared private is part of the public API.
Stable Releases
-
Mustermann 3.0.3 (2024-09-03)
- Fix performance issue for
Mustermann::AST::Translator#escape
#142 @hsbt, @ericproulx
- Fix performance issue for
-
Mustermann 3.0.2 (2024-08-09)
-
Mustermann 3.0.1 (2024-07-31)
-
Mustermann 3.0.0 (2022-07-24)
- Drop support for old Rubies < 2.6.
-
Mustermann 2.0.2 (2022-07-22)
-
Mustermann 2.0.1 (2022-07-19)
-
Mustermann 2.0.0 (2022-07-18)
-
Mustermann 1.1.2 (2022-07-16)
- Add compatibility with --enable=frozen-string-literal param. Fixes #110 @michal-granec
-
Mustermann 1.1.1 (2020-01-04)
-
Mustermann 1.1.0 (2019-12-30)
- Proper handling of
Mustermann::ExpandError
. Fixes #88 @namusyaka - Support Ruby 3 keyword arguments. @mame
- At the same time, we dropped a support that accepts options followed by mappings on
Mustermann::Mapper
. Reference commit
- At the same time, we dropped a support that accepts options followed by mappings on
- Improve documentation and development. @horaciob, @epistrephein, @jbampton, @jkowens, @junaruga
- Proper handling of
-
Mustermann 1.0.3 (2018-08-17)
- Handle
with_look_ahead
on SafeRenderer. Fixes sinatra/sinatra#1409 @namusyaka - Fix
EqualityMap#fetch
to be compatible with the fallbackHash#fetch
. Fixes #89 @eregon - Improve code base and documentation. @sonots, @iguchi1124
- Handle
-
Mustermann 1.0.2 (2018-02-17)
- Look ahead same patterns as its own when concatenation. Fixes sinatra/sinatra#1361 @namusyaka
- Improve development support and documentation. @EdwardBetts, @284km, @yb66 and @garybernhardt
-
Mustermann 1.0.1 (2017-08-26)
Docs
- Updating readme to list Ruby 2.2 as minimum commit (@cassidycodes)
- Fix rendering of HTML table commit (@stevenwilkin)
- Update summary and description in gemspec file. commit (@junaruga)
Fixes
-
Mustermann 1.0.0 (2017-03-05)
- First stable release.
- Includes
mustermann
, andmustermann-contrib
gems - Sinatra patterns: Allow | outside of parens.
- Add concatenation support (
Mustermann::Pattern#+
). -
Mustermann::Sinatra#|
may now generate a Sinatra pattern instead of a real composite. - Add syntax highlighting support for composite patterns.
- Remove routers (they were out of scope for the main gem).
- Rails patterns: Add Rails 5.0 compatibility mode, make it default.
- Moved
tool
gemEqualityMap
toMustermann::EqualityMap
in core - Improve documentation.
Development Releases
-
Mustermann 0.4.0 (2014-11-26)
- More Infos: RubyGems.org, RubyDoc.info, GitHub.com
- Split into multiple gems.
- Add
Pattern#to_proc
. - Add
Pattern#|
,Pattern#&
andPattern#^
. - Add
Pattern#peek
,Pattern#peek_size
,Pattern#peek_match
andPattern#peek_params
. - Add
Mustermann::StringScanner
. - Add
Pattern#to_templates
. - Add
|
syntax tosinatra
templates. - Add template style placeholders to
sinatra
templates. - Add
cake
,express
,flask
andpyramid
patterns. - Allow passing in additional value behavior directly to
Pattern#expand
. - Fix expanding of multiple splats.
- Add expanding to
identity
patterns. - Add
mustermann-fileutils
. - Make expander accept hashes with string keys.
- Allow named splats to be named splat.
- Support multiple Rails versions.
- Type option can be set to nil to get the default type.
- Add
mustermann-visualizer
.
-
Mustermann 0.3.1 (2014-09-12)
- More Infos: RubyGems.org, RubyDoc.info, GitHub.com
- Speed up pattern generation and matching (thanks Daniel Mendler)
- Small change so
Mustermann === Mustermann.new('...')
returnstrue
.
-
Mustermann 0.3.0 (2014-08-18)
- More Infos: RubyGems.org, RubyDoc.info, GitHub.com
- Add
regexp
pattern. - Add named splats to Sinatra patterns.
- Add
Mustermann::Mapper
. - Improve duck typing support.
- Improve documentation.
-
Mustermann 0.2.0 (2013-08-24)
- More Infos: RubyGems.org, RubyDoc.info, GitHub.com
- Add first class expander objects.
- Add params casting for expander.
- Add simple router and rack router.
- Add weak equality map to significantly improve performance.
- Fix Ruby warnings.
- Improve documentation.
- Refactor pattern validation, AST transformations.
- Increase test coverage (from 100%+ to 100%++).
- Improve JRuby compatibility.
- Work around bug in 2.0.0-p0.
-
Mustermann 0.1.0 (2013-05-12)
- More Infos: RubyGems.org, RubyDoc.info, GitHub.com
- Add
Pattern#expand
for generating strings from patterns. - Add better internal API for working with the AST.
- Improved documentation.
- Avoids parsing the path twice when used as Sinatra extension.
- Better exceptions for unknown pattern types.
- Better handling of edge cases around extend.
- More specs to ensure API stability.
- Largely rework internals of Sinatra, Rails and Template patterns.
-
Mustermann 0.0.1 (2013-04-27)
- More Infos: RubyGems.org, RubyDoc.info, GitHub.com
- Initial Release.