Reformat the Jekyll module's static methods.

This commit is contained in:
Parker Moore 2014-08-26 23:01:21 -07:00
parent ab8441259e
commit bd72265e74
1 changed files with 78 additions and 58 deletions

View File

@ -68,11 +68,12 @@ module Jekyll
require 'jekyll/command'
require 'jekyll/liquid_extensions'
class << self
# 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
# images and allows you to skip that when working in development.
def self.env
def env
ENV["JEKYLL_ENV"] || "development"
end
@ -84,7 +85,7 @@ module Jekyll
# list of option names and their defaults.
#
# Returns the final configuration Hash.
def self.configuration(override)
def configuration(override)
config = Configuration[Configuration::DEFAULTS]
override = Configuration[override].stringify_keys
config = config.read_config_files(config.config_files(override))
@ -96,32 +97,49 @@ module Jekyll
config
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
#
# Returns nothing
def self.set_timezone(timezone)
def set_timezone(timezone)
ENV['TZ'] = timezone
end
def self.logger
# Public: Fetch the logger instance for this Jekyll process.
#
# Returns the LogAdapter instance.
def logger
@logger ||= LogAdapter.new(Stevenson.new)
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)
end
# Public: File system root
# Public: An array of sites
#
# Returns the root of the filesystem as a Pathname
def self.fs_root
@fs_root ||= "/"
# Returns the Jekyll sites created.
def sites
@sites ||= []
end
def self.sanitized_path(base_directory, questionable_path)
clean_path = File.expand_path(questionable_path, fs_root)
# Public: Ensures the questionable path is prefixed with the base directory
# 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\:\//, '/')
unless clean_path.start_with?(base_directory)
File.join(base_directory, clean_path)
@ -129,6 +147,8 @@ module Jekyll
clean_path
end
end
end
end
require_all 'jekyll/commands'