Move PathManager methods into its singleton class
This commit is contained in:
parent
9b96cdfa7d
commit
0dedc09ab3
|
@ -16,11 +16,12 @@ module Jekyll
|
|||
# This class cannot be initialized from outside
|
||||
private_class_method :new
|
||||
|
||||
class << self
|
||||
# Wraps `File.join` to cache the frozen result.
|
||||
# Reassigns `nil`, empty strings and empty arrays to a frozen empty string beforehand.
|
||||
#
|
||||
# Returns a frozen string.
|
||||
def self.join(base, item)
|
||||
def join(base, item)
|
||||
base = "" if base.nil? || base.empty?
|
||||
item = "" if item.nil? || item.empty?
|
||||
@join ||= {}
|
||||
|
@ -32,7 +33,7 @@ module Jekyll
|
|||
# and prepends the questionable path with the base directory if false.
|
||||
#
|
||||
# Returns a frozen string.
|
||||
def self.sanitized_path(base_directory, questionable_path)
|
||||
def sanitized_path(base_directory, questionable_path)
|
||||
@sanitized_path ||= {}
|
||||
@sanitized_path[base_directory] ||= {}
|
||||
@sanitized_path[base_directory][questionable_path] ||= begin
|
||||
|
@ -60,3 +61,4 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue