Skip to content

Commit

Permalink
fix backup file ignore merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Dec 24, 2008
2 parents d435eaa + d85c0d3 commit 9fb1f6e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/jekyll/site.rb
Expand Up @@ -28,13 +28,14 @@ def process
self.write_posts
end

# Read all the files in <source>/_layouts into memory for
# later use.
# Read all the files in <source>/_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|
Expand All @@ -45,15 +46,16 @@ def read_layouts
# ignore missing layout dir
end

# Read all the files in <base>/_posts and create a new Post
# object with each one.
# Read all the files in <base>/_posts except backup files (end with "~")
# and create a new Post object with each one.
#
# Returns nothing
def read_posts(dir)
base = File.join(self.source, dir, '_posts')

entries = []
Dir.chdir(base) { entries = Dir['**/*'] }
entries = entries.reject { |e| e[-1..-1] == '~' }
entries = entries.reject { |e| File.directory?(File.join(base, e)) }

# first pass processes, but does not yet render post content
Expand Down Expand Up @@ -84,15 +86,17 @@ def write_posts
end

# Copy all regular files from <source> to <dest>/ 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
#
# Returns nothing
def transform_pages(dir = '')
base = File.join(self.source, dir)
entries = Dir.entries(base)
entries = entries.reject { |e| e[-1..-1] == '~' }
entries = entries.reject do |e|
(e != '_posts') and ['.', '_'].include?(e[0..0])
end
Expand Down

0 comments on commit 9fb1f6e

Please sign in to comment.