Remove code duplication: #write in Page and Post is the same.

This commit is contained in:
Parker Moore 2013-04-16 02:55:31 +02:00
parent c0c0150bb5
commit 6ed41e373c
3 changed files with 13 additions and 26 deletions

View File

@ -118,5 +118,18 @@ module Jekyll
end
end
end
# Write the generated page file to the destination directory.
#
# dest - The String path to the destination dir.
#
# Returns nothing.
def write(dest)
path = destination(dest)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
f.write(self.output)
end
end
end
end

View File

@ -129,19 +129,6 @@ module Jekyll
path
end
# Write the generated page file to the destination directory.
#
# dest - The String path to the destination dir.
#
# Returns nothing.
def write(dest)
path = destination(dest)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
f.write(self.output)
end
end
# Returns the object as a debug String.
def inspect
"#<Jekyll:Page @name=#{self.name.inspect}>"

View File

@ -258,19 +258,6 @@ module Jekyll
path
end
# Write the generated post file to the destination directory.
#
# dest - The String path to the destination dir.
#
# Returns nothing.
def write(dest)
path = destination(dest)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
f.write(self.output)
end
end
# Convert this post into a Hash for use in Liquid templates.
#
# Returns the representative Hash.