Module: Mustermann

Defined in:
lib/mustermann.rb,
lib/mustermann/error.rb,
lib/mustermann/rails.rb,
lib/mustermann/shell.rb,
lib/mustermann/caster.rb,
lib/mustermann/router.rb,
lib/mustermann/simple.rb,
lib/mustermann/pattern.rb,
lib/mustermann/sinatra.rb,
lib/mustermann/version.rb,
lib/mustermann/ast/node.rb,
lib/mustermann/expander.rb,
lib/mustermann/identity.rb,
lib/mustermann/template.rb,
lib/mustermann/extension.rb,
lib/mustermann/ast/parser.rb,
lib/mustermann/ast/pattern.rb,
lib/mustermann/router/rack.rb,
lib/mustermann/ast/compiler.rb,
lib/mustermann/ast/expander.rb,
lib/mustermann/equality_map.rb,
lib/mustermann/regexp_based.rb,
lib/mustermann/simple_match.rb,
lib/mustermann/router/simple.rb,
lib/mustermann/ast/translator.rb,
lib/mustermann/ast/validation.rb,
lib/mustermann/ast/transformer.rb,
lib/mustermann/ast/tree_renderer.rb

Overview

Namespace and main entry point for the Mustermann library.

Under normal circumstances the only external API entry point you should be using is Mustermann.new.

Defined Under Namespace

Modules: AST, Extension, Router Classes: Expander, Identity, Pattern, Rails, RegexpBased, Shell, Simple, SimpleMatch, Sinatra, Template

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Class, #new

Maps a type to its factory.

Examples:

Mustermann[:sinatra] # => Mustermann::Sinatra

Raises:

  • (ArgumentError)

    if the type is not supported



23
24
25
26
27
# File 'lib/mustermann.rb', line 23

def self.[](key)
  constant, library = register.fetch(key) { raise ArgumentError, "unsupported type %p" % key }
  require library if library
  constant.respond_to?(:new) ? constant : register[key] = const_get(constant)
end

.new(string, type: :sinatra, **options) ⇒ Mustermann::Pattern

Returns pattern corresponding to string.

Raises:

  • (ArgumentError)

    if the type is not supported

  • (ArgumentError)

    if some option is not supported

  • (Mustermann::Error)

    if the pattern can't be generated from the string

See Also:



11
12
13
# File 'lib/mustermann.rb', line 11

def self.new(string, type: :sinatra, **options)
  options.any? ? self[type].new(string, **options) : self[type].new(string)
end