From d85c0d323601e6d6b7661978e50ff6407aff6669 Mon Sep 17 00:00:00 2001 From: Mikael Lind Date: Wed, 24 Dec 2008 16:07:38 +0100 Subject: [PATCH] ignore backup files (end with "~") --- lib/jekyll/site.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 433c754a..9af398c3 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -28,13 +28,14 @@ module Jekyll self.write_posts end - # Read all the files in /_layouts into memory for - # later use. + # Read all the files in /_layouts except backup files + # (end with "~") into memory for later use. # # Returns nothing def read_layouts base = File.join(self.source, "_layouts") entries = Dir.entries(base) + entries = entries.reject { |e| e[-1..-1] == '~' } entries = entries.reject { |e| File.directory?(File.join(base, e)) } entries.each do |f| @@ -45,12 +46,13 @@ module Jekyll # ignore missing layout dir end - # Read all the files in /_posts and create a new Post - # object with each one. + # Read all the files in /_posts except backup files (end with "~") + # and create a new Post object with each one. # # Returns nothing def read_posts(base) entries = Dir.entries(base) + entries = entries.reject { |e| e[-1..-1] == '~' } entries = entries.reject { |e| File.directory?(e) } entries.each do |f| @@ -73,8 +75,9 @@ module Jekyll end # Copy all regular files from to / ignoring - # any files/directories that are hidden (start with ".") or contain - # site content (start with "_") unless they are "_posts" directories + # any files/directories that are hidden or backup files (start + # with "." or end with "~") or contain site content (start with "_") + # unless they are "_posts" directories # The +dir+ String is a relative path used to call this method # recursively as it descends through directories # @@ -82,6 +85,7 @@ module Jekyll def transform_pages(dir = '') base = File.join(self.source, dir) entries = Dir.entries(base) + entries = entries.reject { |e| e[-1..-1] == '~' } entries = entries.reject { |e| (e != '_posts') and ['.', '_'].include?(e[0..0]) }