Extracted `in_dest_dir` from site.rb into reader.rb

- Extracted in_dest_dir from site.rb.
 - Updated References.
 - Ran Tests.

Signed-off-by: Martin Jorn Rogalla <martin@martinrogalla.com>
This commit is contained in:
Martin Jorn Rogalla 2015-03-04 19:21:24 +01:00
parent bb9d43dff5
commit c836ec613d
6 changed files with 7 additions and 17 deletions

View File

@ -36,7 +36,7 @@ module Jekyll
# Returns a Set with the file paths
def existing_files
files = Set.new
Dir.glob(site.in_dest_dir("**", "*"), File::FNM_DOTMATCH) do |file|
Dir.glob(site.reader.in_dest_dir("**", "*"), File::FNM_DOTMATCH) do |file|
files << file unless file =~ /\/\.{1,2}$/ || file =~ keep_file_regex || keep_dirs.include?(file)
end
files
@ -83,7 +83,7 @@ module Jekyll
#
# Returns a Set with the directory paths
def keep_dirs
site.keep_files.map { |file| parent_dirs(site.in_dest_dir(file)) }.flatten.to_set
site.keep_files.map { |file| parent_dirs(site.reader.in_dest_dir(file)) }.flatten.to_set
end
# Private: Creates a regular expression from the config's keep_files array

View File

@ -162,8 +162,8 @@ module Jekyll
#
# Returns the full path to the output file of this document.
def destination(base_directory)
dest = site.in_dest_dir(base_directory)
path = site.in_dest_dir(dest, URL.unescape_path(url))
dest = site.reader.in_dest_dir(base_directory)
path = site.reader.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index.html") if url.end_with?("/")
path << output_ext unless path.end_with?(output_ext)
path

View File

@ -140,7 +140,7 @@ module Jekyll
#
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = site.reader.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index.html") if url.end_with?("/")
path << output_ext unless path.end_with?(output_ext)
path

View File

@ -278,7 +278,7 @@ module Jekyll
# Returns destination file path String.
def destination(dest)
# The url needs to be unescaped in order to preserve the correct filename
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = site.reader.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index.html") if self.url.end_with?("/")
path << output_ext unless path.end_with?(output_ext)
path

View File

@ -99,16 +99,6 @@ module Jekyll
end
end
# Public: Prefix a given path with the destination directory.
#
# paths - (optional) path elements to a file or directory within the
# destination directory
#
# Returns a path which is prefixed with the destination directory.
def in_dest_dir(*paths)
reader.in_dest_dir(*paths)
end
# The list of collections and their corresponding Jekyll::Collection instances.
# If config['collections'] is set, a new instance is created for each item in the collection.
# If config['collections'] is not set, a new hash is returned.

View File

@ -35,7 +35,7 @@ module Jekyll
#
# Returns destination file path.
def destination(dest)
@site.in_dest_dir(*[dest, destination_rel_dir, @name].compact)
@site.reader.in_dest_dir(*[dest, destination_rel_dir, @name].compact)
end
def destination_rel_dir