Method: Doing::Plugins.template_regex

Defined in:
lib/doing/plugin_manager.rb

.template_regex(type: :export) ⇒ Regexp

Return a regular expression of all template triggers for type

Parameters:

  • type (Symbol) (defaults to: :export)

    The type :import or :export

Returns:

  • (Regexp)

    regular expression



239
240
241
242
243
244
245
246
247
248
249
# File 'lib/doing/plugin_manager.rb', line 239

def template_regex(type: :export)
  type = valid_type(type)
  pattern = []
  plugs = plugins[type].clone
  plugs.delete_if { |_, o| o[:templates].nil? }.each do |_, options|
    options[:templates].each do |t|
      pattern << t[:trigger].normalize_trigger
    end
  end
  Regexp.new("^(?:#{pattern.join('|')})$", true)
end