class Sitepress::AssetPaths

Iterates through a folder, ignores partials and files that are well known to not be part of the website files, like `.DS_Store`, etc.

Constants

IGNORE_FILE_PATTERNS

Exclude swap files created by Textmate and vim from being added to the sitemap.

PARTIAL_PREFIX

Template files that start with `_user.html.erb` are partials that we want to ignore for the site's navigation tree.

Attributes

path[R]

Public Class Methods

new(path:) click to toggle source
# File lib/sitepress/asset_paths.rb, line 24
def initialize(path:)
  @path = Pathname.new(path)
end

Public Instance Methods

each() { |path| ... } click to toggle source

Returns a list of files, paths, and node names to iterate through to build out nodes

# File lib/sitepress/asset_paths.rb, line 29
def each
  path.each_child do |path|
    yield path unless ignore_file? path
  end
end

Private Instance Methods

ignore_file?(path) click to toggle source
# File lib/sitepress/asset_paths.rb, line 37
def ignore_file?(path)
  is_partial_file?(path) or matches_ignore_file_pattern?(path)
end
is_partial_file?(path) click to toggle source
# File lib/sitepress/asset_paths.rb, line 41
def is_partial_file?(path)
  path.basename.to_s.start_with? PARTIAL_PREFIX
end
matches_ignore_file_pattern?(path) click to toggle source
# File lib/sitepress/asset_paths.rb, line 45
def matches_ignore_file_pattern?(path)
  IGNORE_FILE_PATTERNS.any? { |pattern| path.basename.fnmatch? pattern }
end