Class: Middleman::Sitemap::Extensions::Ignores::IgnoreDescriptor
- Inherits:
-
Struct
- Object
- Struct
- Middleman::Sitemap::Extensions::Ignores::IgnoreDescriptor
- Defined in:
- lib/middleman-core/sitemap/extensions/ignores.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block
20 21 22 |
# File 'lib/middleman-core/sitemap/extensions/ignores.rb', line 20 def block @block end |
#path ⇒ Object
Returns the value of attribute path
20 21 22 |
# File 'lib/middleman-core/sitemap/extensions/ignores.rb', line 20 def path @path end |
Instance Method Details
#execute_descriptor(_app, resources) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/middleman-core/sitemap/extensions/ignores.rb', line 21 def execute_descriptor(_app, resources) resources.map do |r| # Ignore based on the source path (without template extensions) if ignored?(r.path) r.ignore! elsif !r.is_a?(ProxyResource) && r.file_descriptor && ignored?(r.file_descriptor[:relative_path].to_s) # This allows files to be ignored by their source file name (with template extensions) r.ignore! end r end end |
#ignored?(match_path) ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/middleman-core/sitemap/extensions/ignores.rb', line 35 def ignored?(match_path) match_path = ::Middleman::Util.normalize_path(match_path) if path.is_a? Regexp match_path =~ path elsif path.is_a? String path_clean = ::Middleman::Util.normalize_path(path) if path_clean.include?('*') # It's a glob if defined?(::File::FNM_EXTGLOB) ::File.fnmatch(path_clean, match_path, ::File::FNM_EXTGLOB) else ::File.fnmatch(path_clean, match_path) end else match_path == path_clean end elsif block block.call(match_path) end end |