Class: Sitepress::AssetPaths

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sitepress/asset_paths.rb

Overview

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

Constant Summary collapse

IGNORE_PATTERNS =

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

[
  "**/*~",        # Created by many editors when things crash
  "**/*.swp",     # Created by vim
  "**/.DS_Store", # Created by our friends at Apple
  "**/*.orig",    # Created when there's a git conflict
  "**/.git*"      # This is a problem when a git repo is nested in a project's `./pages` folder.
]
PARTIAL_PREFIX =

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

"_".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ AssetPaths

Returns a new instance of AssetPaths.



24
25
26
# File 'lib/sitepress/asset_paths.rb', line 24

def initialize(path:)
  @path = Pathname.new(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



22
23
24
# File 'lib/sitepress/asset_paths.rb', line 22

def path
  @path
end

Instance Method Details

#eachObject

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



29
30
31
32
33
# File 'lib/sitepress/asset_paths.rb', line 29

def each
  path.each_child do |path|
    yield path unless ignore_file? path
  end
end