Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the EntryFilter class into the Jekyll module to avoid polluting the global namespace... #1800

Merged
merged 1 commit into from Dec 9, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 27 additions & 25 deletions lib/jekyll/entry_filter.rb
@@ -1,35 +1,37 @@
class EntryFilter
attr_reader :site
def initialize(site)
@site = site
end
module Jekyll
class EntryFilter
attr_reader :site

def initialize(site)
@site = site
end

def filter(entries)
entries.reject do |e|
unless included?(e)
special?(e) || backup?(e) || excluded?(e) || symlink?(e)
def filter(entries)
entries.reject do |e|
unless included?(e)
special?(e) || backup?(e) || excluded?(e) || symlink?(e)
end
end
end
end

def included?(entry)
site.include.glob_include?(entry)
end
def included?(entry)
site.include.glob_include?(entry)
end

def special?(entry)
['.', '_', '#'].include?(entry[0..0])
end
def special?(entry)
['.', '_', '#'].include?(entry[0..0])
end

def backup?(entry)
entry[-1..-1] == '~'
end
def backup?(entry)
entry[-1..-1] == '~'
end

def excluded?(entry)
site.exclude.glob_include?(entry)
end
def excluded?(entry)
site.exclude.glob_include?(entry)
end

def symlink?(entry)
File.symlink?(entry) && site.safe
def symlink?(entry)
File.symlink?(entry) && site.safe
end
end

end