Class: Middleman::Sitemap::Extensions::Ignores

Inherits:
ConfigExtension show all
Defined in:
lib/middleman-core/sitemap/extensions/ignores.rb

Overview

Class to handle managing ignores

Defined Under Namespace

Classes: BlockIgnoreDescriptor, GlobIgnoreDescriptor, IgnoreDescriptor, RegexpIgnoreDescriptor, StringIgnoreDescriptor

Constant Summary

Constants included from Contracts

Contracts::PATH_MATCHER

Instance Attribute Summary

Attributes inherited from Extension

#app, #options

Instance Method Summary collapse

Methods inherited from ConfigExtension

#after_configuration, #initialize, #manipulate_resource_list, #proxy_method_call, #ready

Methods inherited from Extension

activated_extension, #add_exposed_to_context, #after_build, #after_configuration, #after_extension_activated, after_extension_activated, #before_build, #before_configuration, clear_after_extension_callbacks, config, define_setting, expose_to_application, expose_to_config, expose_to_template, global_config, helpers, #initialize, #manipulate_resource_list, option, #ready, resources

Methods included from Contracts

#Contract

Constructor Details

This class inherits a constructor from Middleman::ConfigExtension

Instance Method Details

#execute_descriptorIgnoreDescriptor

Ignore a path or add an ignore callback

Parameters:

  • path (String, Regexp)

    Path glob expression, or path regex

Returns:



14
# File 'lib/middleman-core/sitemap/extensions/ignores.rb', line 14

Contract Or[String, Regexp, Proc] => RespondTo[:execute_descriptor]

#ignore(path = nil, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/middleman-core/sitemap/extensions/ignores.rb', line 15

def ignore(path=nil, &block)
  @app.sitemap.invalidate_resources_not_ignored_cache!

  if path.is_a? Regexp
    RegexpIgnoreDescriptor.new(path)
  elsif path.is_a? String
    path_clean = ::Middleman::Util.normalize_path(path)

    if path_clean.include?('*') # It's a glob
      GlobIgnoreDescriptor.new(path_clean)
    else
      StringIgnoreDescriptor.new(path_clean)
    end
  elsif block
    BlockIgnoreDescriptor.new(nil, block)
  else
    IgnoreDescriptor.new(path, block)
  end
end