Merge pull request #4966 from floydpraveen/rubocop-compliant

Merge pull request 4966
This commit is contained in:
jekyllbot 2016-06-02 22:03:02 -07:00
commit e2ae0bab8a
2 changed files with 75 additions and 73 deletions

View File

@ -16,7 +16,6 @@ AllCops:
- lib/jekyll/site.rb - lib/jekyll/site.rb
- lib/jekyll/static_file.rb - lib/jekyll/static_file.rb
- lib/jekyll/utils.rb - lib/jekyll/utils.rb
- lib/jekyll.rb
- bin/**/* - bin/**/*
- benchmark/**/* - benchmark/**/*
- script/**/* - script/**/*

View File

@ -6,79 +6,79 @@ $LOAD_PATH.unshift File.dirname(__FILE__) # For use/testing when no gem is insta
# #
# Returns nothing. # Returns nothing.
def require_all(path) def require_all(path)
glob = File.join(File.dirname(__FILE__), path, '*.rb') glob = File.join(File.dirname(__FILE__), path, "*.rb")
Dir[glob].sort.each do |f| Dir[glob].sort.each do |f|
require f require f
end end
end end
# rubygems # rubygems
require 'rubygems' require "rubygems"
# stdlib # stdlib
require "pathutil" require "pathutil"
require 'forwardable' require "forwardable"
require 'fileutils' require "fileutils"
require 'time' require "time"
require 'English' require "English"
require 'pathname' require "pathname"
require 'logger' require "logger"
require 'set' require "set"
# 3rd party # 3rd party
require 'safe_yaml/load' require "safe_yaml/load"
require 'liquid' require "liquid"
require 'kramdown' require "kramdown"
require 'colorator' require "colorator"
SafeYAML::OPTIONS[:suppress_warnings] = true SafeYAML::OPTIONS[:suppress_warnings] = true
module Jekyll module Jekyll
# internal requires # internal requires
autoload :Cleaner, 'jekyll/cleaner' autoload :Cleaner, "jekyll/cleaner"
autoload :Collection, 'jekyll/collection' autoload :Collection, "jekyll/collection"
autoload :Configuration, 'jekyll/configuration' autoload :Configuration, "jekyll/configuration"
autoload :Convertible, 'jekyll/convertible' autoload :Convertible, "jekyll/convertible"
autoload :Deprecator, 'jekyll/deprecator' autoload :Deprecator, "jekyll/deprecator"
autoload :Document, 'jekyll/document' autoload :Document, "jekyll/document"
autoload :Draft, 'jekyll/draft' autoload :Draft, "jekyll/draft"
autoload :EntryFilter, 'jekyll/entry_filter' autoload :EntryFilter, "jekyll/entry_filter"
autoload :Errors, 'jekyll/errors' autoload :Errors, "jekyll/errors"
autoload :Excerpt, 'jekyll/excerpt' autoload :Excerpt, "jekyll/excerpt"
autoload :External, 'jekyll/external' autoload :External, "jekyll/external"
autoload :FrontmatterDefaults, 'jekyll/frontmatter_defaults' autoload :FrontmatterDefaults, "jekyll/frontmatter_defaults"
autoload :Hooks, 'jekyll/hooks' autoload :Hooks, "jekyll/hooks"
autoload :Layout, 'jekyll/layout' autoload :Layout, "jekyll/layout"
autoload :CollectionReader, 'jekyll/readers/collection_reader' autoload :CollectionReader, "jekyll/readers/collection_reader"
autoload :DataReader, 'jekyll/readers/data_reader' autoload :DataReader, "jekyll/readers/data_reader"
autoload :LayoutReader, 'jekyll/readers/layout_reader' autoload :LayoutReader, "jekyll/readers/layout_reader"
autoload :PostReader, 'jekyll/readers/post_reader' autoload :PostReader, "jekyll/readers/post_reader"
autoload :PageReader, 'jekyll/readers/page_reader' autoload :PageReader, "jekyll/readers/page_reader"
autoload :StaticFileReader, 'jekyll/readers/static_file_reader' autoload :StaticFileReader, "jekyll/readers/static_file_reader"
autoload :LogAdapter, 'jekyll/log_adapter' autoload :LogAdapter, "jekyll/log_adapter"
autoload :Page, 'jekyll/page' autoload :Page, "jekyll/page"
autoload :PluginManager, 'jekyll/plugin_manager' autoload :PluginManager, "jekyll/plugin_manager"
autoload :Publisher, 'jekyll/publisher' autoload :Publisher, "jekyll/publisher"
autoload :Reader, 'jekyll/reader' autoload :Reader, "jekyll/reader"
autoload :Regenerator, 'jekyll/regenerator' autoload :Regenerator, "jekyll/regenerator"
autoload :RelatedPosts, 'jekyll/related_posts' autoload :RelatedPosts, "jekyll/related_posts"
autoload :Renderer, 'jekyll/renderer' autoload :Renderer, "jekyll/renderer"
autoload :LiquidRenderer, 'jekyll/liquid_renderer' autoload :LiquidRenderer, "jekyll/liquid_renderer"
autoload :Site, 'jekyll/site' autoload :Site, "jekyll/site"
autoload :StaticFile, 'jekyll/static_file' autoload :StaticFile, "jekyll/static_file"
autoload :Stevenson, 'jekyll/stevenson' autoload :Stevenson, "jekyll/stevenson"
autoload :Theme, 'jekyll/theme' autoload :Theme, "jekyll/theme"
autoload :ThemeBuilder, 'jekyll/theme_builder' autoload :ThemeBuilder, "jekyll/theme_builder"
autoload :URL, 'jekyll/url' autoload :URL, "jekyll/url"
autoload :Utils, 'jekyll/utils' autoload :Utils, "jekyll/utils"
autoload :VERSION, 'jekyll/version' autoload :VERSION, "jekyll/version"
# extensions # extensions
require 'jekyll/plugin' require "jekyll/plugin"
require 'jekyll/converter' require "jekyll/converter"
require 'jekyll/generator' require "jekyll/generator"
require 'jekyll/command' require "jekyll/command"
require 'jekyll/liquid_extensions' require "jekyll/liquid_extensions"
require "jekyll/filters" require "jekyll/filters"
class << self class << self
@ -94,19 +94,20 @@ module Jekyll
# options with anything in _config.yml, and adding the given options on top. # options with anything in _config.yml, and adding the given options on top.
# #
# override - A Hash of config directives that override any options in both # override - A Hash of config directives that override any options in both
# the defaults and the config file. See Jekyll::Configuration::DEFAULTS for a # the defaults and the config file.
# See Jekyll::Configuration::DEFAULTS for a
# 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 configuration(override = Hash.new) def configuration(override = {})
config = Configuration.new config = Configuration.new
unless override.delete('skip_config_files') unless override.delete("skip_config_files")
config = config.read_config_files(config.config_files(override)) config = config.read_config_files(config.config_files(override))
end end
# Merge DEFAULTS < _config.yml < override # Merge DEFAULTS < _config.yml < override
Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |config| Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |obj|
set_timezone(config['timezone']) if config['timezone'] set_timezone(obj["timezone"]) if obj["timezone"]
end end
end end
@ -115,9 +116,11 @@ module Jekyll
# timezone - the IANA Time Zone # timezone - the IANA Time Zone
# #
# Returns nothing # Returns nothing
# rubocop:disable Style/AccessorMethodName
def set_timezone(timezone) def set_timezone(timezone)
ENV['TZ'] = timezone ENV["TZ"] = timezone
end end
# rubocop:enable Style/AccessorMethodName
# Public: Fetch the logger instance for this Jekyll process. # Public: Fetch the logger instance for this Jekyll process.
# #
@ -154,11 +157,11 @@ module Jekyll
def sanitized_path(base_directory, questionable_path) def sanitized_path(base_directory, questionable_path)
return base_directory if base_directory.eql?(questionable_path) return base_directory if base_directory.eql?(questionable_path)
questionable_path.insert(0, '/') if questionable_path.start_with?('~') questionable_path.insert(0, "/") if questionable_path.start_with?("~")
clean_path = File.expand_path(questionable_path, "/") clean_path = File.expand_path(questionable_path, "/")
clean_path.sub!(/\A\w\:\//, '/') clean_path.sub!(%r!\A\w:/!, "/")
if clean_path.start_with?(base_directory.sub(/\A\w\:\//, '/')) if clean_path.start_with?(base_directory.sub(%r!\A\w:/!, "/"))
clean_path clean_path
else else
File.join(base_directory, clean_path) File.join(base_directory, clean_path)
@ -166,17 +169,17 @@ module Jekyll
end end
# Conditional optimizations # Conditional optimizations
Jekyll::External.require_if_present('liquid-c') Jekyll::External.require_if_present("liquid-c")
end end
end end
require "jekyll/drops/drop" require "jekyll/drops/drop"
require "jekyll/drops/document_drop" require "jekyll/drops/document_drop"
require_all 'jekyll/commands' require_all "jekyll/commands"
require_all 'jekyll/converters' require_all "jekyll/converters"
require_all 'jekyll/converters/markdown' require_all "jekyll/converters/markdown"
require_all 'jekyll/drops' require_all "jekyll/drops"
require_all 'jekyll/generators' require_all "jekyll/generators"
require_all 'jekyll/tags' require_all "jekyll/tags"
require 'jekyll-sass-converter' require "jekyll-sass-converter"