module Pasta::Ingredients::ClassMethods

Public Instance Methods

grammar(name, &rules) click to toggle source

Public. The DSL for declaring grammar rules in a recipe.

Recipes contain grammars that are defined in ordered arrays. Grammars are recursively matched in a top down

fashion where the array elements match ingredients.  Grammar matching is done on a first match basis so that
the last rule can be a catch-all one.

name - a Symbol naming the grammar rules - a block defining the grammar

Example

grammar(:html)       { [:blockquotes, :paragraphs] }
grammar(:blockquote) { [:blockquote, :paragraphs] }
grammar(:paragraph)  { [:links, :emphasis, :bold, :text] }

Returns nothing

# File lib/pasta/ingredients.rb, line 43
def grammar(name, &rules)
  rules.call.each { |rule| require "pasta/ingredients/#{rule.to_s}" }
  @@grammars[name] = rules.call
end
grammars() click to toggle source
# File lib/pasta/ingredients.rb, line 24
def grammars
  @@grammars
end