class Jekyll::EntryFilter

Constants

SPECIAL_LEADING_CHAR_REGEX

Attributes

site[R]

Public Class Methods

new(site, base_directory = nil) click to toggle source
# File lib/jekyll/entry_filter.rb, line 8
def initialize(site, base_directory = nil)
  @site = site
  @base_directory = derive_base_directory(
    @site, base_directory.to_s.dup
  )
end

Public Instance Methods

backup?(entry) click to toggle source
# File lib/jekyll/entry_filter.rb, line 55
def backup?(entry)
  entry.end_with?("~")
end
base_directory() click to toggle source
# File lib/jekyll/entry_filter.rb, line 15
def base_directory
  @base_directory.to_s
end
derive_base_directory(site, base_dir) click to toggle source
# File lib/jekyll/entry_filter.rb, line 19
def derive_base_directory(site, base_dir)
  base_dir[site.source] = "" if base_dir.start_with?(site.source)
  base_dir
end
excluded?(entry) click to toggle source
# File lib/jekyll/entry_filter.rb, line 59
def excluded?(entry)
  glob_include?(site.exclude - site.include, relative_to_source(entry)).tap do |excluded|
    if excluded
      Jekyll.logger.debug(
        "EntryFilter:",
        "excluded #{relative_to_source(entry)}"
      )
    end
  end
filter(entries) click to toggle source
# File lib/jekyll/entry_filter.rb, line 30
def filter(entries)
  entries.reject do |e|
    # Reject this entry if it is just a "dot" representation.
    #   e.g.: '.', '..', '_movies/.', 'music/..', etc
    next true if e.end_with?(".")
    # Reject this entry if it is a symlink.
    next true if symlink?(e)
    # Do not reject this entry if it is included.
    next false if included?(e)

    # Reject this entry if it is special, a backup file, or excluded.
    special?(e) || backup?(e) || excluded?(e)
  end
end
included?(entry) click to toggle source
# File lib/jekyll/entry_filter.rb, line 45
def included?(entry)
  glob_include?(site.include, entry) ||
    glob_include?(site.include, File.basename(entry))
end
relative_to_source(entry) click to toggle source
# File lib/jekyll/entry_filter.rb, line 24
def relative_to_source(entry)
  File.join(
    base_directory, entry
  )
end
special?(entry) click to toggle source
# File lib/jekyll/entry_filter.rb, line 50
def special?(entry)
  SPECIAL_LEADING_CHAR_REGEX.match?(entry) ||
    SPECIAL_LEADING_CHAR_REGEX.match?(File.basename(entry))
end