Class: EntryFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/entry_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ EntryFilter

Returns a new instance of EntryFilter.



3
4
5
# File 'lib/jekyll/entry_filter.rb', line 3

def initialize(site)
  @site = site
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



2
3
4
# File 'lib/jekyll/entry_filter.rb', line 2

def site
  @site
end

Instance Method Details

#backup?(entry) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/jekyll/entry_filter.rb', line 23

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

#excluded?(entry) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/jekyll/entry_filter.rb', line 27

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

#filter(entries) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/jekyll/entry_filter.rb', line 7

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

#included?(entry) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/jekyll/entry_filter.rb', line 15

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

#special?(entry) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/jekyll/entry_filter.rb', line 19

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

#symlink?(entry) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/jekyll/entry_filter.rb', line 31

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