Reformat the Jekyll module's static methods.
This commit is contained in:
parent
ab8441259e
commit
bd72265e74
|
@ -68,11 +68,12 @@ module Jekyll
|
||||||
require 'jekyll/command'
|
require 'jekyll/command'
|
||||||
require 'jekyll/liquid_extensions'
|
require 'jekyll/liquid_extensions'
|
||||||
|
|
||||||
|
class << self
|
||||||
# Public: Tells you which Jekyll environment you are building in so you can skip tasks
|
# Public: Tells you which Jekyll environment you are building in so you can skip tasks
|
||||||
# if you need to. This is useful when doing expensive compression tasks on css and
|
# if you need to. This is useful when doing expensive compression tasks on css and
|
||||||
# images and allows you to skip that when working in development.
|
# images and allows you to skip that when working in development.
|
||||||
|
|
||||||
def self.env
|
def env
|
||||||
ENV["JEKYLL_ENV"] || "development"
|
ENV["JEKYLL_ENV"] || "development"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ module Jekyll
|
||||||
# list of option names and their defaults.
|
# list of option names and their defaults.
|
||||||
#
|
#
|
||||||
# Returns the final configuration Hash.
|
# Returns the final configuration Hash.
|
||||||
def self.configuration(override)
|
def configuration(override)
|
||||||
config = Configuration[Configuration::DEFAULTS]
|
config = Configuration[Configuration::DEFAULTS]
|
||||||
override = Configuration[override].stringify_keys
|
override = Configuration[override].stringify_keys
|
||||||
config = config.read_config_files(config.config_files(override))
|
config = config.read_config_files(config.config_files(override))
|
||||||
|
@ -96,32 +97,49 @@ module Jekyll
|
||||||
config
|
config
|
||||||
end
|
end
|
||||||
|
|
||||||
# Static: Set the TZ environment variable to use the timezone specified
|
# Public: Set the TZ environment variable to use the timezone specified
|
||||||
#
|
#
|
||||||
# timezone - the IANA Time Zone
|
# timezone - the IANA Time Zone
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def self.set_timezone(timezone)
|
def set_timezone(timezone)
|
||||||
ENV['TZ'] = timezone
|
ENV['TZ'] = timezone
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.logger
|
# Public: Fetch the logger instance for this Jekyll process.
|
||||||
|
#
|
||||||
|
# Returns the LogAdapter instance.
|
||||||
|
def logger
|
||||||
@logger ||= LogAdapter.new(Stevenson.new)
|
@logger ||= LogAdapter.new(Stevenson.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.logger=(writer)
|
# Public: Set the log writer.
|
||||||
|
# New log writer must respond to the same methods
|
||||||
|
# as Ruby's interal Logger.
|
||||||
|
#
|
||||||
|
# writer - the new Logger-compatible log transport
|
||||||
|
#
|
||||||
|
# Returns the new logger.
|
||||||
|
def logger=(writer)
|
||||||
@logger = LogAdapter.new(writer)
|
@logger = LogAdapter.new(writer)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: File system root
|
# Public: An array of sites
|
||||||
#
|
#
|
||||||
# Returns the root of the filesystem as a Pathname
|
# Returns the Jekyll sites created.
|
||||||
def self.fs_root
|
def sites
|
||||||
@fs_root ||= "/"
|
@sites ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.sanitized_path(base_directory, questionable_path)
|
# Public: Ensures the questionable path is prefixed with the base directory
|
||||||
clean_path = File.expand_path(questionable_path, fs_root)
|
# and prepends the questionable path with the base directory if false.
|
||||||
|
#
|
||||||
|
# base_directory - the directory with which to prefix the questionable path
|
||||||
|
# questionable_path - the path we're unsure about, and want prefixed
|
||||||
|
#
|
||||||
|
# Returns the sanitized path.
|
||||||
|
def sanitized_path(base_directory, questionable_path)
|
||||||
|
clean_path = File.expand_path(questionable_path, "/")
|
||||||
clean_path.gsub!(/\A\w\:\//, '/')
|
clean_path.gsub!(/\A\w\:\//, '/')
|
||||||
unless clean_path.start_with?(base_directory)
|
unless clean_path.start_with?(base_directory)
|
||||||
File.join(base_directory, clean_path)
|
File.join(base_directory, clean_path)
|
||||||
|
@ -129,6 +147,8 @@ module Jekyll
|
||||||
clean_path
|
clean_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require_all 'jekyll/commands'
|
require_all 'jekyll/commands'
|
||||||
|
|
Loading…
Reference in New Issue